Git Product home page Git Product logo

Comments (3)

tsachev avatar tsachev commented on May 7, 2024 1

any chance to have support for pacakge-info.java?

from compile-testing.

tsachev avatar tsachev commented on May 7, 2024

I found a bug in my annotation processor I was using

processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT, pkg, fileName)

instead of

processingEnv.getFiler().createSourceFile(pkg + "." + fileName.substring(0, fileName.length()- ".java".length()))

Now I get

java.lang.RuntimeException: java.lang.IllegalArgumentException: Not supported: InMemoryJavaFileObject{uri=mem:///SOURCE_OUTPUT/com/example/test/definition/package-info.java, kind=SOURCE}

    at com.sun.tools.javac.main.Main.compile(Main.java:559)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
    at com.google.testing.compile.Compilation.compile(Compilation.java:77)
    at com.google.testing.compile.JavaSourcesSubject$CompilationClause.compilesWithoutError(JavaSourcesSubject.java:283)
    at com.nemesis.platform.core.mixin.processor.MixInAnnotationProcessorTest.test(MixInAnnotationProcessorTest.java:21)
    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)
Caused by: java.lang.IllegalArgumentException: Not supported: InMemoryJavaFileObject{uri=mem:///SOURCE_OUTPUT/com/example/test/definition/package-info.java, kind=SOURCE}
    at com.sun.tools.javac.file.JavacFileManager.isSameFile(JavacFileManager.java:647)
    at javax.tools.ForwardingJavaFileManager.isSameFile(ForwardingJavaFileManager.java:90)
    at com.google.testing.compile.InMemoryJavaFileManager.isSameFile(InMemoryJavaFileManager.java:88)
    at com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager.isSameFile(ClientCodeWrapper.java:257)
    at com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:310)
    at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:518)
    at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)
    at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)
    at com.sun.tools.javac.comp.Enter.complete(Enter.java:486)
    at com.sun.tools.javac.comp.Enter.main(Enter.java:471)
    at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.enterTrees(JavacProcessingEnvironment.java:1015)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.<init>(JavacProcessingEnvironment.java:902)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.next(JavacProcessingEnvironment.java:921)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1187)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
    at com.sun.tools.javac.main.Main.compile(Main.java:523)
    ... 31 more

from compile-testing.

netdpb avatar netdpb commented on May 7, 2024

I have a fix for this code path. But the modern API should work for this use case without NPE:

Compilation compilation = javac().withProcessors(…).compile(sources…);
assertThat(compilation)
    .generatedSourceFile("expected.package-info")
    .hasSourceEquivalentTo(JavaFileObjects.forResource(…));

from compile-testing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.