-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JaCoCo 0.8.4 and Java 11 Agent Conflict #68
Comments
I read that before commenting in Bugzilla. There is only the same incomplete POM as here, I see no sample project. I told you in my comment, which information I need. Please read again and edit the question. |
I quickly added an application class + JUnit 4 test to my sample project based on your POM snippet. The build runs fine and creates a correct coverage report with JaCoco 0.8.4 on JDK 8, 11, 16. Same with JaCoCo 0.8.7. So if you want me to reproduce your problem, I need a full example project with classes, AspectJ and JaCoCo configuration. |
OK, I did your job for you and created a sample project: Running
The dump file thing is unrelated to this issue, because Surefire has problems with correctly displaying console output created by the JVM itself or by Java agents in general. Anyway, if you open the
This in the end is what makes the build fail. Therefore, the root cause of your problem are simply pointcuts which are too broad, there is no problem in JaCoCo or AspectJ as such. The problem sits in front of the keyboard. 😉 There are at least three ways to solve this:
BTW, in this specific case, excluding @aclement, I think this one can be closed and categorised as "won't fix", "question" and/or whatever tags you deem appropriate. Update: Like I said, at least three ways to solve it. One more way would be:
|
@aclement, please reopen this bug. I have reason to believe my assessment was premature and the problem still persists. While limiting the aspect scope is necessary and should be kept in order to avoid weaving JaCoCo, JUnit and Surefire classes, like I suggested, the problems caused by that were merely covering up another problem. That problem is related to JEP 309 (Dynamic Class-File Constants) being used by JaCoCo and the AspectJ Weaver seemingly to be unable to deal with the generated bytecode, causing See my comment here and the reproducer project here. Andy, could you please look into that and implement a fix? If this is really an AspectJ problem, we probably have it since Java 11 (AspectJ 1.9.2). I am not sure which of JaCoCo or AspectJ is doing something wrong there, but chances are that it might be AspectJ, so please take a look. |
Update: When running Maven with debug logging, I see (with added line breaks and comments):
I.e., the JaCoCo agent is applied first and then the AspectJ weaver needs to deal with JaCoCo-instrumented byte code, whereas it should be the other way around: JaCoCo should create a coverage report for AspectJ-enhanced classes. So I added commit 487552b8, simply reversing the order of agents on the Surefire command line. This fixes the problem. But it would still be interesting to know why AspectJ cannot deal with JaCoCo-generated byte code. @aclement, you can still reproduce the problem by checking out branch |
|
@aclement, I created a branch Therefore, when running
|
I guess that project is missing some repositories that you have locally configured or something:
|
I switched it to M5 instead. |
Ah yes, of course. Well, in M5 there is a bug which makes the console output of Java agents hang. Lucky you, if with M5 that did not happen. Actually, you can also build with a previous release 2.2.x, but then you do not see the agent output on the console, only in a dump file. I helped the Surefire people fix that by testing and providing reproducer projects. |
I see no reason to delay on 1.9.8 if you are happy. I do the website updates after it is available. |
Given that I don't know of a java language construct that would cause the compiler to generate bytecode containing |
Relates to eclipse-aspectj#68. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
@aclement, I modified code by @raphw found in this blog post, ASM-ified it, stored the generator code beside the actual test classes, but also committed a JAR containing the generated class file, similar to how it was done for the indy (invokedynamic) tests. That is not nice, but I did not want to make a big change in order to be able to refer to ASM from XML test configs via something like If we ever see more widespread adoption of condy in JVM languages, we can move the test to its own BTW, like I thought, this bug has existed ever since Java 11 and condy support were added to AspectJ 1.9.2. |
Relates to eclipse-aspectj#68. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Relates to eclipse-aspectj#68. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Nice test case and nice work on the original maven repro sample, made my life much easier. |
This is copy of https://bugs.eclipse.org/bugs/show_bug.cgi?id=549438
from myself it is reproducible on
this issue is pretty well described (with sample project) in jacoco/jacoco#909
see comment jacoco/jacoco#909 (comment)
current workaround: downgrade jacoco to 0.8.3
The text was updated successfully, but these errors were encountered: