Use replacement for Class.newInstance().
It is deprecated as of Java 9, and the replacement is valid for older JVMs.
This commit is contained in:
@@ -63,7 +63,7 @@ public class LiaisonRegistry
|
|||||||
{
|
{
|
||||||
// create a new instance and stick it on our list
|
// create a new instance and stick it on our list
|
||||||
try {
|
try {
|
||||||
_liaisons.add(lclass.newInstance());
|
_liaisons.add(lclass.getDeclaredConstructor().newInstance());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("Unable to instantiate liaison", "class", lclass.getName(), "error", e);
|
log.warning("Unable to instantiate liaison", "class", lclass.getName(), "error", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,7 +243,8 @@ public class StaticConnectionProvider implements ConnectionProvider
|
|||||||
// create an instance of the driver
|
// create an instance of the driver
|
||||||
Driver jdriver;
|
Driver jdriver;
|
||||||
try {
|
try {
|
||||||
jdriver = (Driver)Class.forName(_info.driver).newInstance();
|
jdriver = (Driver)Class.forName(_info.driver).
|
||||||
|
getDeclaredConstructor().newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new PersistenceException(
|
throw new PersistenceException(
|
||||||
"Error loading driver [class=" + _info.driver + "].", e);
|
"Error loading driver [class=" + _info.driver + "].", e);
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class AttachableURLFactory implements URLStreamHandlerFactory
|
|||||||
Class<? extends URLStreamHandler> handler = _handlers.get(protocol.toLowerCase());
|
Class<? extends URLStreamHandler> handler = _handlers.get(protocol.toLowerCase());
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
try {
|
try {
|
||||||
return handler.newInstance();
|
return handler.getDeclaredConstructor().newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("Unable to instantiate URLStreamHandler", "protocol", protocol,
|
log.warning("Unable to instantiate URLStreamHandler", "protocol", protocol,
|
||||||
"cause", e);
|
"cause", e);
|
||||||
|
|||||||
@@ -336,7 +336,7 @@ public class Config
|
|||||||
public Object instantiateValue (String name, String defcname)
|
public Object instantiateValue (String name, String defcname)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
return Class.forName(getValue(name, defcname)).newInstance();
|
return Class.forName(getValue(name, defcname)).getDeclaredConstructor().newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ public final class Log
|
|||||||
provider = System.getProperty("log_provider");
|
provider = System.getProperty("log_provider");
|
||||||
if (provider != null) {
|
if (provider != null) {
|
||||||
Class<?> lpclass = Class.forName(provider);
|
Class<?> lpclass = Class.forName(provider);
|
||||||
_provider = (LogProvider)lpclass.newInstance();
|
_provider = (LogProvider)lpclass.getDeclaredConstructor().newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SecurityException se) {
|
} catch (SecurityException se) {
|
||||||
|
|||||||
@@ -170,7 +170,8 @@ public abstract class Logger
|
|||||||
// create and a log4j logger if the log4j configuration system property is set
|
// create and a log4j logger if the log4j configuration system property is set
|
||||||
try {
|
try {
|
||||||
if (factory == null && System.getProperty("log4j.configuration") != null) {
|
if (factory == null && System.getProperty("log4j.configuration") != null) {
|
||||||
factory = (Factory)Class.forName("com.samskivert.util.Log4JLogger").newInstance();
|
factory = (Factory)Class.forName("com.samskivert.util.Log4JLogger").
|
||||||
|
getDeclaredConstructor().newInstance();
|
||||||
}
|
}
|
||||||
} catch (SecurityException se) {
|
} catch (SecurityException se) {
|
||||||
// in a sandbox, no biggie
|
// in a sandbox, no biggie
|
||||||
@@ -181,7 +182,8 @@ public abstract class Logger
|
|||||||
// create and a log4j2 logger if the log4j2 configuration system property is set
|
// create and a log4j2 logger if the log4j2 configuration system property is set
|
||||||
try {
|
try {
|
||||||
if (factory == null && System.getProperty("log4j.configurationFile") != null) {
|
if (factory == null && System.getProperty("log4j.configurationFile") != null) {
|
||||||
factory = (Factory)Class.forName("com.samskivert.util.Log4J2Logger").newInstance();
|
factory = (Factory)Class.forName("com.samskivert.util.Log4J2Logger").
|
||||||
|
getDeclaredConstructor().newInstance();
|
||||||
}
|
}
|
||||||
} catch (SecurityException se) {
|
} catch (SecurityException se) {
|
||||||
// in a sandbox, no biggie
|
// in a sandbox, no biggie
|
||||||
@@ -212,7 +214,7 @@ public abstract class Logger
|
|||||||
}
|
}
|
||||||
if (!StringUtil.isBlank(implClass)) {
|
if (!StringUtil.isBlank(implClass)) {
|
||||||
try {
|
try {
|
||||||
return (Factory)Class.forName(implClass).newInstance();
|
return (Factory)Class.forName(implClass).getDeclaredConstructor().newInstance();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
System.err.println("Unable to instantiate logging implementation: " + implClass);
|
System.err.println("Unable to instantiate logging implementation: " + implClass);
|
||||||
t.printStackTrace(System.err);
|
t.printStackTrace(System.err);
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ public class DispatcherServlet extends HttpServlet
|
|||||||
return new Application();
|
return new Application();
|
||||||
} else {
|
} else {
|
||||||
Class<?> appclass = Class.forName(appcl);
|
Class<?> appclass = Class.forName(appcl);
|
||||||
return (Application)appclass.newInstance();
|
return (Application)appclass.getDeclaredConstructor().newInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,7 +597,7 @@ public class DispatcherServlet extends HttpServlet
|
|||||||
protected Logic instantiateLogic (String path, String lclass) {
|
protected Logic instantiateLogic (String path, String lclass) {
|
||||||
try {
|
try {
|
||||||
Class<?> pcl = Class.forName(lclass);
|
Class<?> pcl = Class.forName(lclass);
|
||||||
return (Logic)pcl.newInstance();
|
return (Logic)pcl.getDeclaredConstructor().newInstance();
|
||||||
} catch (ClassNotFoundException cnfe) {
|
} catch (ClassNotFoundException cnfe) {
|
||||||
// nothing interesting to report
|
// nothing interesting to report
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user