1 /* This test should test the stacktrace functionality.
2 We only print ClassName and MethName since the other information
3 like FileName and LineNumber are not consistent while building
4 native or interpreted and we want to test the output inside the dejagnu
6 Also, we have to make the methods public since they might be optimized away
7 with inline's and then the -O3/-O2 execution might fail.
9 public class stacktrace
{
10 public static void main(String args
[]) {
13 } catch (TopException e
) {
17 public void a() throws TopException
{
20 } catch (MiddleException e
) {
21 throw new TopException(e
);
25 public void b() throws MiddleException
{
29 public void c() throws MiddleException
{
32 } catch (BottomException e
) {
33 throw new MiddleException(e
);
37 public void d() throws BottomException
{
41 public void e() throws BottomException
{
42 throw new BottomException();
46 class TopException
extends Exception
{
47 TopException(Throwable cause
) {
52 class MiddleException
extends Exception
{
53 MiddleException(Throwable cause
) {
58 class BottomException
extends Exception
{
60 StackTraceElement stack
[] = this.getStackTrace();
61 for (int i
= 0; i
< stack
.length
; i
++) {
62 String className
= stack
[i
].getClassName();
63 String methodName
= stack
[i
].getMethodName();
64 System
.out
.println(className
+ "." + methodName
);