3

下面的代码不能在 Eclipse Luna 中使用 jdk 1.8.0_05 编译。Eclipse 编译器说:类型不匹配:无法从 Integer 转换为 long

它虽然在 Luna 中使用 jdk 1.7 进行编译,但在从命令行调用时也使用 jdk 1.8 进行编译。谁能帮我确定可能出了什么问题?日食JDK?

该代码适用于:http ://www.tryjava8.com/

public class TestJava8Issue {

    public static final int CORE_POOL_SIZE = Math.max(Runtime.getRuntime().availableProcessors() / 2, 2);
    public static final int KEEP_ALIVE_TIME = 60; // seconds

    TestJava8Issue(final int size, final long ttl){
        System.out.println("size: " + size + " " + " ttl: " + ttl);
    }

    public static void main(String[] args) {
        new TestJava8Issue(CORE_POOL_SIZE, get(KEEP_ALIVE_TIME));
    }

    public static <T> T get(T value) {
        return value;
    }
}

Eclipse Java 开发工具
版本:3.10.0.v20140501-0200
构建 ID:I20140501-0200

Java 版本“1.8.0_05”
Java(TM) SE 运行时环境(构建 1.8.0_05-b13)
Java HotSpot(TM) 64 位服务器 VM(构建 25.5-b02,混合模式)

4

0 回答 0