1

I'm trying to build my jwrapper application, and it fails with

WARNING: Error on output: java.io.IOException: bad class major version for Java 7 invokedynamic
**********************************
*          BUILD FAILED          *
**********************************
** Error Trace:

java.io.IOException: bad class major version for Java 7 invokedynamic
    at com.sun.java.util.jar.pack.PackageWriter.writeByteCodes(PackageWriter.java:1657)
    at com.sun.java.util.jar.pack.PackageWriter.writeMembers(PackageWriter.java:1227)
    at com.sun.java.util.jar.pack.PackageWriter.writeClassesAndByteCodes(PackageWriter.java:1202)
    at com.sun.java.util.jar.pack.PackageWriter.write(PackageWriter.java:79)
    at com.sun.java.util.jar.pack.PackerImpl$DoPack.flushPackage(PackerImpl.java:602)
    at com.sun.java.util.jar.pack.PackerImpl$DoPack.flushAll(PackerImpl.java:556)
    at com.sun.java.util.jar.pack.PackerImpl$DoPack.run(PackerImpl.java:492)
    at com.sun.java.util.jar.pack.PackerImpl.pack(PackerImpl.java:98)
    at jwrapper.pack200.Pack200Compressor.compressFileToOutputStream(Pack200Compressor.java:225)
    at jwrapper.archive.Archive.addFileToStream(Archive.java:422)
    at jwrapper.archive.Archive.addFile(Archive.java:159)
    at jwrapper.archive.Archive.addFile(Archive.java:103)
    at jwrapper.archive.LaunchableArchive.addFile(LaunchableArchive.java:43)
    at jwrapper.archive.LaunchableArchive.addFile(LaunchableArchive.java:29)
    at jwrapper.JWrapperCompiler.main(JWrapperCompiler.java:2827)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at SecureRunner2.<init>(SecureRunner2.java:452)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at SecureRunner1.<init>(SecureRunner1.java:410)
    at SecureRunner1.<init>(SecureRunner1.java:227)
    at SecureRunner1.main(SecureRunner1.java:52)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)

It used to build with no problems at all, and nothing changed (not the jwrapper.xml file, which can be attached if that would be helpful, nor the java version jdk1.8.0_31, or even the code being wrapped!). What has me baffled (yes, I googled for invokedynamic, java 7, jwrapper, etc and various combinations of those), was how Java 7's even involved. I have no instances of Java 7 on the system -- I'm packing 1.8.0_31 JRE's, and am using jdk1.8.0_31 to run the process.

Henry Crutcher
  • 2,137
  • 20
  • 28
  • 2
    The reference to Java 7 is because the 'invokedynamic' instruction was added to the JVM in Java 7. So it looks like the code is using 'invokedynamic' but the class file version is Java 6 or earlier (so the major version is wrong). – greg-449 Feb 24 '15 at 17:47
  • 1
    If you post an answer that incorporates your comment, I'll gleefully accept it, as your comment got me on the right track. – Henry Crutcher Feb 24 '15 at 18:13

2 Answers2

2

The reference to Java 7 is because the 'invokedynamic' instruction was added to the JVM in Java 7.

So it looks like the code is using 'invokedynamic' but the class file version is Java 6 or earlier (so the major version is wrong).

greg-449
  • 109,219
  • 232
  • 102
  • 145
0

It turns out that proguard was preprocessing those class files, and labeling them as version 1.6 class files. This was fine until some bit of code actually used invokedynamic, which then triggered the error. So the condition was caused by the USE of Java 1.8 features, rather than merely including a library built for java 1.8.

Henry Crutcher
  • 2,137
  • 20
  • 28