java中注释的嵌套_java-如何从注释处理器中的嵌套注释中读
取...
我试图使⽤Java注释处理⼯具⽣成⼀些代码,我具有嵌套的注释,其中⽗注释值是⼦注释的数组,⽽⼦注释值是类的数组.
注释:
public @interface ParentAnnotation {
ChildAnnotation[] value();
}
public @interface ChildAnnotation {
Class>[] value();
}
⽤法:
session如何设置和读取@ParentAnnotation(
{
@ChildAnnotation({Foo.class, Bar.class}),
@ChildAnnotation({Goo.class, Doo.class})
})
public class Sample{
}
在带有我的Processor⼦类型的注释上调⽤value()失败,发⽣以下异常:
Error:java: error while creating source file pe.MirroredTypeException: Attempt to access Class object for TypeMirror org.dominokit.samples.sion.LayoutEvent
at
del.ateException(AnnotationProxyMaker.java:308
flect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:84)
at com.sun.proxy.$Proxy28.value(Unknown Source)
at
org.dominokit.domino.apt.dule.client.ateFireActivationEvent(Pres
at
org.dominokit.domino.apt.dule.client.presenters.PresenterProxySourceWriter.asTypeBuilder(PresenterProxySo
at
org.dominokit.domino.apt.dule.client.ateProxy(PresenterProxy
at
org.dominokit.domino.apt.dule.client.presenters.PresenterProxyProcessingStep.process(PresenterProxyProces
at
org.dominokit.domino.apt.dule.client.presenters.PresenterProxyProcessor.process(PresenterProxyProcessor.ja
at ls.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at
ls.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at ls.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at ls.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at ls.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at ls.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at ls.javac.main.JavaCompilerpile(JavaCompiler.java:856)
at ls.javac.main.Mainpile(Main.java:523)
at ls.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
at ls.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
at org.jetbrains.jps.javac.JavacMainpile(JavacMain.java:196)
at org.jetbrains.jps.incremental.java.JavaBuilderpileJava(JavaBuilder.java:448)
at org.jetbrains.jps.incremental.java.JavaBuilderpile(JavaBuilder.java:318)
at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:243)
at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:201)
at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1327)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1007)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1074)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:968)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:797)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:375)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:178)
at org.dline.BuildRunner.runBuild(BuildRunner.java:138)
at org.dline.BuildSession.runBuild(BuildSession.java:302)
at org.dline.BuildSession.run(BuildSession.java:135)
at org.dline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:229)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)
at urrent.Executors$RunnableAdapter.call(Executors.java:511)
at urrent.FutureTask.run(FutureTask.java:266)
at urrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at urrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
因此,我如何以List< TypeMirror>从注释中读取这些类. ?

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。