raphw / byte-buddy

Runtime code generation for the Java virtual machine.
https://bytebuddy.net
Apache License 2.0
6.29k stars 807 forks source link

ByteBuddy in Hibernate GraalVM Issue #1560

Closed tonyre closed 1 month ago

tonyre commented 1 year ago

I must apologize right away if this topic is misplaced, but please give this problem a chance to be considered.

I am using the Hibernate library (6.1.1) which includes byte-buddy (1.12.9). I would like to compile it natively using GraalVM. The compile process goes through, but at runtime an error is reported regarding byte-buddy. I have also tested different versions of hibernate and byte-buddy without any positive change.

I have tried all possible experimental options, unfortunately without success.

To easily reproduce that behavior I prepared a little sample that exactly describes that issue, please see: https://github.com/tonyre/HibernateSampleGraalVM

Maybe that's still an issue with byte-buddy - if not please appologize. Greetings Tony

Caused by: java.lang.UnsupportedOperationException: Defining new classes at runtime is not supported at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unimplemented(VMError.java:195) at java.base@21.0.1/java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:45) at java.base@21.0.1/java.lang.reflect.Method.invoke(Method.java:580) at net.bytebuddy.utility.Invoker$Dispatcher.invoke(Unknown Source) at net.bytebuddy.utility.dispatcher.JavaDispatcher$Dispatcher$ForNonStaticMethod.invoke(JavaDispatcher.java:1028) at net.bytebuddy.utility.dispatcher.JavaDispatcher$ProxiedInvocationHandler.invoke(JavaDispatcher.java:1158) at jdk.proxy4/jdk.proxy4.$Proxy54.defineClass(Unknown Source) at net.bytebuddy.dynamic.loading.ClassInjector$UsingLookup.injectRaw(ClassInjector.java:1638)

raphw commented 1 year ago

Hibernate supports build-time instrumentation which I assume is required for Graal.

Have you checked Hibernates documentation?