[GRADLE-2667] Juint tests break on JDK8 b74 Created: 01/Feb/13  Updated: 20/Nov/13  Resolved: 18/Nov/13

Status: Resolved
Project: Gradle
Affects Version/s: 1.2, 1.3, 1.4
Fix Version/s: 1.10-rc-1

Type: Bug
Reporter: Danno Ferrin Assignee: Unassigned
Resolution: Fixed Votes: 2


 Description   

Tests are broken in JDK8 b74 and later, I think they turned on some lambda stuff that changes some ASM assumptions.

Caused by: 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 org.gradle.api.internal.tasks.testing.detection.AbstractTestFrameworkDetector.classVisitor(AbstractTestFrameworkDetector.java:119)
... 85 more

Groovy had a similar problem with GROOVY-5947 and fixed it like this:
https://github.com/groovy/groovy-core/commit/00c80a3ffdc7ddebfeace0979c2f4f83928e51bf



 Comments   
Comment by Paul Merlin [ 15/Feb/13 ]

Got the very same behavior when I upgraded a Gradle project dependencies to ASM from 3.3 to 4.1.

Not sure if the fix should be in Gradle or in ASM, I found this issue in the ASM bugtracker that seems related: #316375 Add version 52.0 in ASM to support JDK 8 classfiles.

Comment by Richard Bair [ 15/Feb/13 ]

Same here, the issue is due to ASM ClassReader, which explicitly fails a bytecode version check. There is a branched version of ASM that contains the required fixes. Since OpenJFX is generally going to be compiling with a +1 version of the JDK (ie: the next unreleased version) we are likely to face this again in the future when working on Java 9. One idea was to have a patched version of Gradle that uses the unreleased 8 compatible version of ASM.

Comment by Paul Merlin [ 20/Feb/13 ]

Issue at ASM: http://forge.ow2.org/tracker/index.php?func=detail&aid=316375&group_id=23&atid=350023

Follow up discussion on ASM mailing-list: http://mail-archive.ow2.org/asm/2013-02/msg00000.html

Comment by Adam Murdoch [ 24/Feb/13 ]

A workaround is to switch off the test class detection:

test {
    scanForTestClasses = false
    // probably have to tweak the include and exclude patterns, depending on the naming scheme you use
    include '**/*Test.*'
    exclude '**/*Abstract*.*'
}
Comment by Adam Murdoch [ 24/Feb/13 ]

@Richard, it should be possible to extract out the test detection stuff so that it is better isolated and can use an unreleased version of ASM. Or you can replace it with a custom detector that doesn't need to use ASM.

Comment by Richard Bair [ 26/Feb/13 ]

Adam, thanks for the workaround that is doing the trick. Ultimately we're going to use jtreg to discover and run our tests, and this sounds a bit more like the ability to replace the built in test detection with my own custom detector. (Actually what jtreg will do is discover the tests and also invoke them, such that each test can be customized to indicate whether it can be used in a shared VM or not, so that we don't have to manage that information in the build script but rather in the tests themselves).

Comment by Paul Merlin [ 18/Nov/13 ]

Adam, could you tell us what was done to close this issue?
Best regards

Comment by Adam Murdoch [ 19/Nov/13 ]

@Paul, we just upgraded to a new version of asm which understands the new byte code version.

Comment by Paul Merlin [ 20/Nov/13 ]

Thanks Adam

Generated at Wed Jun 30 12:28:09 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.