devcon5io / mutation-analysis-plugin

Plugin for SonarQube to process mutation analysis results.
GNU Lesser General Public License v3.0
30 stars 17 forks source link

make it compile with java 11 #34

Closed magwas closed 5 years ago

gmuecke commented 5 years ago

The jacoco support for Java11 is experimental. Sonarqube does not support to running on Java 11 - it still requires Java 8. So there is no strong need to be compilable on Java 11. And although the change is rather small, I'm curious, what the actual problem was that it solves?

magwas commented 5 years ago

AFAIK java 11 is the supported LTS version. I think it is a good idea to support it. And sonar actually works with my project on java 11. I need it to compile on java 11. processing of -javaagent failed with jacoco 0.8.1

I see a sonar error in the travis build. It looks like a configuration problem. Looks for sonar on 127.0.0.1/

The build error with jacoco 0.8.1 was: 
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
    at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525)
Caused by: java.lang.RuntimeException: Class java/lang/UnknownError could not be instrumented.
    at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:140)
    at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:101)
    at org.jacoco.agent.rt.internal_c13123e.PreMain.createRuntime(PreMain.java:55)
    at org.jacoco.agent.rt.internal_c13123e.PreMain.premain(PreMain.java:47)
    ... 6 more
Caused by: java.lang.NoSuchFieldException: $jacocoAccess
    at java.base/java.lang.Class.getField(Class.java:2000)
    at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
    ... 9 more
FATAL ERROR in native method: processing of -javaagent failed
Aborted (core dumped)

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.649 s
[INFO] Finished at: 2019-04-10T16:45:29Z
[INFO] Final Memory: 22M/87M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project mutation-analysis-plugin: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /home/developer/mutation-analysis-plugin && /usr/lib/jvm/java-11-openjdk-amd64/bin/java -javaagent:/home/developer/.m2/repository/org/jacoco/org.jacoco.agent/0.8.1/org.jacoco.agent-0.8.1-runtime.jar=destfile=/home/developer/mutation-analysis-plugin/target/jacoco.exec -jar /home/developer/mutation-analysis-plugin/target/surefire/surefirebooter7119762749756609711.jar /home/developer/mutation-analysis-plugin/target/surefire/surefire10175339288073221918tmp /home/developer/mutation-analysis-plugin/target/surefire/surefire_013672901620346697891tmp
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
magwas commented 5 years ago

I still have a workaround in my toolchain project serving ~ 5 other projects related to this issue. Can we work out an agreement about merging this, or should I fork? What are your requirements?

gmuecke commented 5 years ago

I still don't understand why you need to build the plugin by yourself? You can use the pre-built and released artifact from https://github.com/devcon5io/mutation-analysis-plugin/releases or use the version from Sonarqube's marketplace (I think it's still on 1.4, but the 1.5 is coming soon).

I'd much appreciate an issue on github with a comprehensive problem description. "doesn't build on my machine" simply isn't compelling enough, especially as most build-environments support building with different versions of JDKs. What should I write in the release notes? How do others benefit from this change?

Of course your PR is small, but even this small PR doesn't update to the latest version of jacoco, which is 0.8.4.

And as an important side note: the standalone-analysis is an unmaintained branch with a tech demo of what is possible with sonarcloud. If you can live with the version you have in your fork, I'm fine with that.