artyushov / idea-jmh-plugin

Plugin for Itellij IDEA to make benchmarking with JMH easier.
MIT License
442 stars 43 forks source link

Having JMH benchmarks while compiling with Ajc compiler breaks the build with an error #14

Closed gvlasov closed 4 years ago

gvlasov commented 9 years ago

When I'm using JMH plugin with Compiler → Java Compiler → Use compiler set to Ajc (AspectJ compiler), and there are JMH benchmarks in my project, I'm getting the following error when compiling any class. I can prevent the error doing a clean build (by removing the target directory or doing Rebuild project), but doing incremental builds results in this:

Error:ajc: Error writing benchmark list javax.annotation.processing.FilerException: createResource. Resource already created : CLASS_OUTPUT//META-INF/BenchmarkList --- uri = file:/home/suseika/IdeaProjects/eloquent-aspects/target/test-classes/META-INF/BenchmarkList
----
file:/home/suseika/IdeaProjects/eloquent-aspects/target/test-classes/META-INF/BenchmarkList
file:/home/suseika/IdeaProjects/eloquent-aspects/target/test-classes/META-INF/CompilerHints
    at org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchFilerImpl.createResource(BatchFilerImpl.java:94)
    at org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.AjBatchFilerImpl.createResource(AjBatchFilerImpl.java:35)
    at org.openjdk.jmh.generators.annotations.APGeneratorDestinaton.newResource(APGeneratorDestinaton.java:51)
    at org.openjdk.jmh.generators.core.BenchmarkGenerator.complete(BenchmarkGenerator.java:219)
    at org.openjdk.jmh.generators.BenchmarkProcessor.process(BenchmarkProcessor.java:60)
    at org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:140)
    at org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:111)
    at org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:160)
    at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:881)
    at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:439)
    at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:420)
    at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1036)
    at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:272)
    at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:185)
    at com.intellij.lang.aspectj.build.AjJpsCompiler.doBuild(AjJpsCompiler.java:227)
    at com.intellij.lang.aspectj.build.AjJpsCompiler.build(AjJpsCompiler.java:113)
    at com.intellij.lang.aspectj.build.AjTranslatingBuilder.doBuild(AjTranslatingBuilder.java:111)
    at com.intellij.lang.aspectj.build.AjBuilderBase.build(AjBuilderBase.java:75)
    at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1170)
    at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:851)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:919)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:814)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:637)
    at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:370)
    at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:191)
    at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:137)
    at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:293)
    at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:124)
    at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:242)
    at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
luengnat commented 6 years ago

I got a similar problem

Error:java: Error writing benchmark list javax.annotation.processing.FilerException: Resource already created : CLASS_OUTPUT//META-INF/BenchmarkList
    at org.eclipse.jdt.internal.compiler.apt.dispatch.BatchFilerImpl.createResource(BatchFilerImpl.java:90)
    at org.openjdk.jmh.generators.annotations.APGeneratorDestinaton.newResource(APGeneratorDestinaton.java:47)
    at org.openjdk.jmh.generators.core.BenchmarkGenerator.complete(BenchmarkGenerator.java:186)
    at org.openjdk.jmh.generators.BenchmarkProcessor.process(BenchmarkProcessor.java:59)
    at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:139)
    at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:110)
    at org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:159)
    at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:953)
    at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:437)
    at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:417)
    at org.eclipse.jdt.internal.compiler.batch.Main.performCompilation(Main.java:4180)
    at org.eclipse.jdt.internal.compiler.tool.EclipseCompilerImpl.call(EclipseCompilerImpl.java:76)
    at org.eclipse.jdt.internal.compiler.tool.EclipseCompiler$1.call(EclipseCompiler.java:188)
    at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:190)
    at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:473)
    at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:328)
    at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:255)
    at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:208)
    at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1260)
    at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:937)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1009)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:900)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:733)
    at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:385)
    at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:192)
    at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138)
    at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:295)
    at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:125)
    at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:236)
    at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
stokito commented 4 years ago

Why would you need to compile with AspectJ? To test aspect advice? Aspects are implemented as a bytecode manipulation and JMH also performs some transformations. Probably JMH should itself support ajc but I guess this will never happen. Currently only HotSpot JVM and compiler supported. I'll close the ticket because I don't see anything that we as developers of JMH plugin can make here. Feel free to reopen ticket if you know what exactly we should do here