Applied fix from trunk for revision: 1854683
=== Preparation for JDK11 update, Updated following code to fix warning with respect to JDK11 - Replaced Class::newInstance occurrences - Removed deprecated override method Object::finalize (OFBIZ-10757) git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release18.12@1854689 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -154,10 +154,10 @@ public abstract class ResourceLoader {
|
||||
Class<?> lClass = null;
|
||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||
lClass = classLoader.loadClass(className);
|
||||
loader = (ResourceLoader) lClass.newInstance();
|
||||
loader = (ResourceLoader) lClass.getDeclaredConstructor().newInstance();
|
||||
loader.init(loaderName, loaderElement.getAttribute("prefix"), loaderElement.getAttribute("prepend-env"));
|
||||
return loader;
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new GenericConfigException("Exception thrown while loading ResourceLoader class \"" + className
|
||||
+ "\" ", e);
|
||||
}
|
||||
|
||||
@@ -122,8 +122,8 @@ public class ContainerLoader implements StartupLoader {
|
||||
// create a new instance of the container object
|
||||
Container containerObj;
|
||||
try {
|
||||
containerObj = (Container) containerClass.newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
containerObj = (Container) containerClass.getDeclaredConstructor().newInstance();
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new StartupException("Cannot create " + containerCfg.name, e);
|
||||
}
|
||||
if (containerObj == null) {
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class FlexibleLocation {
|
||||
String locationType = (String) entry.getKey();
|
||||
String locationResolverName = (String) entry.getValue();
|
||||
Class<?> lClass = classLoader.loadClass(locationResolverName);
|
||||
resolverMap.put(locationType, (LocationResolver) lClass.newInstance());
|
||||
resolverMap.put(locationType, (LocationResolver) lClass.getDeclaredConstructor().newInstance());
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
|
||||
@@ -156,11 +156,13 @@ public class ObjectType {
|
||||
* @throws ClassNotFoundException
|
||||
* @throws InstantiationException
|
||||
* @throws IllegalAccessException
|
||||
* @throws NoSuchMethodException
|
||||
* @throws InvocationTargetException,
|
||||
*/
|
||||
public static Object getInstance(String className) throws ClassNotFoundException,
|
||||
InstantiationException, IllegalAccessException {
|
||||
public static Object getInstance(String className) throws ClassNotFoundException, InstantiationException,
|
||||
IllegalAccessException, NoSuchMethodException, InvocationTargetException {
|
||||
Class<?> c = loadClass(className);
|
||||
Object o = c.newInstance();
|
||||
Object o = c.getDeclaredConstructor().newInstance();
|
||||
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Instantiated object: " + o.toString(), module);
|
||||
|
||||
-8
@@ -39,12 +39,4 @@ public abstract class CacheSoftReference<V> extends ReferenceCleaner.Soft<V> imp
|
||||
}
|
||||
super.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose(new Exception("UtilCache.CacheSoftRef.finalize()"), "Finalize UtilCache SoftReference - " + get(), module);
|
||||
}
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ public final class FreeMarkerWorker {
|
||||
Debug.logVerbose("Adding FTL Transform " + key + " with class " + className, module);
|
||||
}
|
||||
try {
|
||||
config.setSharedVariable(key, loader.loadClass(className).newInstance());
|
||||
config.setSharedVariable(key, loader.loadClass(className).getDeclaredConstructor().newInstance());
|
||||
} catch (Exception e) {
|
||||
Debug.logError(e, "Could not pre-initialize dynamically loaded class: " + className + ": " + e, module);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user