A DESCRIPTION OF THE PROBLEM :
For a variable "a" of type Integer, if a is referenced in the first operand of the ternary conditional operator ? : and is used with a postfix operator in the third operand of the ternary conditional operator ? :, the compiler throws an AssertionError.
REGRESSION : Last worked in version 11.0.2
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Save the code entered below in the "Source code for an executable test case" box in a file named CompilerTest.java.
2. Run "javac CompilerTest.java".
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The compiler produces a file named "CompilerTest.class".
ACTUAL -
The compiler produced the following output.
An exception has occurred in the compiler (12.0.1). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError
at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitVarDef(Gen.java:1053)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:962)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:616)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:667)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitLetExpr(Gen.java:2300)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$LetExpr.accept(JCTree.java:3026)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:853)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitSelect(Gen.java:2241)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2189)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:853)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitApply(Gen.java:1803)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1709)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:853)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1835)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1452)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:853)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genArgs(Gen.java:872)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitApply(Gen.java:1808)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1709)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:853)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitVarDef(Gen.java:1051)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:962)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:616)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:667)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1067)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:937)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:900)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:872)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2345)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:756)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1635)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1603)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
---------- BEGIN SOURCE ----------
public class CompilerTest {
public static void main(String[] args) {
Integer a = Integer.valueOf(1);
Integer b = a == null ? 1 : a++;
}
}
---------- END SOURCE ----------
FREQUENCY : always