sourcegraph / scip-java

SCIP Code Intelligence Protocol generator for Java
https://sourcegraph.github.io/scip-java/
Apache License 2.0
67 stars 28 forks source link

Using metals, getting NPE at buildtime #419

Open lucasdellabella opened 2 years ago

lucasdellabella commented 2 years ago

I'm not sure what other context to provide, I am just getting the below, along with Please report a bug to https://github.com/sourcegraph/semanticdb-java with the stack trace above. and the link to the semanticdb repo isbroken. I'm not sure the significance of the file in our codebase.

com.sourcegraph.semanticdb_javac.CompilationUnitException: …myFile.java
Caused by: java.lang.NullPointerException
    at com.sourcegraph.semanticdb_javac.Semanticdb$TypeSignature$Builder.setUpperBound(Semanticdb.java:9271)
    at com.sourcegraph.semanticdb_javac.SemanticdbTypeVisitor.visitDeclared(SemanticdbTypeVisitor.java:49)
    at com.sourcegraph.semanticdb_javac.SemanticdbTypeVisitor.visitDeclared(SemanticdbTypeVisitor.java:13)
    at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:944)
    at javax.lang.model.util.AbstractTypeVisitor6.visit(AbstractTypeVisitor6.java:105)
    at com.sourcegraph.semanticdb_javac.SemanticdbTypeVisitor.semanticdbType(SemanticdbTypeVisitor.java:27)
    at com.sourcegraph.semanticdb_javac.SemanticdbSignatures.generateType(SemanticdbSignatures.java:110)
    at com.sourcegraph.semanticdb_javac.SemanticdbSignatures.generateFieldSignature(SemanticdbSignatures.java:82)
    at com.sourcegraph.semanticdb_javac.SemanticdbSignatures.generateSignature(SemanticdbSignatures.java:30)
    at com.sourcegraph.semanticdb_javac.SemanticdbVisitor.semanticdbSignature(SemanticdbVisitor.java:263)
    at com.sourcegraph.semanticdb_javac.SemanticdbVisitor.emitSymbolInformation(SemanticdbVisitor.java:96)
    at com.sourcegraph.semanticdb_javac.SemanticdbVisitor.emitSymbolOccurrence(SemanticdbVisitor.java:88)
    at com.sourcegraph.semanticdb_javac.SemanticdbVisitor.visitVariable(SemanticdbVisitor.java:204)
    at com.sourcegraph.semanticdb_javac.SemanticdbVisitor.visitVariable(SemanticdbVisitor.java:30)
    at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:864)
    at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:68)
    at com.sun.source.util.TreeScanner.scan(TreeScanner.java:91)
    at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:99)
    at com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:141)
    at com.sourcegraph.semanticdb_javac.SemanticdbVisitor.visitMethod(SemanticdbVisitor.java:197)
    at com.sourcegraph.semanticdb_javac.SemanticdbVisitor.visitMethod(SemanticdbVisitor.java:30)
    at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:800)
    at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:68)
    at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:81)
    at com.sun.source.util.TreeScanner.scan(TreeScanner.java:91)
    at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:99)
    at com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:133)
    at com.sourcegraph.semanticdb_javac.SemanticdbVisitor.visitClass(SemanticdbVisitor.java:171)
    at com.sourcegraph.semanticdb_javac.SemanticdbVisitor.visitClass(SemanticdbVisitor.java:30)
    at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:720)
    at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:68)
    at com.sun.source.util.TreeScanner.scan(TreeScanner.java:91)
    at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:99)
    at com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:120)
    at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:550)
    at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:68)
    at com.sourcegraph.semanticdb_javac.SemanticdbVisitor.buildTextDocument(SemanticdbVisitor.java:68)
    at com.sourcegraph.semanticdb_javac.SemanticdbTaskListener.onFinishedAnalyze(SemanticdbTaskListener.java:66)
    at com.sourcegraph.semanticdb_javac.SemanticdbTaskListener.finished(SemanticdbTaskListener.java:46)
    at com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:681)
    at com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:111)
    at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1342)
    at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1296)
    at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
    at com.sun.tools.javac.main.Main.compile(Main.java:523)
    at com.sun.tools.javac.main.Main.compile(Main.java:381)
    at com.sun.tools.javac.main.Main.compile(Main.java:370)
    at com.sun.tools.javac.main.Main.compile(Main.java:361)
    at com.sun.tools.javac.Main.compile(Main.java:56)
    at com.sun.tools.javac.Main.main(Main.java:42)
Strum355 commented 2 years ago

Thanks for the report!

and the link to the semanticdb repo is broken.

Good catch on that, will fix that 🙂

I'm not sure the significance of the file in our codebase.

If the file isnt private, it could be greatly beneficial to see it (or the project as a whole would be even better), else if youre able to narrow down a snippet of the file that is tripping it up, that might be enough too.

To further narrow down where the issue is occurring, could you run the lsif-java standalone cli tool (it supports mixed Scala/Java/Kotlin projects) and see if the issue occurs then too. I dont know the specifics on how semanticdb-javac is integrated into metals (maybe @tgodzik is aware of any shortcomings), so I want to rule out it being a metals integration issue or whether its solely due to semanticdb-javac

tgodzik commented 2 years ago

To further narrow down where the issue is occurring, could you run the lsif-java standalone cli tool (it supports mixed Scala/Java/Kotlin projects) and see if the issue occurs then too. I dont know the specifics on how semanticdb-javac is integrated into metals (maybe @tgodzik is aware of any shortcomings), so I want to rule out it being a metals integration issue or whether its solely due to semanticdb-javac

It shouldn't be an issue with the integration, but I think it's good to check that out first.