-
Bug
-
Resolution: Fixed
-
P3
-
1.0
-
1.0beta2
-
x86
-
windows_nt
-
Not verified
The following code, using 13oct95.zip release of JDK beta for win32:
***
class tryfinally1_beta extends Throwable {
static boolean cond = false;
public static void main(String args[]) {
System.out.print("Test 'return' returns: " + test(1) + "\\n");
System.out.print("Test 'throw' returns: " + test(2) + "\\n");
System.out.print("Test 'break' returns: " + test(3) + "\\n");
System.out.print("Test 'continue' returns: " + test(4) + "\\n");
System.out.print("Test 'goto' returns: " + test(5) + "\\n");
}
public static int test(int how) {
int i;
stuff: {
try {
for (i = 0; i < 10; i++) {
try {
if (i == 5) {
switch (how) {
case 1:
return 0;
case 2:
try {
throw new Exception();
} catch (Exception e) {};
case 3:
break;
case 4:
continue;
case 5:
break stuff;
// goto out;
default:
System.out.print("Error - unknown test: " + how + "\\n");
}
}
} finally {
int a, b, c;
if (i == 5) {
System.out.print("Returning 11 from finally\\n");
return 11;
}
System.out.print("i = " + i + "\\n");
}
}
} finally {
System.out.print("Outermost finally called, and it returns 12!\\n")
;
return 12;
}
} // end stuff
out: return 13;
}
}
***
produces:
***
ERROR: sun.tools.java.CompilerError: stack depth error^M
-- listing --^M
16: try 16064208^M
17: iconst_0 0^M
17: istore 1^M
17: goto 16064384^M
$16064376:^M
18: try 16064488^M
19: iload 1^M
19: iconst_5 5^M
19: if_icmpne 16064488^M
20: iload 0^M
20: tableswitch sun/tools/asm/SwitchData[minValue=1, maxValue=5, defaultLabe
l=sun/tools/asm/Instruction.sun/tools/asm/Label, tab=java/util/Dictionary.java/u
til/Hashtable]^M
$16064688:^M
22: iconst_0 0^M
22: istore 4^M
22: jsr 16064528^M
22: jsr 16064272^M
22: iload 4^M
22: ireturn^M
$16064712:^M
25: try 16064952^M
26: new class java.lang.Exception^M
26: dup^M
26: invokenonvirtual java.lang.Exception()^M
26: athrow^M
$16064952:^M
$16064968:^M
27: pop^M
25: goto 16064488^M
$16064760:^M
33: jsr 16064528^M
33: goto 16064368^M
$16064784:^M
36: jsr 16064528^M
36: jsr 16064272^M
36: goto 16064144^M
$16064664:^M
40: getstatic java.io.PrintStream out^M
40: new class java.lang.StringBuffer^M
40: dup^M
40: invokenonvirtual java.lang.StringBuffer()^M
40: ldc "Error - unknown test: "^M
40: invokevirtual java.lang.StringBuffer append(java.lang.String)^M
40: iload 0^M
40: invokevirtual java.lang.StringBuffer append(int)^M
40: ldc "^M
"^M
40: invokevirtual java.lang.StringBuffer append(java.lang.String)^M
40: invokevirtual java.lang.String toString()^M
40: invokevirtual void print(java.lang.String)^M
$16064488:^M
18: jsr 16064528^M
18: goto 16064368^M
$16064504:^M
18: astore 2^M
18: jsr 16064528^M
18: aload 2^M
18: athrow^M
$16064528:^M
18: astore 3^M
46: iload 1^M
46: iconst_5 5^M
46: if_icmpne 16066768^M
47: getstatic java.io.PrintStream out^M
47: ldc "Returning 11 from finally^M
"^M
47: invokevirtual void print(java.lang.String)^M
48: bipush 11^M
48: istore 4^M
48: jsr 16064272^M
48: iload 4^M
48: ireturn^M
$16066768:^M
50: getstatic java.io.PrintStream out^M
50: new class java.lang.StringBuffer^M
50: dup^M
50: invokenonvirtual java.lang.StringBuffer()^M
50: ldc "i = "^M
50: invokevirtual java.lang.StringBuffer append(java.lang.String)^M
50: iload 1^M
50: invokevirtual java.lang.StringBuffer append(int)^M
50: ldc "^M
"nvokevirtual java.lang.StringBuffer append(java.lang.String)^M
40: iload 0^M
40: invokevirtual java.lang.StringBuffer append(int)^M
40: ldc "^M
"^M
40: invokevirtual java.lang.StringBuffer append(java.lang.String)^M
40: invokevirtual java.lang.String toString()^M
40: invokevirtual void print(java.lang.String)^M
$16064488:^M
18: jsr 16064528^M
18: goto 16064368^M
$16064504:^M
18: astore 2^M
18: jsr 16064528^M
18: aload 2^M
18: athrow^M
$16064528:^M
18: astore 3^M
46: iload 1^M
^M
50: invokevirtual java.lang.StringBuffer append(java.lang.String)^M
50: invokevirtual java.lang.String toString()^M
50: invokevirtual void print(java.lang.String)^M
18: ret 3^M
$16064368:^M
java.lang.ClassCastException java.lang.Object^M
at sun.tools.asm.Instruction.toString(Instruction.java:861)^M
at sun.tools.asm.Assembler.listing(Assembler.java:654)^M
at sun.tools.asm.Assembler.write(Assembler.java:326)^M
at sun.tools.javac.SourceClass.compileClass(SourceClass.java:668)^M
at sun.tools.javac.SourceClass.compile(SourceClass.java:500)^M
at sun.tools.javac.Main.compile(Main.java:195)^M
at sun.tools.javac.Main.main(Main.java:286)^M
error: An exception has occurred in the compiler; please file a bug report (java
###@###.###).^M
1 error^M
***
***
class tryfinally1_beta extends Throwable {
static boolean cond = false;
public static void main(String args[]) {
System.out.print("Test 'return' returns: " + test(1) + "\\n");
System.out.print("Test 'throw' returns: " + test(2) + "\\n");
System.out.print("Test 'break' returns: " + test(3) + "\\n");
System.out.print("Test 'continue' returns: " + test(4) + "\\n");
System.out.print("Test 'goto' returns: " + test(5) + "\\n");
}
public static int test(int how) {
int i;
stuff: {
try {
for (i = 0; i < 10; i++) {
try {
if (i == 5) {
switch (how) {
case 1:
return 0;
case 2:
try {
throw new Exception();
} catch (Exception e) {};
case 3:
break;
case 4:
continue;
case 5:
break stuff;
// goto out;
default:
System.out.print("Error - unknown test: " + how + "\\n");
}
}
} finally {
int a, b, c;
if (i == 5) {
System.out.print("Returning 11 from finally\\n");
return 11;
}
System.out.print("i = " + i + "\\n");
}
}
} finally {
System.out.print("Outermost finally called, and it returns 12!\\n")
;
return 12;
}
} // end stuff
out: return 13;
}
}
***
produces:
***
ERROR: sun.tools.java.CompilerError: stack depth error^M
-- listing --^M
16: try 16064208^M
17: iconst_0 0^M
17: istore 1^M
17: goto 16064384^M
$16064376:^M
18: try 16064488^M
19: iload 1^M
19: iconst_5 5^M
19: if_icmpne 16064488^M
20: iload 0^M
20: tableswitch sun/tools/asm/SwitchData[minValue=1, maxValue=5, defaultLabe
l=sun/tools/asm/Instruction.sun/tools/asm/Label, tab=java/util/Dictionary.java/u
til/Hashtable]^M
$16064688:^M
22: iconst_0 0^M
22: istore 4^M
22: jsr 16064528^M
22: jsr 16064272^M
22: iload 4^M
22: ireturn^M
$16064712:^M
25: try 16064952^M
26: new class java.lang.Exception^M
26: dup^M
26: invokenonvirtual java.lang.Exception()^M
26: athrow^M
$16064952:^M
$16064968:^M
27: pop^M
25: goto 16064488^M
$16064760:^M
33: jsr 16064528^M
33: goto 16064368^M
$16064784:^M
36: jsr 16064528^M
36: jsr 16064272^M
36: goto 16064144^M
$16064664:^M
40: getstatic java.io.PrintStream out^M
40: new class java.lang.StringBuffer^M
40: dup^M
40: invokenonvirtual java.lang.StringBuffer()^M
40: ldc "Error - unknown test: "^M
40: invokevirtual java.lang.StringBuffer append(java.lang.String)^M
40: iload 0^M
40: invokevirtual java.lang.StringBuffer append(int)^M
40: ldc "^M
"^M
40: invokevirtual java.lang.StringBuffer append(java.lang.String)^M
40: invokevirtual java.lang.String toString()^M
40: invokevirtual void print(java.lang.String)^M
$16064488:^M
18: jsr 16064528^M
18: goto 16064368^M
$16064504:^M
18: astore 2^M
18: jsr 16064528^M
18: aload 2^M
18: athrow^M
$16064528:^M
18: astore 3^M
46: iload 1^M
46: iconst_5 5^M
46: if_icmpne 16066768^M
47: getstatic java.io.PrintStream out^M
47: ldc "Returning 11 from finally^M
"^M
47: invokevirtual void print(java.lang.String)^M
48: bipush 11^M
48: istore 4^M
48: jsr 16064272^M
48: iload 4^M
48: ireturn^M
$16066768:^M
50: getstatic java.io.PrintStream out^M
50: new class java.lang.StringBuffer^M
50: dup^M
50: invokenonvirtual java.lang.StringBuffer()^M
50: ldc "i = "^M
50: invokevirtual java.lang.StringBuffer append(java.lang.String)^M
50: iload 1^M
50: invokevirtual java.lang.StringBuffer append(int)^M
50: ldc "^M
"nvokevirtual java.lang.StringBuffer append(java.lang.String)^M
40: iload 0^M
40: invokevirtual java.lang.StringBuffer append(int)^M
40: ldc "^M
"^M
40: invokevirtual java.lang.StringBuffer append(java.lang.String)^M
40: invokevirtual java.lang.String toString()^M
40: invokevirtual void print(java.lang.String)^M
$16064488:^M
18: jsr 16064528^M
18: goto 16064368^M
$16064504:^M
18: astore 2^M
18: jsr 16064528^M
18: aload 2^M
18: athrow^M
$16064528:^M
18: astore 3^M
46: iload 1^M
^M
50: invokevirtual java.lang.StringBuffer append(java.lang.String)^M
50: invokevirtual java.lang.String toString()^M
50: invokevirtual void print(java.lang.String)^M
18: ret 3^M
$16064368:^M
java.lang.ClassCastException java.lang.Object^M
at sun.tools.asm.Instruction.toString(Instruction.java:861)^M
at sun.tools.asm.Assembler.listing(Assembler.java:654)^M
at sun.tools.asm.Assembler.write(Assembler.java:326)^M
at sun.tools.javac.SourceClass.compileClass(SourceClass.java:668)^M
at sun.tools.javac.SourceClass.compile(SourceClass.java:500)^M
at sun.tools.javac.Main.compile(Main.java:195)^M
at sun.tools.javac.Main.main(Main.java:286)^M
error: An exception has occurred in the compiler; please file a bug report (java
###@###.###).^M
1 error^M
***