FULL PRODUCT VERSION :
# java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
# javac -version
javac 1.8.0_31
ADDITIONAL OS VERSION INFORMATION :
Linux sit1v085-2 3.13.0-39-generic #66-Ubuntu SMP Tue Oct 28 13:30:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Class does not compile
REGRESSION. Last worked in version 7u76
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile with:
javac -g:vars <className>
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
class to compile
ACTUAL -
does not compile on JDK 8. Tested on u25 and u31.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.8.0_31). 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.util.Assert.error(Assert.java:126)
at com.sun.tools.javac.util.Assert.check(Assert.java:45)
at com.sun.tools.javac.jvm.ClassWriter.writeCode(ClassWriter.java:1189)
at com.sun.tools.javac.jvm.ClassWriter.writeMethod(ClassWriter.java:1110)
at com.sun.tools.javac.jvm.ClassWriter.writeMethods(ClassWriter.java:1602)
at com.sun.tools.javac.jvm.ClassWriter.writeClassFile(ClassWriter.java:1692)
at com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:1620)
at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:746)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1572)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1536)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.main.Main.compile(Main.java:381)
at com.sun.tools.javac.main.Main.compile(Main.java:370)
at com.sun.tools.javac.main.Main.compile(Main.java:361)
at com.sun.tools.javac.Main.compile(Main.java:56)
at com.sun.tools.javac.Main.main(Main.java:42)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class FooBar {
// run: javac -g:vars FooBar.java
public static void COMPILER_GOES_BOOM() {
{ // need to have a block here.
//int before = 0; // assigning values here and it compiles fine,
int i;
int j;
if (Boolean.valueOf("true")) {
i = 1;
System.out.println(i);
}
if (Boolean.valueOf("true")) {
j = 2;
System.out.println(j);
}
// int after; // comment in and it compiles fine.
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
change the code so the variable scope changes