HHH-12800 Use a class loading strategy suitable for the JDK used
The previously chosen strategy used misc.Unsafe which is not possible anymore with JDK 11.
This commit is contained in:
parent
9202a5a11d
commit
5ec70ec22e
|
@ -91,7 +91,7 @@ public final class ByteBuddyState {
|
|||
return buddy;
|
||||
}
|
||||
|
||||
public static ClassLoadingStrategy<?> resolveClassLoadingStrategy(Class<?> originalClass) {
|
||||
public static ClassLoadingStrategy<ClassLoader> resolveClassLoadingStrategy(Class<?> originalClass) {
|
||||
if ( ClassInjector.UsingLookup.isAvailable() ) {
|
||||
// This is only enabled for JDK 9+
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue