-
Bug
-
Resolution: Duplicate
-
P3
-
8
FULL PRODUCT VERSION :
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)Q
ADDITIONAL OS VERSION INFORMATION :
3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
fails on different hardware/os setups
A DESCRIPTION OF THE PROBLEM :
code compiles but class does not load
REGRESSION. Last worked in version 7u76
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile provided code and attempt to run
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
it should load and run
ACTUAL -
class fails to load
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.VerifyError: Bad local variable type
Exception Details:
Location:
TernaryOperatorCompileErr.main([Ljava/lang/String;)V @25: aload_2
Reason:
Type top (current frame, locals[2]) is not assignable to reference type
Current Frame:
bci: @25
flags: { }
locals: { '[Ljava/lang/String;', integer }
stack: { 'java/io/PrintStream', 'java/lang/StringBuilder' }
Bytecode:
0x0000000: bb00 0259 b700 03b6 0004 3cb2 0005 bb00
0x0000010: 0659 b700 071b 9900 072c a700 042d b600
0x0000020: 08b6 0009 b600 0ab1
Stackmap Table:
full_frame(@29,{Object[#20],Integer},{Object[#21],Object[#22]})
full_frame(@30,{Object[#20],Integer},{Object[#21],Object[#22],Object[#23]})
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.Random;
public class TernaryOperatorCompileErr {
public static void main(String[] args) {
boolean b = new Random().nextBoolean();
final String a1 = "a";
final String a2 = "b";
System.out.println(new StringBuilder().append(b ? a1 : a2).toString());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
refrain from using 'final' on local variables used with ternary operators
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)Q
ADDITIONAL OS VERSION INFORMATION :
3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
fails on different hardware/os setups
A DESCRIPTION OF THE PROBLEM :
code compiles but class does not load
REGRESSION. Last worked in version 7u76
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile provided code and attempt to run
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
it should load and run
ACTUAL -
class fails to load
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.VerifyError: Bad local variable type
Exception Details:
Location:
TernaryOperatorCompileErr.main([Ljava/lang/String;)V @25: aload_2
Reason:
Type top (current frame, locals[2]) is not assignable to reference type
Current Frame:
bci: @25
flags: { }
locals: { '[Ljava/lang/String;', integer }
stack: { 'java/io/PrintStream', 'java/lang/StringBuilder' }
Bytecode:
0x0000000: bb00 0259 b700 03b6 0004 3cb2 0005 bb00
0x0000010: 0659 b700 071b 9900 072c a700 042d b600
0x0000020: 08b6 0009 b600 0ab1
Stackmap Table:
full_frame(@29,{Object[#20],Integer},{Object[#21],Object[#22]})
full_frame(@30,{Object[#20],Integer},{Object[#21],Object[#22],Object[#23]})
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.Random;
public class TernaryOperatorCompileErr {
public static void main(String[] args) {
boolean b = new Random().nextBoolean();
final String a1 = "a";
final String a2 = "b";
System.out.println(new StringBuilder().append(b ? a1 : a2).toString());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
refrain from using 'final' on local variables used with ternary operators