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
7e69797a45
commit
9d36d1d91f
|
@ -91,7 +91,7 @@ public final class ByteBuddyState {
|
||||||
return buddy;
|
return buddy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ClassLoadingStrategy<?> resolveClassLoadingStrategy(Class<?> originalClass) {
|
public static ClassLoadingStrategy<ClassLoader> resolveClassLoadingStrategy(Class<?> originalClass) {
|
||||||
if ( ClassInjector.UsingLookup.isAvailable() ) {
|
if ( ClassInjector.UsingLookup.isAvailable() ) {
|
||||||
// This is only enabled for JDK 9+
|
// This is only enabled for JDK 9+
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,11 @@ package org.hibernate.test.annotations.tuplizer.bytebuddysubclass;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.tuple.Instantiator;
|
import org.hibernate.tuple.Instantiator;
|
||||||
|
|
||||||
import net.bytebuddy.ByteBuddy;
|
import net.bytebuddy.ByteBuddy;
|
||||||
import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
|
|
||||||
import net.bytebuddy.implementation.FixedValue;
|
import net.bytebuddy.implementation.FixedValue;
|
||||||
import net.bytebuddy.matcher.ElementMatchers;
|
import net.bytebuddy.matcher.ElementMatchers;
|
||||||
|
|
||||||
|
@ -42,7 +42,8 @@ public class MyEntityInstantiator implements Instantiator {
|
||||||
.method( ElementMatchers.named( "toString" ) )
|
.method( ElementMatchers.named( "toString" ) )
|
||||||
.intercept( FixedValue.value( "transformed" ) )
|
.intercept( FixedValue.value( "transformed" ) )
|
||||||
.make()
|
.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();
|
.getLoaded();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue