Comments (3)
any chance to have support for pacakge-info.java
?
from compile-testing.
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.
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)
- Annotation processor's Filer can't read the files being compiled HOT 9
- Android/AGP 3.6.2 breaks JavaFileObjects.forResource HOT 4
- “NoSuchMethodErrors” due to multiple versions of com.google.guava:guava:jar HOT 3
- Fix incompatibility vs. Truth HOT 2
- [feature request] support assert generate multi source file. HOT 1
- If there are invalid class in the source file, the process method of processor will not be invoked. HOT 2
- Javac plugins cannot be found HOT 5
- Access to compiler internal APIs will fail starting with JDK 16 HOT 7
- Test classpath isolation HOT 1
- how to pass libraries through javac -cp in a text file for example HOT 1
- We probably don't handle recent Java features HOT 1
- No release since Oct, 2020 HOT 3
- Compile with Lombok Annotations HOT 8
- [BUG] InMemoryJavaFileManager.uriForJavaFileObject() breaks when supplied with a Locations.ModuleLocationHandler HOT 4
- Release 0.20? HOT 2
- Request: Automatically configure compiler to reflect the test module's pom file (or build.gradle) HOT 2
- Incompatibility with the last version of truth HOT 1
- Output information about why an assertion failed HOT 9
- test annotation processors generate source code is correct ,but report error: cannot find symbol HOT 2
- JDK16+ --add-exports not working as expected HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compile-testing.