Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in JDTTreeBuilder.visit #574

Closed
worblehat opened this issue Apr 5, 2016 · 2 comments
Closed

NPE in JDTTreeBuilder.visit #574

worblehat opened this issue Apr 5, 2016 · 2 comments

Comments

@worblehat
Copy link

I get a NullPointerException when using spoon in no-classpath-mode to build a model of the following code:

public class Demo  {

    public foo() {
        A.B b = new A.B<C>() {
            D d = new D();
        };
    }
}
Exception in thread "main" java.lang.NullPointerException
    at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:2745)
    at org.eclipse.jdt.internal.compiler.ast.FieldDeclaration.traverse(FieldDeclaration.java:328)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1408)
    at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:3224)
    at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.traverse(QualifiedAllocationExpression.java:604)
    at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:2897)
    at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.traverse(LocalDeclaration.java:301)
    at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:3129)
    at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:327)
    at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:3855)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1319)
    at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:748)
    at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:709)
    at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildSources(JDTBasedSpoonCompiler.java:436)
    at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:124)
    at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:107)
@tdurieux
Copy link
Collaborator

tdurieux commented Apr 6, 2016

@GerardPaligot be careful the method foo() does not have a return type (this is not the origin of the NPE).

The easy solution is to add if (scope != null) { at JDTTreeBuilder.java:2745

@worblehat
Copy link
Author

the method foo() does not have a return type

Sorry, a typo.

monperrus pushed a commit to monperrus/spoon that referenced this issue Apr 18, 2016
monperrus pushed a commit to monperrus/spoon that referenced this issue Apr 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants