diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/bytebuddy/BasicProxyFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/bytebuddy/BasicProxyFactoryImpl.java index eae143eb67..a2004408e5 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/bytebuddy/BasicProxyFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/bytebuddy/BasicProxyFactoryImpl.java @@ -6,6 +6,7 @@ */ package org.hibernate.bytecode.internal.bytebuddy; +import java.lang.reflect.Constructor; import java.util.Arrays; import java.util.HashSet; import java.util.Set; @@ -28,6 +29,7 @@ public class BasicProxyFactoryImpl implements BasicProxyFactory { private final Class proxyClass; private final ProxyConfiguration.Interceptor interceptor; + private final Constructor proxyClassConstructor; @SuppressWarnings({ "unchecked", "rawtypes" }) public BasicProxyFactoryImpl(Class superClass, Class[] interfaces, ByteBuddyState byteBuddyState) { @@ -49,12 +51,18 @@ public class BasicProxyFactoryImpl implements BasicProxyFactory { .intercept( byteBuddyState.getProxyDefinitionHelpers().getInterceptorFieldAccessor() ) ); this.interceptor = new PassThroughInterceptor( proxyClass.getName() ); + try { + proxyClassConstructor = proxyClass.getConstructor(); + } + catch (NoSuchMethodException e) { + throw new AssertionFailure( "Could not access default constructor from newly generated basic proxy" ); + } } @Override public Object getProxy() { try { - final ProxyConfiguration proxy = (ProxyConfiguration) proxyClass.newInstance(); + final ProxyConfiguration proxy = (ProxyConfiguration) proxyClassConstructor.newInstance(); proxy.$$_hibernate_set_interceptor( this.interceptor ); return proxy; }