FULL PRODUCT VERSION :
ADDITIONAL OS VERSION INFORMATION :
Sun JDK 1.6.0_24 on Mac
Sun JDK 1.6.0_20 on Windows [6.1.7600]
A DESCRIPTION OF THE PROBLEM :
When compiling the class file shown in link 2 there is an exception thrown
Links:
http://stackoverflow.com/q/5662090/29924
http://stackoverflow.com/questions/5662090/nesting-five-conditional-operators/5664277#5664277
Stack Trace:
An exception has occurred in the compiler (1.6.0_24). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError
at com.sun.tools.javac.jvm.Code$State.forceStackTop(Code.java:1688)
at com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1679)
at com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1021)
at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:818)
at com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1678)
at com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1021)
at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:818)
at com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1678)
at com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1021)
at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:818)
at com.sun.tools.javac.jvm.Gen.visitReturn(Gen.java:1626)
at com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1138)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:700)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:686)
at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:737)
at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1013)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:739)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:700)
at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:893)
at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:866)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:639)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2198)
at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:617)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1289)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1259)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:765)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:730)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:279)
at com.sun.tools.javac.main.Main.compile(Main.java:270)
at com.sun.tools.javac.Main.compile(Main.java:69)
at com.sun.tools.javac.Main.main(Main.java:54)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile class file at http://stackoverflow.com/questions/5662090/nesting-five-conditional-operators/5664277#5664277
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Class should compile
ACTUAL -
AssertionError thrown
ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.6.0_24). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError
at com.sun.tools.javac.jvm.Code$State.forceStackTop(Code.java:1688)
at com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1679)
at com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1021)
at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:818)
at com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1678)
at com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1021)
at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:818)
at com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1678)
at com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1021)
at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:818)
at com.sun.tools.javac.jvm.Gen.visitReturn(Gen.java:1626)
at com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1138)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:700)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:686)
at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:737)
at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1013)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:739)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:700)
at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:893)
at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:866)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:639)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2198)
at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:617)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1289)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1259)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:765)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:730)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:279)
at com.sun.tools.javac.main.Main.compile(Main.java:270)
at com.sun.tools.javac.Main.compile(Main.java:69)
at com.sun.tools.javac.Main.main(Main.java:54)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.ArrayList;
import java.util.Date;
public class Test3 {
private Number number;
private String string;
private Boolean bool; // Replace Boolean with Object, and it compiles!
private Date date;
private ArrayList<String> list; // Replace ArrayList with List, and it
// compiles!
public Object getValue() {
return number != null ? number :
string != null ? string :
bool != null ? bool :
date != null ? date :
list != null ? list : // Comment This Line
null;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
See comments in above code, changing the types of the field or commenting out "Comment This Line" allows the class to compile
ADDITIONAL OS VERSION INFORMATION :
Sun JDK 1.6.0_24 on Mac
Sun JDK 1.6.0_20 on Windows [6.1.7600]
A DESCRIPTION OF THE PROBLEM :
When compiling the class file shown in link 2 there is an exception thrown
Links:
http://stackoverflow.com/q/5662090/29924
http://stackoverflow.com/questions/5662090/nesting-five-conditional-operators/5664277#5664277
Stack Trace:
An exception has occurred in the compiler (1.6.0_24). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError
at com.sun.tools.javac.jvm.Code$State.forceStackTop(Code.java:1688)
at com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1679)
at com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1021)
at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:818)
at com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1678)
at com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1021)
at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:818)
at com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1678)
at com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1021)
at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:818)
at com.sun.tools.javac.jvm.Gen.visitReturn(Gen.java:1626)
at com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1138)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:700)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:686)
at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:737)
at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1013)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:739)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:700)
at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:893)
at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:866)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:639)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2198)
at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:617)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1289)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1259)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:765)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:730)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:279)
at com.sun.tools.javac.main.Main.compile(Main.java:270)
at com.sun.tools.javac.Main.compile(Main.java:69)
at com.sun.tools.javac.Main.main(Main.java:54)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile class file at http://stackoverflow.com/questions/5662090/nesting-five-conditional-operators/5664277#5664277
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Class should compile
ACTUAL -
AssertionError thrown
ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.6.0_24). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError
at com.sun.tools.javac.jvm.Code$State.forceStackTop(Code.java:1688)
at com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1679)
at com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1021)
at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:818)
at com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1678)
at com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1021)
at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:818)
at com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1678)
at com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1021)
at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:818)
at com.sun.tools.javac.jvm.Gen.visitReturn(Gen.java:1626)
at com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1138)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:700)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:686)
at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:737)
at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1013)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:739)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:700)
at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:893)
at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:866)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:639)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2198)
at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:617)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1289)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1259)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:765)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:730)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:279)
at com.sun.tools.javac.main.Main.compile(Main.java:270)
at com.sun.tools.javac.Main.compile(Main.java:69)
at com.sun.tools.javac.Main.main(Main.java:54)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.ArrayList;
import java.util.Date;
public class Test3 {
private Number number;
private String string;
private Boolean bool; // Replace Boolean with Object, and it compiles!
private Date date;
private ArrayList<String> list; // Replace ArrayList with List, and it
// compiles!
public Object getValue() {
return number != null ? number :
string != null ? string :
bool != null ? bool :
date != null ? date :
list != null ? list : // Comment This Line
null;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
See comments in above code, changing the types of the field or commenting out "Comment This Line" allows the class to compile
- duplicates
-
JDK-6500343 compiler generates bad code when translating conditional expressions
-
- Closed
-