Unable to instrument class file version on Java 6 on JDK 11
See original GitHub issueJDK: 11.0.2
Byte-Buddy: 1.10.1
Trying to instrument a certain library that was compiled in Java 6, it is being shown the following error:
java.lang.IllegalStateException: Cannot write invoke dynamic instruction for class file version Java 6
However, if I use JDK 1.7/1.8, the class is instrumented without problems.
Did I miss something to instrument these kind of classes? Thanks so very much!
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
How to fix java.lang.UnsupportedClassVersionError
This error means that the JRE that is being used to execute your class code does not recognise the version of Java used....
Read more >Java - Unsupported class file major version 61 - Mkyong.com
It means Java 17 (major version 61) compiled the class file, and if we try to run the class file under Java 16...
Read more >How to Fix UnsupportedClassVersion Error in Java - Rollbar
The UnsupportedClassVersionError in Java occurs when the JVM attempts to read a malformed or otherwise erroneous class file.
Read more >Android SDK with Java 11 - Mobile - New Relic Explorers Hub
Does the latest 6.0.0 version of the SDK work with JDK 11 when building on Android? I'm seeing this error: Error while instrumenting...
Read more >Oracle JDK Migration Guide - Java
Before migrating your application to JDK 11, you should understand what the ... code on the class path with references to classes in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I assume that you are using an advice template that uses an invokedynamic instruction, most likely a lambda expression. If your targeted class file was compiled against Java 6, it is illegal to inline such an expression into the instrumented class, no matter what JVM version you are running.
Make sure to compile your advice classes against Java 6 byte code level. That is the most universal to consider.
Fixed!
Thanks for the support!