The :test task can fail with 'failed to read class file X' when unit tests are compiled with Java 1.8's -parameters option

When compiling a gradle project that uses the new Java 1.8 -parameters feature, the check task fails in some cases. I’ve created a small github example project that recreates the problem: https://github.com/seanjreilly/gradle-parameters-bug/ It requires Java 1.8, and with gradle 2.0 the test task fails when you run gradle clean build.

The error message and stacktrace produced are in [this gist] (https://gist.github.com/seanjreilly/086968ab04fbb339b562).

The error can be avoided by: * disabling the -parameters option when compiling (commenting out lines 15-17 in build.gradle) * commenting out the method (doTheThing) with parameters (commenting out lines 6-8 in TheTest.java) * moving the “doTheThing” method below the first org.junit.Test annotated test method in TheTest.java

Any ideas?

output of gradle -v:

------------------------------------------------------------
Gradle 2.0
------------------------------------------------------------
  Build time:
 2014-07-01 07:45:34 UTC
Build number: none
Revision:
   b6ead6fa452dfdadec484059191eb641d817226c
  Groovy:
     2.3.3
Ant:
        Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:
        1.8.0_11 (Oracle Corporation 25.11-b03)
OS:
         Mac OS X 10.9.4 x86_64

It looks like it might be an asm bug…

I tried this with the latest build of master (which doesn’t build cleanly for me right now, btw) and with a 2.0 branch modified only to move to the latest version of asm. Both of these still replicate the same error.

Based on the stack trace, the problem is likely related to asm, or gradle’s use of asm to detect junit/testng tests, but I don’t think I can confidently say for sure…

Somebody more knowledgeable about the codebase is probably needed to conclusively diagnose which “side of the fence” the problem is on.

This is still broken in gradle 2.1. Are there any plans to fix this? Has anyone looked at it?

Hey sean,
thanks for the report, I’ll have a look on that soon

I checked this again, and while it’s still broken in gradle 2.2.1, it’s fixed in gradle 2.3-rc-3. Yay!