The following code will cause a compiler error:
%> javac t.java
ERROR: sun.tools.java.CompilerError: stack under flow: 11: putfield boolean publicFlag = -1
-- listing --
$6:
11: aload 0
11: getfield t this$0
11: aload 0
11: getfield t this$0
11: iconst_1 1
11: invokestatic void access$1(t, boolean)
11: putfield boolean publicFlag
10: return
sun.tools.java.CompilerError: stack under flow: 11: putfield boolean publicFlag = -1
at sun.tools.asm.Assembler.balance(Assembler.java:246)
at sun.tools.asm.Assembler.write(Assembler.java:378)
at sun.tools.javac.SourceClass.compileClass(SourceClass.java:1969)
at sun.tools.javac.SourceClass.compile(SourceClass.java:1690)
at sun.tools.javac.Main.compile(Main.java:408)
at sun.tools.javac.Main.main(Main.java:571)
error: An error has occurred in the compiler; please file a bug report (http://java.sun.com/cgi-bin/bugreport.cgi).
1 error
//code for t.java:
public class t {
public boolean publicFlag;
private boolean privateFlag;
public t() {
publicFlag = privateFlag = true;
}
class inner {
public void innerMethod() {
publicFlag = privateFlag = true;
}
}
}
Note that it is not a problem if privateFlag is declared 'public'.
Note that it is still a problem if publicFlag is declared 'private'.
I have verified this both on Solaris using 1.2beta3-N and 1.1.6N.
dale.mcduffie@Eng 1998-04-23
%> javac t.java
ERROR: sun.tools.java.CompilerError: stack under flow: 11: putfield boolean publicFlag = -1
-- listing --
$6:
11: aload 0
11: getfield t this$0
11: aload 0
11: getfield t this$0
11: iconst_1 1
11: invokestatic void access$1(t, boolean)
11: putfield boolean publicFlag
10: return
sun.tools.java.CompilerError: stack under flow: 11: putfield boolean publicFlag = -1
at sun.tools.asm.Assembler.balance(Assembler.java:246)
at sun.tools.asm.Assembler.write(Assembler.java:378)
at sun.tools.javac.SourceClass.compileClass(SourceClass.java:1969)
at sun.tools.javac.SourceClass.compile(SourceClass.java:1690)
at sun.tools.javac.Main.compile(Main.java:408)
at sun.tools.javac.Main.main(Main.java:571)
error: An error has occurred in the compiler; please file a bug report (http://java.sun.com/cgi-bin/bugreport.cgi).
1 error
//code for t.java:
public class t {
public boolean publicFlag;
private boolean privateFlag;
public t() {
publicFlag = privateFlag = true;
}
class inner {
public void innerMethod() {
publicFlag = privateFlag = true;
}
}
}
Note that it is not a problem if privateFlag is declared 'public'.
Note that it is still a problem if publicFlag is declared 'private'.
I have verified this both on Solaris using 1.2beta3-N and 1.1.6N.
dale.mcduffie@Eng 1998-04-23
- duplicates
-
JDK-4098316 Stack underflow on inner class chained assignments
-
- Closed
-