Java8 eclipse编译器bug

时间:2014-11-07 20:58:12

标签: java-8

我发现了java8的一个奇怪问题:

在类方法中,我有以下代码:

int id;
...
new Key<Integer>(id)

要删除“类型参数的冗余规范”作为密钥,我写道:

new Key<>(id)

然后我得到了

java.lang.VerifyError: Bad type on operand stack

执行时... !!!!原因是:编译器省略用整数替换int ...

希望这会帮助像我这样的人,他们的程序只是从java7传递到java8,完全被这种运行时执行所忽视....

版本:Luna Release(4.4.0) 构建ID:20140612-0600

Java版“1.8.0_25” Java(TM)SE运行时环境(版本1.8.0_25-b17) Java HotSpot(TM)64位服务器VM(内置25.25-b02,混合模式)

ADDED

这是一个完整的简单示例:

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) {
        }
    }
}

似乎问题来自泛型(用字符串替换C):

public static final <C extends Object> void BugCondition(C test, Key<?> key) {
}

1 个答案:

答案 0 :(得分:0)

您的示例与Eclipse Mars完全匹配。我使用以下版本:

Version: Mars Release Candidate 2 (4.5.0RC2)
Build id: 20150528-0540

我怀疑此问题已在此期间得到解决(与许多其他Eclipse / Java8编译问题一样)