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 noclasspath #406

Closed
monperrus opened this issue Nov 13, 2015 · 5 comments
Closed

NPE in noclasspath #406

monperrus opened this issue Nov 13, 2015 · 5 comments

Comments

@monperrus
Copy link
Collaborator

spoon4.3 -x -i IndexWriter.java (attached
IndexWriter.java.txt
)

results in

java.lang.NullPointerException
    at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:2255)
    at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse(MessageSend.java:1008)
    at spoon.support.compiler.jdt.JDTTreeBuilder.buildCommonPartForCtNewClassAndCtConstructorCall(JDTTreeBuilder.java:1636)
    at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:2474)
    at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.traverse(QualifiedAllocationExpression.java:587)
    at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:2274)
    at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse(MessageSend.java:1008)
    at org.eclipse.jdt.internal.compiler.ast.Block.traverse(Block.java:136)
    at org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement.traverse(SynchronizedStatement.java:212)
    at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:1937)
    at org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration.traverse(ConstructorDeclaration.java:577)
    at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:3024)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1338)
    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:247)
    at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:500)
    at fr.inria.sacha.spoon.diffSpoon.DiffSpoon.getCtClass(DiffSpoon.java:108)
    at fr.inria.sacha.spoon.diffSpoon.DiffSpoon.compare(DiffSpoon.java:148)
    at fr.inria.sacha.spoon.diffSpoon.DiffSpoonTest.test_t_224771(DiffSpoonTest.java:706)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)


@GerardPaligot
Copy link
Contributor

This bug is already fixed in the version 4.4.0 but there is another bug with anonymous class in noclasspath.

This is the anonymous class:

new Lock.With(directory.makeLock("commit.lock")) {
    public Object doBody() throws IOException {
        if (create)
            segmentInfos.write(directory);
        else
            segmentInfos.read(directory);
        return null;
    }
}.run();

This is the stacktrace:

java.lang.NullPointerException
    at spoon.support.compiler.jdt.JDTTreeBuilder.createType(JDTTreeBuilder.java:973)
    at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:3004)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1374)
    at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:2542)
    at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.traverse(QualifiedAllocationExpression.java:604)
    at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:2341)
    at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse(MessageSend.java:1031)
    at org.eclipse.jdt.internal.compiler.ast.Block.traverse(Block.java:139)
    at org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement.traverse(SynchronizedStatement.java:212)
    at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:1989)
    at org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration.traverse(ConstructorDeclaration.java:605)
    at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:3085)
    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:227)
    at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:480)
    at spoon.Launcher.buildModel(Launcher.java:664)
    at spoon.Launcher.run(Launcher.java:616)
    at spoon.test.invocations.InvocationTest.testInvocation(InvocationTest.java:69)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

@GerardPaligot
Copy link
Contributor

We have a problem here. In noclasspath, JDT returns 0 information about the class which covers the anonymous class.

@monperrus
Copy link
Collaborator Author

can we simply work around the exception and having at least an
incomplete model?

@GerardPaligot
Copy link
Contributor

We can create a CtClass without data inside.

@monperrus
Copy link
Collaborator Author

OK for me.

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