Java8 eclipse compiler error
I found a strange problem with java8:
In a class method, I have the following code:
int id;
...
new Key<Integer>(id)
To remove the "redundant type argument specification" as a key, I write:
new Key<>(id)
Then I get
java.lang.VerifyError: Bad type on operand stack
During runtime ... !!!! Reason: the compiler cannot replace int with an integer ...
Hope this helps guys like me who were completely disassembled by such a runtime when their program just went from java7 to java8 ....
Version: Luna Release (4.4.0) Build ID: 20140612-0600
Java version "1.8.0_25" Java (TM) SE Runtime Environment (Build 1.8.0_25-b17) Java HotSpot (TM) 64-bit Server VM (Build 25.25-b02, mixed mode)
ADDITION
Here's a complete simple example:
package bug;
public class Bug {
public static void main(String[] args) {
Bug.class.getConstructors();
System.out.println("test ok");
}
public Bug() {
BugCondition("", new Key<Integer>(1));
//BugCondition("", new Key<>(1));
}
public static final <C extends Object> void BugCondition(C test, Key<?> key) {
}
public class Key<K> {
public Key(K value) {
}
}
}
The problem seems to come from generics (replace C with String):
public static final <C extends Object> void BugCondition(C test, Key<?> key) {
}
source to share
Your example compiles fine with Eclipse Mars . I am using the following assembly:
Version: Mars Release Candidate 2 (4.5.0RC2)
Build id: 20150528-0540
I suspect this issue has been resolved in the meantime (like many other Eclipse / Java8 compilation issues)
source to share