# Plugin compiled with Java 8 won't work on Java 7

**URL:** <https://discuss.gradle.org/t/plugin-compiled-with-java-8-wont-work-on-java-7/1578>\
**Category:** Old Forum Archive\
**Created:** [December 17, 2014, 12:19am UTC](https://discuss.gradle.org/t/plugin-compiled-with-java-8-wont-work-on-java-7/1578 "2014-12-17T00:19:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jurgen\_Cruz](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jurgen_cruz/32/411_2.png) [@Jurgen\_Cruz](https://discuss.gradle.org/u/Jurgen_Cruz)\
**Post date:** [December 17, 2014, 12:19am UTC](https://discuss.gradle.org/t/plugin-compiled-with-java-8-wont-work-on-java-7/1578/1 "2014-12-17T00:19:00Z")

</div>

Hi, I’m the creator of the plugin [https://github.com/JCAndKSolutions/android-unit-test/](https://github.com/JCAndKSolutions/android-unit-test/) And I compile it with Java 8 with the sourceCompatibility and TargetCompatibility set to 1.6. Everything was working perfectly until today when I got a failed Travis build: [https://travis-ci.org/JCAndKSolutions/android-unit-test/jobs/44274091](https://travis-ci.org/JCAndKSolutions/android-unit-test/jobs/44274091) . The stack trace says that the Class java.util.HashMap$Node was not found.

I extend a HashMap in my code but I don’t use the Node class directly. If I compile it with Java 7 it works. I use Gradle version 2.2.1 and use “compile localGroovy()” to reference the Groovy SDK. I don’t know if that has anything to do. Any ideas why is it hardcoding the Java 8 HashMap implementation? Would making my Map a .java instead of a .groovy help? Do I need to force a version of groovy?

I need to fix this ASAP since the version 2.1.0 is already in Maven central and I require to publish a fixed 2.1.1 for my users.

Thank you very much.

Jürgen.

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [December 17, 2014, 2:13am UTC](https://discuss.gradle.org/t/plugin-compiled-with-java-8-wont-work-on-java-7/1578/2 "2014-12-17T02:13:00Z")

</div>

Hi,&nbsp;  
  
I’m pretty sure this is a Groovy problem, that we won’t be able to resolve. Can you please provide a _full_ stacktrace (obtained by running with ‘-S’, not ‘-s’) so we can verify?

---

<div class="post-metadata">

**Author:** ![Jurgen\_Cruz](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jurgen_cruz/32/411_2.png) [@Jurgen\_Cruz](https://discuss.gradle.org/u/Jurgen_Cruz)\
**Post date:** [December 17, 2014, 4:08am UTC](https://discuss.gradle.org/t/plugin-compiled-with-java-8-wont-work-on-java-7/1578/3 "2014-12-17T04:08:00Z")

</div>

I was able to fix this by not extending nor implementing the Map interface. I made a wrapper instead with a map as a member. So basically yeah, referencing any class that was touched in Java 8 can give trouble. It might be a groovy issue but correct me if I’m wrong, if use the ‘sourceCompatibility’, ‘targetCompatibility’ and ‘options.bootClasspath’ all pointing to Java 7, shouldn’t the byte code generated by compatible with Java 7 and not reference Java 8 classes/methods? this is what I have in build.gradle:

‘’’ compileJava {

sourceCompatibility = JavaVersion.VERSION\_1\_7

targetCompatibility = JavaVersion.VERSION\_1\_7

options.bootClasspath = “${System.env.JDK7\_HOME}/jre/lib/rt.jar”

}

compileTestJava {

sourceCompatibility = JavaVersion.VERSION\_1\_7

targetCompatibility = JavaVersion.VERSION\_1\_7

options.bootClasspath = “${System.env.JDK7\_HOME}/jre/lib/rt.jar”

}

compileGroovy {

sourceCompatibility = JavaVersion.VERSION\_1\_7

targetCompatibility = JavaVersion.VERSION\_1\_7

options.bootClasspath = “${System.env.JDK7\_HOME}/jre/lib/rt.jar”

}

compileTestGroovy {

sourceCompatibility = JavaVersion.VERSION\_1\_7

targetCompatibility = JavaVersion.VERSION\_1\_7

options.bootClasspath = “${System.env.JDK7\_HOME}/jre/lib/rt.jar”

}

test {

jvmArgs ‘-noverify’

} ‘’’

Notice the noverify flag that I have to set because otherwise the tests fail with a verification error. I’m completely lost as to what gradle does internally to compile and run with Java 8 JDK but keeping Java 7 compatible if that happens at all. Maybe Groovy is adding a dependency on Java 8?

Thanks for looking into this, I’ll see if I can get you the stack trace.
