Skip to content

NPE when generated source is package-info.java #85

@tsachev

Description

@tsachev

My annotation processor generates package-info.java source files.
But when I call generatesSources() NPE is thrown?

java.lang.NullPointerException
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:213)
    at com.google.common.collect.FluentIterable.<init>(FluentIterable.java:82)
    at com.google.common.collect.FluentIterable$1.<init>(FluentIterable.java:91)
    at com.google.common.collect.FluentIterable.from(FluentIterable.java:90)
    at com.google.testing.compile.TypeEnumerator$TypeScanner.visitCompilationUnit(TypeEnumerator.java:103)
    at com.google.testing.compile.TypeEnumerator$TypeScanner.visitCompilationUnit(TypeEnumerator.java:55)
    at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:550)
    at com.sun.source.util.TreeScanner.scan(TreeScanner.java:77)
    at com.google.testing.compile.TypeEnumerator$TypeScanner.scan(TypeEnumerator.java:59)
    at com.google.testing.compile.TypeEnumerator.getTopLevelTypes(TypeEnumerator.java:49)
    at com.google.testing.compile.JavaSourcesSubject$CompilationClause$1.apply(JavaSourcesSubject.java:178)
    at com.google.testing.compile.JavaSourcesSubject$CompilationClause$1.apply(JavaSourcesSubject.java:176)
    at com.google.common.collect.Maps.toMap(Maps.java:1119)
    at com.google.common.collect.Maps.toMap(Maps.java:1097)
    at com.google.testing.compile.JavaSourcesSubject$CompilationClause.parsesAs(JavaSourcesSubject.java:183)
    at com.google.testing.compile.JavaSourcesSubject.parsesAs(JavaSourcesSubject.java:93)
    at com.google.testing.compile.JavaSourcesSubject$SuccessfulCompilationBuilder.generatesSources(JavaSourcesSubject.java:482)
    at com.nemesis.platform.core.mixin.processor.MixInAnnotationProcessorTest.test(MixInAnnotationProcessorTest.java:22)
    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:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    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:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

assertAbout(javaSources())
                        .that(ImmutableList.of(JavaFileObjects.forResource(Resources.getResource("definition/package-info.java"))))
                        .processedWith(new MixInAnnotationProcessor())
                        .compilesWithoutError().and()
                        .generatesSources(JavaFileObjects.forResource(Resources.getResource("entity/package-info.java")));

Metadata

Metadata

Assignees

Labels

P3type=defectBug, not working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions