diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/bytebuddy/ByteBuddyState.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/bytebuddy/ByteBuddyState.java index cc79fb90f2..151fb514c2 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/bytebuddy/ByteBuddyState.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/bytebuddy/ByteBuddyState.java @@ -91,7 +91,7 @@ public final class ByteBuddyState { return buddy; } - public static ClassLoadingStrategy resolveClassLoadingStrategy(Class originalClass) { + public static ClassLoadingStrategy resolveClassLoadingStrategy(Class originalClass) { if ( ClassInjector.UsingLookup.isAvailable() ) { // This is only enabled for JDK 9+ diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/tuplizer/bytebuddysubclass/MyEntityInstantiator.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/tuplizer/bytebuddysubclass/MyEntityInstantiator.java index 3cab644e71..483c84e12d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/tuplizer/bytebuddysubclass/MyEntityInstantiator.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/tuplizer/bytebuddysubclass/MyEntityInstantiator.java @@ -8,11 +8,11 @@ package org.hibernate.test.annotations.tuplizer.bytebuddysubclass; import java.io.Serializable; +import org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState; import org.hibernate.mapping.PersistentClass; import org.hibernate.tuple.Instantiator; import net.bytebuddy.ByteBuddy; -import net.bytebuddy.dynamic.loading.ClassLoadingStrategy; import net.bytebuddy.implementation.FixedValue; import net.bytebuddy.matcher.ElementMatchers; @@ -42,7 +42,8 @@ public class MyEntityInstantiator implements Instantiator { .method( ElementMatchers.named( "toString" ) ) .intercept( FixedValue.value( "transformed" ) ) .make() - .load( entityClass.getClassLoader(), ClassLoadingStrategy.Default.INJECTION ) + // we use our internal helper to get a class loading strategy suitable for the JDK used + .load( entityClass.getClassLoader(), ByteBuddyState.resolveClassLoadingStrategy( entityClass ) ) .getLoaded(); try {