Skip to content
Permalink
Browse files

Improved: Do not use deprecated ‘Proxyclass#getConstructor’

(OFBIZ-11262)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1869007 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Oct 26, 2019
1 parent 81be0b8 commit 8f9fa569e09161426a27602967a12ab0bbb4ca6b
@@ -18,7 +18,6 @@
*******************************************************************************/
package org.apache.ofbiz.entity.jdbc;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -60,9 +59,9 @@ protected Object invoke(Object obj, Object proxy, Method method, Object... args)

protected static <T> T newHandler(InvocationHandler handler, Class<T> implClass) throws IllegalAccessException, IllegalArgumentException, InstantiationException, InvocationTargetException, NoSuchMethodException, SecurityException {
ClassLoader loader = implClass.getClassLoader();
if (loader == null) loader = ClassLoader.getSystemClassLoader();
Class<?> proxyClass = Proxy.getProxyClass(loader, implClass);
Constructor<?> constructor = proxyClass.getConstructor(InvocationHandler.class);
return implClass.cast(constructor.newInstance(handler));
if (loader == null) {
loader = ClassLoader.getSystemClassLoader();
}
return implClass.cast(Proxy.newProxyInstance(loader, new Class<?>[] {implClass}, handler));
}
}

0 comments on commit 8f9fa56

Please sign in to comment.
You can’t perform that action at this time.