Skip to content
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

Error when using Java 8 #166

Closed
ghost opened this issue Jun 6, 2014 · 26 comments
Closed

Error when using Java 8 #166

ghost opened this issue Jun 6, 2014 · 26 comments

Comments

@ghost
Copy link

ghost commented Jun 6, 2014

I'm trying to run Cobertura for Java 8 project. I get errors like

java.lang.VerifyError: Expecting a stackmap frame at branch target 78

Using -XX:-UseSplitVerifier does not help since I think it was dropped in Java 8.

@kimmerin
Copy link

kimmerin commented Jul 2, 2014

What version of Cobertura are you using, what versions of the other libraries, cobertura needs are you using?

@ghost
Copy link
Author

ghost commented Jul 2, 2014

Using Maven

<dependency>
    <groupId>net.sourceforge.cobertura</groupId>
    <artifactId>cobertura</artifactId>
    <version>2.0.3</version>
</dependency>

@christ66
Copy link
Member

christ66 commented Jul 2, 2014

Maven plugin isn't upgraded to be compatible with java 8. There were some recent changes in core to allow for java 8 compatibility, however I have yet to write any test units testing the latest functionality. I think over the break I will do some major work on cobertura (removing java -1.5 compatibility, etc. to fix a lot of the issues people are encountering.

@theHilikus
Copy link

Any updates on this?
I'm using cobertura-maven-plugin:2.6 and I get

[INFO] Cobertura 2.0.3 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[cobertura] WARN  [main] net.sourceforge.cobertura.instrument.CoberturaInstrumenter - Unable to instrument file /var/lib/jenkins/workspace/gitBranchBuilder/implementations/configuration/target/generated-classes/cobertura/com/foo/schema/other/SchemaNamespaces.class
java.lang.IllegalArgumentException
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:147)
at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:121)
at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:234)
at net.sourceforge.cobertura.instrument.Main.addInstrumentationToSingleClass(Main.java:298)
at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:307)
at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:399)
at net.sourceforge.cobertura.instrument.Main.main(Main.java:421)

I imagine it is caused by ASM not liking java 8?

@dfranssen
Copy link

I'm getting the same issue as @theHilikus with my java8 project. Any feedback regarding this?

@dennisl
Copy link

dennisl commented Nov 19, 2014

The Cobertura Maven Plugin uses Cobertura 2.0.3, as can be seen in the build log.

What happens if you use the latest 2.1.0-SNAPSHOT version of Cobertura from the command line, i.e. not using the Maven plugin? Cobertura 2.1.0-SNAPSHOT uses ASM 5.0, which is supposed to be Java 8 compatible.

@dennisl
Copy link

dennisl commented Nov 26, 2014

I have updated the Maven Cobertura Plugin to use the latest 2.1.0-SNAPSHOT of Cobertura. Please give version 2-7-SNAPSHOT of the plugin it a try. Also if you are only using the Cobertura jar, version 2.1.0-SNAPSHOT of that has been deployed to the SNAPSHOT-repository.

Others have had some success with the latest versions, see https://jira.codehaus.org/browse/MCOBERTURA-189

But, there seems to be a problem with JavaNCSS and Java 8. JavaNCSS is used inside Cobertura, but Cobertura has a copy of (an old version of) the JavaNCSS classes. So updating to a newer version of JavaNCSS is not an easy task. I gave it a try, but haven't been able to finish it yet.

@theHilikus
Copy link

@dennisl thank you for the update. I am currently in the middle of releasing so I can't use an unstable plugin. I will try to test it next week.
Where are you pushing these unstable artifacts though? i'm currently just pulling from maven central

@theHilikus
Copy link

Oh, I also forgot to ask. There's another workaround mentioned here. What do you think of it? at least it seems to allow using the latest stable version of the plugin (2.6). I tried it and it seemed to work, although with some strange warnings

@dennisl
Copy link

dennisl commented Nov 26, 2014

@theHilikus The Cobertura SNAPSHOTs are available in this repo:
https://oss.sonatype.org/content/repositories/snapshots/

The Cobertura Maven Plugin SNAPSHOTs are available in this repo:
https://nexus.codehaus.org/content/groups/snapshots-group/

There are no SNAPSHOTs in Maven central, so if you are about to release you need to stick with non-SNAPSHOT versions.

@dennisl
Copy link

dennisl commented Nov 26, 2014

@theHilikus That workaround might work, but there are 5 dependencies on ASM artifacts in Cobertura, so ideally you'd need to add them all with the updated version. They are specied in this POM:
https://github.com/cobertura/cobertura/blob/master/cobertura/pom.xml

@abbybader
Copy link

@dennisl I'm having trouble hitting the Maven plugin snapshots repo. I've googled around for examples (haven't worked with Nexus in years) but I think maybe I'm just missing the appropriate value. Can you provide it? I took a guess and ended up with the following:

<pluginRepositories>
    <pluginRepository>
    <id>codehaus-snapshots-group</id>
      <name>Codehaus Snapshots</name>
      <url>https://nexus.codehaus.org/content/groups/snapshots-group/</url>
    </pluginRepository>
</pluginRepositories>

FWIW the solution linked by @theHilikus allows me to run, so this isn't urgent from our point of view. However, if you need some legwork done on the issue, I'd be happy to help.

@dennisl
Copy link

dennisl commented Jan 9, 2015

This is the setting that I use:

      <pluginRepositories>
        <pluginRepository>
          <id>codehaus-nexus-snapshots</id>
          <name>Codehaus Nexus Snapshots</name>
          <url>https://nexus.codehaus.org/content/repositories/snapshots/</url>
        </pluginRepository>
      </pluginRepositories>

Let me know if you have problems using the Maven plugin SNAPSHOT.

@dennisl dennisl added this to the Cobertura 2.1.0 milestone Jan 14, 2015
@dennisl dennisl closed this as completed Jan 14, 2015
@theHilikus
Copy link

@dennisl now that the issue is closed, is it just a matter of waiting for the 2.7 release of cobertura-maven-plugin??

@dennisl
Copy link

dennisl commented Jan 19, 2015

@theHilikus I am pushing first for a release of Cobertura, and after that a release of the Maven plugin.

@theHilikus
Copy link

makes sense. i just wanted to know what were the missing steps to having a working plugin. I was also assuming that Cobertura had already been released, which I see is wrong

@trothwell
Copy link

Do we have a date for 2.1 release?

@dennisl
Copy link

dennisl commented Jan 19, 2015

ASAP

@theHilikus
Copy link

Hi @dennisl
I just tried cobertura plugin 2.7 after you (I think) sent an email to the maven mailing list; however, I still get a bunch of warnings. What am I doing wrong? or is java 8 not yet supported (I thought it was based on this thread)
I get two types of problems

[INFO] --- cobertura-maven-plugin:2.7:instrument (default) @ service-alarm-impl ---

mojoSucceeded org.codehaus.mojo:cobertura-maven-plugin:2.7(default)[INFO] Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[WARN] Unable to instrument file /var/lib/jenkins/workspace/platform_HEAD/implementations/service/target/generated-classes/cobertura/com/foo/config/ServiceConfigPersistance.class
java.lang.IllegalArgumentException: INVOKESPECIAL/STATIC on interfaces require ASM 5
    at org.objectweb.asm.MethodVisitor.visitMethodInsn(Unknown Source) ~[asm-5.0.1.jar:5.0.1]
    at org.objectweb.asm.ClassReader.a(Unknown Source) ~[asm-5.0.1.jar:5.0.1]
    at org.objectweb.asm.ClassReader.b(Unknown Source) ~[asm-5.0.1.jar:5.0.1]
    at org.objectweb.asm.ClassReader.accept(Unknown Source) ~[asm-5.0.1.jar:5.0.1]
    at org.objectweb.asm.ClassReader.accept(Unknown Source) ~[asm-5.0.1.jar:5.0.1]
    at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:161) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:129) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:243) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.instrument.CodeInstrumentationTask.addInstrumentationToSingleClass(CodeInstrumentationTask.java:299) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.instrument.CodeInstrumentationTask.addInstrumentation(CodeInstrumentationTask.java:308) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.instrument.CodeInstrumentationTask.instrument(CodeInstrumentationTask.java:90) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.dsl.Cobertura.instrumentCode(Cobertura.java:74) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.instrument.InstrumentMain.instrument(InstrumentMain.java:82) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.instrument.InstrumentMain.main(InstrumentMain.java:99) [cobertura-2.1.1.jar:2.1.1]
[WARN] Unable to instrument file /var/lib/jenkins/workspace/platform_HEAD/implementations/service/target/generated-classes/cobertura/com/foo/internal/config/ServiceConfigImpl.class
java.lang.IllegalArgumentException: INVOKESPECIAL/STATIC on interfaces require ASM 5
    at org.objectweb.asm.MethodVisitor.visitMethodInsn(Unknown Source) ~[asm-5.0.1.jar:5.0.1]
    at org.objectweb.asm.ClassReader.a(Unknown Source) ~[asm-5.0.1.jar:5.0.1]
    at org.objectweb.asm.ClassReader.b(Unknown Source) ~[asm-5.0.1.jar:5.0.1]
    at org.objectweb.asm.ClassReader.accept(Unknown Source) ~[asm-5.0.1.jar:5.0.1]
    at org.objectweb.asm.ClassReader.accept(Unknown Source) ~[asm-5.0.1.jar:5.0.1]
    at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:161) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:129) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:243) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.instrument.CodeInstrumentationTask.addInstrumentationToSingleClass(CodeInstrumentationTask.java:299) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.instrument.CodeInstrumentationTask.addInstrumentation(CodeInstrumentationTask.java:308) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.instrument.CodeInstrumentationTask.instrument(CodeInstrumentationTask.java:90) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.dsl.Cobertura.instrumentCode(Cobertura.java:74) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.instrument.InstrumentMain.instrument(InstrumentMain.java:82) [cobertura-2.1.1.jar:2.1.1]
    at net.sourceforge.cobertura.instrument.InstrumentMain.main(InstrumentMain.java:99) [cobertura-2.1.1.jar:2.1.1]
[INFO] Cobertura: Saved information on 12 classes.
[INFO] Cobertura: Saved information on 12 classes.

[INFO] Instrumentation was successful.
[INFO] NOT adding cobertura ser file to attached artifacts list.

mojoStarted org.apache.maven.plugins:maven-resources-plugin:2.7(default-testResources)[INFO] Using 'UTF-8' encoding to copy filtered resources.

The other error I see is too long to post all of it but this is the main part. It is related to lambdas

[INFO] --- cobertura-maven-plugin:2.7:cobertura (default) @ geckoflex ---
[INFO] Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[INFO] Cobertura: Loaded information on 105 classes.
[WARN] JavaNCSS got an error while parsing the java file /var/lib/jenkins/workspace/platform_HEAD/implementations/blah/src/main/java/com/foo/CommunicatorImpl.java
ParseException in STDIN
Last useful checkpoint: "com.foo.CommunicatorImplcom.foo.CommunicatorImpl.CommunicatorImpl(SocketManager)"
Encountered " ")" ") "" at line 40, column 35.
Was expecting one of:
    "assert" ...
    "boolean" ...
    "byte" ...
    "char" ...
    "double" ...
    "enum" ...
    "false" ...
    "float" ...
    "int" ...
    "long" ...
    "new" ...
    "null" ...
    "short" ...
    "super" ...
    "this" ...
    "true" ...
    "void" ...
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <CHARACTER_LITERAL> ...
    <STRING_LITERAL> ...
    <IDENTIFIER> ...
    "(" ...
    "!" ...
    "~" ...
    "++" ...
    "--" ...
    "+" ...
    "-" ...
    "boolean" ...
    "char" ...
    "byte" ...
    "short" ...
    "int" ...
    "long" ...
    "float" ...
    "double" ...
    "double" ...
    "boolean" ...
    "char" ...
    "byte" ...
    "short" ...
    "int" ...
    "long" ...
    "float" ...
    "double" ...
    <IDENTIFIER> ...
    "boolean" ...
    "char" ...
    "byte" ...
    "short" ...
    "int" ...
    "long" ...
    "float" ...
    "double" ...
    "double" ...
    "boolean" ...
    "char" ...
    "byte" ...
    "short" ...
    "int" ...
    "long" ...
    "float" ...
    "double" ...
    <IDENTIFIER> ...
    "boolean" ...
    "char" ...
    "byte" ...
    "short" ...
    "int" ...
    "long" ...
    "float" ...
    "double" ...

Thank you for your help again

@dennisl
Copy link

dennisl commented Mar 3, 2015

The first problem I have not seen before. Could you please open a separate issue for that. If you could include a small test class that shows the issue, it would be very helpful.

The second one is not about the instrumentation or the calculation of coverage. The report should be ok despite the warning in the log. This is really about a problem in JavaNCSS, which is used by Cobertura. It is tracked in issue #220

@cromoteca
Copy link

I'm experiencing the same issue reported by @theHilikus, so I opened issue #248 for it.

@OhadR
Copy link

OhadR commented Dec 7, 2015

@dennisl great job ;-) thanks. i have a similar issue with gradle-plugin, but i assume it is not cobertura's problem now, since 2.1 release.

@DINESHMOHAN
Copy link

Is there an ETA for Cobertura support for Java 8 ?

@klassounski-daitan
Copy link

Any news on the support for Java 8? Java 9 is coming out for god sake.

@madorb
Copy link

madorb commented Nov 28, 2017

Java 9 is out :-)

cpovirk added a commit to google/truth that referenced this issue Jan 4, 2018
Motivation: The old version of cobertura-maven-plugin is apparently corrupting .class files, triggering VerifyError during tests.
I see this only after I've run `mvn versions:set` and I'm running `mvn site:jar`.

Presumably it's cobertura/cobertura#166

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=180834879
joschi pushed a commit to Graylog2/graylog2-server that referenced this issue Mar 5, 2018
The Cobertura Maven plugin (and Cobertura itself) doesn't support Java 8.

Additionally, code coverage metrics are currently not used anywhere in the build,
so we can as well remove it.

Refs mojohaus/cobertura-maven-plugin#21
Refs cobertura/cobertura#166
bernd pushed a commit to Graylog2/graylog2-server that referenced this issue Mar 9, 2018
The Cobertura Maven plugin (and Cobertura itself) doesn't support Java 8.

Additionally, code coverage metrics are currently not used anywhere in the build,
so we can as well remove it.

Refs mojohaus/cobertura-maven-plugin#21
Refs cobertura/cobertura#166
sebasjm pushed a commit to sebasjm/truth that referenced this issue Mar 11, 2018
Motivation: The old version of cobertura-maven-plugin is apparently corrupting .class files, triggering VerifyError during tests.
I see this only after I've run `mvn versions:set` and I'm running `mvn site:jar`.

Presumably it's cobertura/cobertura#166

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=180834879
@Ordiel
Copy link

Ordiel commented Mar 22, 2018

I've literally been waiting this since first quarter of 2017 :/ I guess it was a good run... moving on to JaCoCo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests