mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-09 12:44:49 +00:00
HHH-14385 Allow specifying a target JVM version for compatibility of generated proxies via ByteBuddy
This commit is contained in:
parent
9c69ddc8f1
commit
016625eb5d
@ -30,6 +30,7 @@
|
|||||||
import org.hibernate.proxy.ProxyFactory;
|
import org.hibernate.proxy.ProxyFactory;
|
||||||
|
|
||||||
import net.bytebuddy.ByteBuddy;
|
import net.bytebuddy.ByteBuddy;
|
||||||
|
import net.bytebuddy.ClassFileVersion;
|
||||||
import net.bytebuddy.TypeCache;
|
import net.bytebuddy.TypeCache;
|
||||||
import net.bytebuddy.asm.AsmVisitorWrapper.ForDeclaredMethods;
|
import net.bytebuddy.asm.AsmVisitorWrapper.ForDeclaredMethods;
|
||||||
import net.bytebuddy.asm.MemberSubstitution;
|
import net.bytebuddy.asm.MemberSubstitution;
|
||||||
@ -71,7 +72,11 @@ public final class ByteBuddyState {
|
|||||||
private final TypeCache<TypeCache.SimpleKey> basicProxyCache;
|
private final TypeCache<TypeCache.SimpleKey> basicProxyCache;
|
||||||
|
|
||||||
ByteBuddyState() {
|
ByteBuddyState() {
|
||||||
this.byteBuddy = new ByteBuddy().with( TypeValidation.DISABLED );
|
this( ClassFileVersion.ofThisVm( ClassFileVersion.JAVA_V8 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteBuddyState(ClassFileVersion classFileVersion) {
|
||||||
|
this.byteBuddy = new ByteBuddy( classFileVersion ).with( TypeValidation.DISABLED );
|
||||||
|
|
||||||
this.proxyCache = new TypeCache.WithInlineExpunction<TypeCache.SimpleKey>( TypeCache.Sort.WEAK );
|
this.proxyCache = new TypeCache.WithInlineExpunction<TypeCache.SimpleKey>( TypeCache.Sort.WEAK );
|
||||||
this.basicProxyCache = new TypeCache.WithInlineExpunction<TypeCache.SimpleKey>( TypeCache.Sort.WEAK );
|
this.basicProxyCache = new TypeCache.WithInlineExpunction<TypeCache.SimpleKey>( TypeCache.Sort.WEAK );
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
import org.hibernate.bytecode.spi.ReflectionOptimizer;
|
import org.hibernate.bytecode.spi.ReflectionOptimizer;
|
||||||
import org.hibernate.proxy.pojo.bytebuddy.ByteBuddyProxyHelper;
|
import org.hibernate.proxy.pojo.bytebuddy.ByteBuddyProxyHelper;
|
||||||
|
|
||||||
|
import net.bytebuddy.ClassFileVersion;
|
||||||
import net.bytebuddy.NamingStrategy;
|
import net.bytebuddy.NamingStrategy;
|
||||||
import net.bytebuddy.description.method.MethodDescription;
|
import net.bytebuddy.description.method.MethodDescription;
|
||||||
import net.bytebuddy.description.type.TypeDescription;
|
import net.bytebuddy.description.type.TypeDescription;
|
||||||
@ -49,8 +50,21 @@ public class BytecodeProviderImpl implements BytecodeProvider {
|
|||||||
|
|
||||||
private final ByteBuddyProxyHelper byteBuddyProxyHelper;
|
private final ByteBuddyProxyHelper byteBuddyProxyHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a ByteBuddy BytecodeProvider instance which attempts to auto-detect the target JVM version
|
||||||
|
* from the currently running one, with a fallback on Java 8.
|
||||||
|
*/
|
||||||
public BytecodeProviderImpl() {
|
public BytecodeProviderImpl() {
|
||||||
this.byteBuddyState = new ByteBuddyState();
|
this( ClassFileVersion.ofThisVm( ClassFileVersion.JAVA_V8 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a ByteBuddy BytecodeProvider instance which aims to produce code compatible
|
||||||
|
* with the specified target JVM version.
|
||||||
|
* @param targetCompatibleJVM
|
||||||
|
*/
|
||||||
|
public BytecodeProviderImpl(ClassFileVersion targetCompatibleJVM) {
|
||||||
|
this.byteBuddyState = new ByteBuddyState( targetCompatibleJVM );
|
||||||
this.byteBuddyProxyHelper = new ByteBuddyProxyHelper( byteBuddyState );
|
this.byteBuddyProxyHelper = new ByteBuddyProxyHelper( byteBuddyState );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user