小编Aks*_*kar的帖子

java 10 compilaton Null Pointer Exception

我最近安装了jdk10.我正在做正常的代码,但它无法正常工作.

我在这里做错了吗?请参阅代码和异常堆栈跟踪.据我所知,这种行为应该没有理由.

import com.bean.College;

public class Student {

    interface Club {
        <T> T get(College<T> key);
    }

    private Club club;

    Student() {
        Object obj = club.get(new College<>() {});
    }
}
Run Code Online (Sandbox Code Playgroud)

导入的College类是:

public class College<T> {
    int id;
    protected College() {
    }

    College(int id){
        this.id=id;
    }
} 
Run Code Online (Sandbox Code Playgroud)

在编译时,javac编译器与以下堆栈跟踪崩溃:

java.lang.NullPointerException
        at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitApply(Flow.java:1233)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
        at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:396)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitVarDef(Flow.java:987)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:956)
        at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:396)
        at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitBlock(Flow.java:995)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
        at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:396)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitMethodDef(Flow.java:962)
        at …
Run Code Online (Sandbox Code Playgroud)

java compiler-errors javac java-9 java-10

17
推荐指数
1
解决办法
987
查看次数

标签 统计

compiler-errors ×1

java ×1

java-10 ×1

java-9 ×1

javac ×1