I recently upgraded my project to Java 1.8 from version 1.7.
I get an exception for an inconsistent stack combination for a method in one of my classes.
Initializing some unrecognized local variables in a permitted method, but can someone explain why using unread variables throws an exception in Java 8, thanks.
Perhaps this will be with the version of eclipse (Kepler SR 2 20140224-0627) that I am using is just curious.
POSSIBLE SOLUTION
previously used the arguments "--xxSplitVerifier" (in version 1.7) or the "-NVerify" Jvm before fixing the faulty code.
if the compiler options in the eclipse workspace are not marked with the option "save unused local variables", it is compiled using java 8
Method :
It is impossible to publish the full method as its very large and restrained code of the company I work with.
public synchronized int setData()
{
int id= 0;
StringBuffer sb;
String name;
if (true) {
sb = new StringBuffer();
} else {
sb = new StringBuffer();
}
stackFrame:
Called: java.lang.VerifyError: inconsistent freeze frames on target branch 2079
Exception Details: Location: someClass.setData (someClass / Data) i @ 2079: iload_3
Reason: Type top (current frame, locals [4]) is not assigned to 'java / lang / StringBuffer' (stack map, locals [4])
: bci: @98 flags: {} locals: {'someClass/setData', 'someClass/Data', 'someClass/Data', integer, top, top} stack: {'someClass/Data'}
: bci: @2079 flags: {} locals: {'someClass/setData', 'someClass/Data', 'someClass/Data', integer, 'java/lang/StringBuffer', 'java/lang/String'} stack: {} Bytecode: 0x0000000: 2bb6 032b 4d03 3e06 bd01 3e59 0313 032f 0x0000010: 5359 0413 0331 5359 0513 0333 533a 0606