HHH-12610 Upgrade to Byte Buddy 1.8.11 to improve JDK compatibility

This commit is contained in:
Sanne Grinovero 2018-05-21 16:39:22 +01:00
parent 89305c994e
commit 2d55060ff6
5 changed files with 15 additions and 5 deletions

View File

@ -22,7 +22,7 @@ ext {
weldVersion = '3.0.0.Final'
javassistVersion = '3.22.0-GA'
byteBuddyVersion = '1.8.0' // Now with JDK10 compatibility and preliminary support for JDK11
byteBuddyVersion = '1.8.11' // Now with JDK10 compatibility and preliminary support for JDK11
geolatteVersion = '1.3.0'

View File

@ -55,7 +55,7 @@ public class BasicProxyFactoryImpl implements BasicProxyFactory {
.implement( ProxyConfiguration.class )
.intercept( FieldAccessor.ofField( ProxyConfiguration.INTERCEPTOR_FIELD_NAME ).withAssigner( Assigner.DEFAULT, Assigner.Typing.DYNAMIC ) )
.make()
.load( BasicProxyFactory.class.getClassLoader() )
.load( BasicProxyFactory.class.getClassLoader(), ByteBuddyState.getLoadingStrategy() )
.getLoaded();
}

View File

@ -8,6 +8,7 @@ package org.hibernate.bytecode.internal.bytebuddy;
import net.bytebuddy.ByteBuddy;
import net.bytebuddy.TypeCache;
import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
import net.bytebuddy.dynamic.scaffold.TypeValidation;
/**
@ -23,6 +24,11 @@ public final class ByteBuddyState {
*/
private static final ByteBuddy buddy = new ByteBuddy().with( TypeValidation.DISABLED );
/**
* This will need to change depending on the runtime JDK.
*/
private static final ClassLoadingStrategy loadingStrategy = new ClassLoadingStrategy.ForUnsafeInjection();
/**
* This currently needs to be static: the BytecodeProvider is a static field of Environment and
* is being accessed from static methods.
@ -75,4 +81,8 @@ public final class ByteBuddyState {
return buddy;
}
public static ClassLoadingStrategy getLoadingStrategy() {
return loadingStrategy;
}
}

View File

@ -67,7 +67,7 @@ public class BytecodeProviderImpl implements BytecodeProvider {
.method( newInstanceMethodName )
.intercept( MethodCall.construct( constructor ) )
.make()
.load( clazz.getClassLoader() )
.load( clazz.getClassLoader(), ByteBuddyState.getLoadingStrategy() )
.getLoaded();
final Class bulkAccessor = bytebuddy.getCurrentyByteBuddy()
@ -80,7 +80,7 @@ public class BytecodeProviderImpl implements BytecodeProvider {
.method( getPropertyNamesMethodName )
.intercept( MethodCall.call( new CloningPropertyCall( getterNames ) ) )
.make()
.load( clazz.getClassLoader() )
.load( clazz.getClassLoader(), ByteBuddyState.getLoadingStrategy() )
.getLoaded();
try {

View File

@ -113,7 +113,7 @@ public class ByteBuddyProxyFactory implements ProxyFactory, Serializable {
.implement( ProxyConfiguration.class )
.intercept( FieldAccessor.ofField( ProxyConfiguration.INTERCEPTOR_FIELD_NAME ).withAssigner( Assigner.DEFAULT, Assigner.Typing.DYNAMIC ) )
.make()
.load( persistentClass.getClassLoader() )
.load( persistentClass.getClassLoader(), ByteBuddyState.getLoadingStrategy() )
.getLoaded(), cacheForProxies );
}