byte-buddy
byte-buddy copied to clipboard
Does bytebuddy support jdk17
[2022-07-25 15:46:57] [22745:rasp-logger_deamon_task] DEBUG c.x.r.i.ExceptionReportingAgentBuilderListener: onError(): { typeName=java.time .zone.ZoneRules, classLoader=null, module=module java.base, loaded=false } Execption: java.lang.IllegalArgumentException: Unsupported class file major version 61
Yes, but it likely needs to be updated.
+1
This is our stacktrace (in https://github.com/linkedin/parseq)
java.lang.UnsupportedOperationException: Could not access Unsafe class: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
at parseq.net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$Unavailable.initialize(ClassInjector.java:2006)
at parseq.net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe.injectRaw(ClassInjector.java:1738)
at parseq.net.bytebuddy.dynamic.loading.ClassInjector$AbstractBase.inject(ClassInjector.java:110)
at com.linkedin.parseq.lambda.ASMBasedTaskDescriptor.<clinit>(ASMBasedTaskDescriptor.java:102)
Yes, but the ClassInjector
in question does not work on Java 17 anymore. It would need to resolve another injector for this platform, such as ClassInjector.UsingUnsafe
.
This is something the maintainers have to fix, it's described in the javadoc how to resolve this.
it's described in the javadoc how to resolve this
Do you have a pointer to where in the javadoc it's described, or have any general advice for updating usages of bytebuddy that are encountering this error?
I saw this, but it doesn't recommend a specific alternative strategy: https://github.com/raphw/byte-buddy/blob/60f21c4e9382c794423c4d8c1b93bd508cdc80f1/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/loading/ClassLoadingStrategy.java#L113-L115
It seems like the part of http://mydailyjava.blogspot.com/2018/04/jdk-11-and-proxies-in-world-past.html?m=1 about "Supporting proxies on Java versions prior to 9 and past 10" answers my question, is that still a good reference for using a ClassLoadingStrategy
that works with versions before and after 9?
Yes, before 9, Unsafe is the only option. From 17, handles are the only option.
Most of these methods are moved to jdk.internal.misc.Unsafe which requires special access via "--add-exports" and may be some other permissions, but technically "Unsafe.defineClass" is still available.
Byte Buddy 1.10.21 Update ASM and add support for Java 17 @raphw Would you be able to explain how add support for Java 17? Is it Java 8 compatible? AFAIK, handles does not exist in Java 8. Neither do jdk.internal.misc.Unsafe.
java.lang.UnsupportedOperationException: Could not access Unsafe class: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
Byte Buddy adjusts its support based on the VM being used. You can check ClassFileVersion.ofCurrentVm()
to see what Java version you are running and choose a strategy accordingly.