6850612: Deprecate Class.newInstance since it violates the checked exception language contract
Reviewed-by: lancea, mullan, dfuchs
This commit is contained in:
parent
e8cd76568d
commit
01ee88c8ae
@ -470,7 +470,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||
* expression with an empty argument list. The class is initialized if it
|
||||
* has not already been initialized.
|
||||
*
|
||||
* <p>Note that this method propagates any exception thrown by the
|
||||
* @deprecated This method propagates any exception thrown by the
|
||||
* nullary constructor, including a checked exception. Use of
|
||||
* this method effectively bypasses the compile-time exception
|
||||
* checking that would otherwise be performed by the compiler.
|
||||
@ -500,6 +500,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||
* of this class.
|
||||
*/
|
||||
@CallerSensitive
|
||||
@Deprecated(since="9")
|
||||
public T newInstance()
|
||||
throws InstantiationException, IllegalAccessException
|
||||
{
|
||||
|
@ -1645,7 +1645,9 @@ class InetAddress implements java.io.Serializable {
|
||||
*/
|
||||
String prefix = GetPropertyAction.privilegedGetProperty("impl.prefix", "");
|
||||
try {
|
||||
impl = Class.forName("java.net." + prefix + implName).newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = Class.forName("java.net." + prefix + implName).newInstance();
|
||||
impl = tmp;
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.err.println("Class not found: java.net." + prefix +
|
||||
implName + ":\ncheck impl.prefix property " +
|
||||
@ -1662,7 +1664,9 @@ class InetAddress implements java.io.Serializable {
|
||||
|
||||
if (impl == null) {
|
||||
try {
|
||||
impl = Class.forName(implName).newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = Class.forName(implName).newInstance();
|
||||
impl = tmp;
|
||||
} catch (Exception e) {
|
||||
throw new Error("System property impl.prefix incorrect");
|
||||
}
|
||||
|
@ -71,7 +71,9 @@ public abstract class ProxySelector {
|
||||
try {
|
||||
Class<?> c = Class.forName("sun.net.spi.DefaultProxySelector");
|
||||
if (c != null && ProxySelector.class.isAssignableFrom(c)) {
|
||||
theProxySelector = (ProxySelector) c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
ProxySelector tmp = (ProxySelector) c.newInstance();
|
||||
theProxySelector = tmp;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
theProxySelector = null;
|
||||
|
@ -1198,8 +1198,9 @@ public final class URL implements java.io.Serializable {
|
||||
public URLStreamHandler createURLStreamHandler(String protocol) {
|
||||
String name = PREFIX + "." + protocol + ".Handler";
|
||||
try {
|
||||
Class<?> c = Class.forName(name);
|
||||
return (URLStreamHandler)c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = Class.forName(name).newInstance();
|
||||
return (URLStreamHandler)o;
|
||||
} catch (ClassNotFoundException x) {
|
||||
// ignore
|
||||
} catch (Exception e) {
|
||||
@ -1234,7 +1235,9 @@ public final class URL implements java.io.Serializable {
|
||||
}
|
||||
}
|
||||
if (cls != null) {
|
||||
handler = (URLStreamHandler)cls.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = cls.newInstance();
|
||||
handler = (URLStreamHandler)tmp;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// any number of exceptions can get thrown here
|
||||
|
@ -1323,7 +1323,9 @@ public abstract class URLConnection {
|
||||
}
|
||||
}
|
||||
if (cls != null) {
|
||||
return (ContentHandler) cls.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = cls.newInstance();
|
||||
return (ContentHandler) tmp;
|
||||
}
|
||||
} catch(Exception ignored) { }
|
||||
}
|
||||
|
@ -94,9 +94,10 @@ public abstract class AsynchronousChannelProvider {
|
||||
if (cn == null)
|
||||
return null;
|
||||
try {
|
||||
Class<?> c = Class.forName(cn, true,
|
||||
ClassLoader.getSystemClassLoader());
|
||||
return (AsynchronousChannelProvider)c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = Class.forName(cn, true,
|
||||
ClassLoader.getSystemClassLoader()).newInstance();
|
||||
return (AsynchronousChannelProvider)tmp;
|
||||
} catch (ClassNotFoundException x) {
|
||||
throw new ServiceConfigurationError(null, x);
|
||||
} catch (IllegalAccessException x) {
|
||||
|
@ -95,9 +95,10 @@ public abstract class SelectorProvider {
|
||||
if (cn == null)
|
||||
return false;
|
||||
try {
|
||||
Class<?> c = Class.forName(cn, true,
|
||||
ClassLoader.getSystemClassLoader());
|
||||
provider = (SelectorProvider)c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = Class.forName(cn, true,
|
||||
ClassLoader.getSystemClassLoader()).newInstance();
|
||||
provider = (SelectorProvider)tmp;
|
||||
return true;
|
||||
} catch (ClassNotFoundException x) {
|
||||
throw new ServiceConfigurationError(null, x);
|
||||
|
@ -222,8 +222,9 @@ public abstract class Policy {
|
||||
public Policy run() {
|
||||
try {
|
||||
ClassLoader scl = ClassLoader.getSystemClassLoader();
|
||||
Class<?> c = Class.forName(policyProvider, true, scl);
|
||||
return (Policy)c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = Class.forName(policyProvider, true, scl).newInstance();
|
||||
return (Policy)o;
|
||||
} catch (Exception e) {
|
||||
if (debug != null) {
|
||||
debug.println("policy provider " + policyProvider +
|
||||
|
@ -147,6 +147,7 @@ public abstract class ZoneRulesProvider {
|
||||
if (prop != null) {
|
||||
try {
|
||||
Class<?> c = Class.forName(prop, true, ClassLoader.getSystemClassLoader());
|
||||
@SuppressWarnings("deprecation")
|
||||
ZoneRulesProvider provider = ZoneRulesProvider.class.cast(c.newInstance());
|
||||
registerProvider(provider);
|
||||
loaded.add(provider);
|
||||
|
@ -811,7 +811,9 @@ public final class ServiceLoader<S>
|
||||
}
|
||||
S p = null;
|
||||
try {
|
||||
p = service.cast(c.newInstance());
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = c.newInstance();
|
||||
p = service.cast(tmp);
|
||||
} catch (Throwable x) {
|
||||
fail(service,
|
||||
"Provider " + cn + " could not be instantiated",
|
||||
|
@ -3507,6 +3507,7 @@ public class ForkJoinPool extends AbstractExecutorService {
|
||||
* Creates and returns the common pool, respecting user settings
|
||||
* specified via system properties.
|
||||
*/
|
||||
@SuppressWarnings("deprecation") // Class.newInstance
|
||||
static ForkJoinPool makeCommonPool() {
|
||||
int parallelism = -1;
|
||||
ForkJoinWorkerThreadFactory factory = null;
|
||||
|
@ -704,7 +704,9 @@ public abstract class Pack200 {
|
||||
impl = com.sun.java.util.jar.pack.UnpackerImpl.class;
|
||||
}
|
||||
// We have a class. Now instantiate it.
|
||||
return impl.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object result = impl.newInstance();
|
||||
return result;
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new Error("Class not found: " + implName +
|
||||
":\ncheck property " + prop +
|
||||
|
@ -97,6 +97,7 @@ public abstract class SSLServerSocketFactory extends ServerSocketFactory
|
||||
}
|
||||
}
|
||||
log("class " + clsName + " is loaded");
|
||||
@SuppressWarnings("deprecation")
|
||||
SSLServerSocketFactory fac = (SSLServerSocketFactory)cls.newInstance();
|
||||
log("instantiated an instance of class " + clsName);
|
||||
theFactory = fac;
|
||||
|
@ -106,6 +106,7 @@ public abstract class SSLSocketFactory extends SocketFactory
|
||||
}
|
||||
}
|
||||
log("class " + clsName + " is loaded");
|
||||
@SuppressWarnings("deprecation")
|
||||
SSLSocketFactory fac = (SSLSocketFactory)cls.newInstance();
|
||||
log("instantiated an instance of class " + clsName);
|
||||
theFactory = fac;
|
||||
|
@ -250,7 +250,9 @@ public abstract class Configuration {
|
||||
finalClass, false,
|
||||
Thread.currentThread().getContextClassLoader()
|
||||
).asSubclass(Configuration.class);
|
||||
return implClass.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Configuration result = implClass.newInstance();
|
||||
return result;
|
||||
}
|
||||
});
|
||||
AccessController.doPrivileged(
|
||||
|
@ -304,7 +304,9 @@ public class LoginContext {
|
||||
Class<? extends CallbackHandler> c = Class.forName(
|
||||
defaultHandler, true,
|
||||
finalLoader).asSubclass(CallbackHandler.class);
|
||||
return c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
CallbackHandler result = c.newInstance();
|
||||
return result;
|
||||
}
|
||||
});
|
||||
} catch (java.security.PrivilegedActionException pae) {
|
||||
@ -697,8 +699,9 @@ public class LoginContext {
|
||||
|
||||
if (moduleStack[i].module == null) {
|
||||
try {
|
||||
moduleStack[i].module = (LoginModule) Class.forName(
|
||||
name, false, contextClassLoader).newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = Class.forName(name, false, contextClassLoader).newInstance();
|
||||
moduleStack[i].module = (LoginModule) tmp;
|
||||
if (debug != null) {
|
||||
debug.println(name + " loaded via reflection");
|
||||
}
|
||||
|
@ -124,7 +124,9 @@ public final class JrtFileSystemProvider extends FileSystemProvider {
|
||||
ClassLoader cl = newJrtFsLoader(jrtfs);
|
||||
try {
|
||||
Class<?> c = Class.forName(JrtFileSystemProvider.class.getName(), false, cl);
|
||||
return ((FileSystemProvider)c.newInstance()).newFileSystem(uri, newEnv);
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = c.newInstance();
|
||||
return ((FileSystemProvider)tmp).newFileSystem(uri, newEnv);
|
||||
} catch (ClassNotFoundException |
|
||||
IllegalAccessException |
|
||||
InstantiationException e) {
|
||||
|
@ -392,6 +392,7 @@ class MethodAccessorGenerator extends AccessorGenerator {
|
||||
// matter.
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<MagicAccessorImpl>() {
|
||||
@SuppressWarnings("deprecation") // Class.newInstance
|
||||
public MagicAccessorImpl run() {
|
||||
try {
|
||||
return (MagicAccessorImpl)
|
||||
|
@ -67,8 +67,9 @@ public abstract class FtpClientProvider {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Class<?> c = Class.forName(cm, true, null);
|
||||
provider = (FtpClientProvider) c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = Class.forName(cm, true, null).newInstance();
|
||||
provider = (FtpClientProvider)o;
|
||||
return true;
|
||||
} catch (ClassNotFoundException |
|
||||
IllegalAccessException |
|
||||
|
@ -165,14 +165,11 @@ public class ThreadPool {
|
||||
GetPropertyAction(DEFAULT_THREAD_POOL_THREAD_FACTORY));
|
||||
if (propValue != null) {
|
||||
try {
|
||||
Class<?> c = Class
|
||||
.forName(propValue, true, ClassLoader.getSystemClassLoader());
|
||||
return ((ThreadFactory)c.newInstance());
|
||||
} catch (ClassNotFoundException x) {
|
||||
throw new Error(x);
|
||||
} catch (InstantiationException x) {
|
||||
throw new Error(x);
|
||||
} catch (IllegalAccessException x) {
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = Class
|
||||
.forName(propValue, true, ClassLoader.getSystemClassLoader()).newInstance();
|
||||
return (ThreadFactory)tmp;
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException x) {
|
||||
throw new Error(x);
|
||||
}
|
||||
}
|
||||
|
@ -115,10 +115,11 @@ public class FastCharsetProvider
|
||||
|
||||
// Instantiate the charset and cache it
|
||||
try {
|
||||
Class<?> c = Class.forName(packagePrefix + "." + cln,
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o= Class.forName(packagePrefix + "." + cln,
|
||||
true,
|
||||
this.getClass().getClassLoader());
|
||||
cs = (Charset)c.newInstance();
|
||||
this.getClass().getClassLoader()).newInstance();
|
||||
cs = (Charset)o;
|
||||
cache.put(csn, cs);
|
||||
return cs;
|
||||
} catch (ClassNotFoundException |
|
||||
|
@ -110,10 +110,11 @@ public class StandardCharsets extends CharsetProvider {
|
||||
|
||||
// Instantiate the charset and cache it
|
||||
try {
|
||||
Class<?> c = Class.forName(packagePrefix + "." + cln,
|
||||
true,
|
||||
this.getClass().getClassLoader());
|
||||
cs = (Charset)c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = Class.forName(packagePrefix + "." + cln,
|
||||
true,
|
||||
this.getClass().getClassLoader()).newInstance();
|
||||
cs = (Charset)o;
|
||||
cache.put(csn, cs);
|
||||
return cs;
|
||||
} catch (ClassNotFoundException |
|
||||
|
@ -185,7 +185,9 @@ final class ProviderConfig {
|
||||
try {
|
||||
Class<?> c = Class.forName("apple.security.AppleProvider");
|
||||
if (Provider.class.isAssignableFrom(c)) {
|
||||
return (Provider) c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = c.newInstance();
|
||||
return (Provider) tmp;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -386,6 +388,7 @@ final class ProviderConfig {
|
||||
|
||||
Provider p = AccessController.doPrivileged
|
||||
(new PrivilegedExceptionAction<Provider>() {
|
||||
@SuppressWarnings("deprecation") // Class.newInstance
|
||||
public Provider run() throws Exception {
|
||||
return (Provider) provClass.newInstance();
|
||||
}
|
||||
|
@ -218,11 +218,10 @@ public class PKCS8Key implements PrivateKey {
|
||||
}
|
||||
}
|
||||
|
||||
Object inst = null;
|
||||
@SuppressWarnings("deprecation")
|
||||
Object inst = (keyClass != null) ? keyClass.newInstance() : null;
|
||||
PKCS8Key result;
|
||||
|
||||
if (keyClass != null)
|
||||
inst = keyClass.newInstance();
|
||||
if (inst instanceof PKCS8Key) {
|
||||
result = (PKCS8Key) inst;
|
||||
result.algid = algid;
|
||||
|
@ -728,6 +728,7 @@ public final class Main {
|
||||
provClass = Class.forName(provName);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Object obj = provClass.newInstance();
|
||||
if (!(obj instanceof Provider)) {
|
||||
MessageFormat form = new MessageFormat
|
||||
|
@ -196,8 +196,9 @@ public class KeyStoreDelegator extends KeyStoreSpi {
|
||||
// A new keystore is always created in the primary keystore format
|
||||
if (stream == null) {
|
||||
try {
|
||||
keystore = primaryKeyStore.newInstance();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
KeyStoreSpi tmp = primaryKeyStore.newInstance();
|
||||
keystore = tmp;
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
// can safely ignore
|
||||
}
|
||||
@ -214,7 +215,9 @@ public class KeyStoreDelegator extends KeyStoreSpi {
|
||||
bufferedStream.mark(Integer.MAX_VALUE);
|
||||
|
||||
try {
|
||||
keystore = primaryKeyStore.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
KeyStoreSpi tmp = primaryKeyStore.newInstance();
|
||||
keystore = tmp;
|
||||
type = primaryType;
|
||||
keystore.engineLoad(bufferedStream, password);
|
||||
|
||||
@ -232,7 +235,9 @@ public class KeyStoreDelegator extends KeyStoreSpi {
|
||||
throw e;
|
||||
}
|
||||
|
||||
keystore = secondaryKeyStore.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
KeyStoreSpi tmp= secondaryKeyStore.newInstance();
|
||||
keystore = tmp;
|
||||
type = secondaryType;
|
||||
bufferedStream.reset();
|
||||
keystore.engineLoad(bufferedStream, password);
|
||||
@ -284,7 +289,9 @@ public class KeyStoreDelegator extends KeyStoreSpi {
|
||||
boolean result = false;
|
||||
|
||||
try {
|
||||
keystore = primaryKeyStore.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
KeyStoreSpi tmp = primaryKeyStore.newInstance();
|
||||
keystore = tmp;
|
||||
type = primaryType;
|
||||
result = keystore.engineProbe(stream);
|
||||
|
||||
|
@ -255,11 +255,10 @@ public class X509Key implements PublicKey {
|
||||
}
|
||||
}
|
||||
|
||||
Object inst = null;
|
||||
@SuppressWarnings("deprecation")
|
||||
Object inst = (keyClass != null) ? keyClass.newInstance() : null;
|
||||
X509Key result;
|
||||
|
||||
if (keyClass != null)
|
||||
inst = keyClass.newInstance();
|
||||
if (inst instanceof X509Key) {
|
||||
result = (X509Key) inst;
|
||||
result.algid = algid;
|
||||
|
@ -157,8 +157,9 @@ public abstract class CalendarSystem {
|
||||
cal = LocalGregorianCalendar.getLocalGregorianCalendar(calendarName);
|
||||
} else {
|
||||
try {
|
||||
Class<?> cl = Class.forName(className);
|
||||
cal = (CalendarSystem) cl.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = Class.forName(className).newInstance();
|
||||
cal = (CalendarSystem) tmp;
|
||||
} catch (Exception e) {
|
||||
throw new InternalError(e);
|
||||
}
|
||||
|
@ -171,8 +171,9 @@ public abstract class LocaleProviderAdapter {
|
||||
if (cached == null) {
|
||||
try {
|
||||
// lazily load adapters here
|
||||
adapter = (LocaleProviderAdapter)Class.forName(type.getAdapterClassName())
|
||||
.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = Class.forName(type.getAdapterClassName()).newInstance();
|
||||
adapter = (LocaleProviderAdapter)tmp;
|
||||
cached = adapterInstances.putIfAbsent(type, adapter);
|
||||
if (cached != null) {
|
||||
adapter = cached;
|
||||
|
@ -73,7 +73,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
|
||||
try {
|
||||
return AccessController.doPrivileged(new PrivilegedExceptionAction<P>() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings(value={"unchecked", "deprecation"})
|
||||
public P run() {
|
||||
P delegate = null;
|
||||
|
||||
|
@ -61,7 +61,9 @@ class DefaultDatagramSocketImplFactory {
|
||||
throws SocketException {
|
||||
if (prefixImplClass != null) {
|
||||
try {
|
||||
return (DatagramSocketImpl)prefixImplClass.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
DatagramSocketImpl result = (DatagramSocketImpl)prefixImplClass.newInstance();
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
throw new SocketException("can't instantiate DatagramSocketImpl");
|
||||
}
|
||||
|
@ -48,7 +48,9 @@ public class DefaultAsynchronousChannelProvider {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
try {
|
||||
return c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
AsynchronousChannelProvider result = c.newInstance();
|
||||
return result;
|
||||
} catch (IllegalAccessException | InstantiationException x) {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
|
@ -44,7 +44,9 @@ public class DefaultFileSystemProvider {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
try {
|
||||
return c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
FileSystemProvider result = c.newInstance();
|
||||
return result;
|
||||
} catch (IllegalAccessException | InstantiationException x) {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
|
@ -39,7 +39,9 @@ class FilterFactory {
|
||||
List<HeaderFilter> l = new LinkedList<>();
|
||||
for (Class<? extends HeaderFilter> clazz : filterClasses) {
|
||||
try {
|
||||
l.add(clazz.newInstance());
|
||||
@SuppressWarnings("deprecation")
|
||||
HeaderFilter headerFilter = clazz.newInstance();
|
||||
l.add(headerFilter);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new InternalError(e);
|
||||
}
|
||||
|
@ -231,13 +231,15 @@ public class LogManager {
|
||||
cname = System.getProperty("java.util.logging.manager");
|
||||
if (cname != null) {
|
||||
try {
|
||||
Class<?> clz = ClassLoader.getSystemClassLoader()
|
||||
.loadClass(cname);
|
||||
mgr = (LogManager) clz.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = ClassLoader.getSystemClassLoader()
|
||||
.loadClass(cname).newInstance();
|
||||
mgr = (LogManager) tmp;
|
||||
} catch (ClassNotFoundException ex) {
|
||||
Class<?> clz = Thread.currentThread()
|
||||
.getContextClassLoader().loadClass(cname);
|
||||
mgr = (LogManager) clz.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = Thread.currentThread()
|
||||
.getContextClassLoader().loadClass(cname).newInstance();
|
||||
mgr = (LogManager) tmp;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
@ -991,8 +993,9 @@ public class LogManager {
|
||||
List<Handler> handlers = new ArrayList<>(names.length);
|
||||
for (String type : names) {
|
||||
try {
|
||||
Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(type);
|
||||
Handler hdl = (Handler) clz.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = ClassLoader.getSystemClassLoader().loadClass(type).newInstance();
|
||||
Handler hdl = (Handler) o;
|
||||
// Check if there is a property defining the
|
||||
// this handler's level.
|
||||
String levs = getProperty(type + ".level");
|
||||
@ -1330,11 +1333,13 @@ public class LogManager {
|
||||
// calling readConfiguration(InputStream) with a suitable stream.
|
||||
try {
|
||||
Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(cname);
|
||||
clz.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object witness = clz.newInstance();
|
||||
return;
|
||||
} catch (ClassNotFoundException ex) {
|
||||
Class<?> clz = Thread.currentThread().getContextClassLoader().loadClass(cname);
|
||||
clz.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object witness = clz.newInstance();
|
||||
return;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
@ -1561,7 +1566,8 @@ public class LogManager {
|
||||
for (String word : names) {
|
||||
try {
|
||||
Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(word);
|
||||
clz.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object witness = clz.newInstance();
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Can't load config class \"" + word + "\"");
|
||||
System.err.println("" + ex);
|
||||
@ -2307,8 +2313,9 @@ public class LogManager {
|
||||
String val = getProperty(name);
|
||||
try {
|
||||
if (val != null) {
|
||||
Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(val);
|
||||
return (Filter) clz.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = ClassLoader.getSystemClassLoader().loadClass(val).newInstance();
|
||||
return (Filter) o;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// We got one of a variety of exceptions in creating the
|
||||
@ -2328,8 +2335,9 @@ public class LogManager {
|
||||
String val = getProperty(name);
|
||||
try {
|
||||
if (val != null) {
|
||||
Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(val);
|
||||
return (Formatter) clz.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = ClassLoader.getSystemClassLoader().loadClass(val).newInstance();
|
||||
return (Formatter) o;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// We got one of a variety of exceptions in creating the
|
||||
|
@ -117,7 +117,9 @@ public class MemoryHandler extends Handler {
|
||||
Class<?> clz;
|
||||
try {
|
||||
clz = ClassLoader.getSystemClassLoader().loadClass(targetName);
|
||||
target = (Handler) clz.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = clz.newInstance();
|
||||
target = (Handler) o;
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||
throw new RuntimeException("MemoryHandler can't load handler target \"" + targetName + "\"" , e);
|
||||
}
|
||||
|
@ -655,7 +655,9 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory {
|
||||
final Object[] openArray = (Object[]) openValue;
|
||||
final Collection<Object> valueCollection;
|
||||
try {
|
||||
valueCollection = cast(collectionClass.newInstance());
|
||||
@SuppressWarnings("deprecation")
|
||||
Collection<?> tmp = collectionClass.newInstance();
|
||||
valueCollection = cast(tmp);
|
||||
} catch (Exception e) {
|
||||
throw invalidObjectException("Cannot create collection", e);
|
||||
}
|
||||
@ -1114,7 +1116,9 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory {
|
||||
try {
|
||||
final Class<?> targetClass = getTargetClass();
|
||||
ReflectUtil.checkPackageAccess(targetClass);
|
||||
o = targetClass.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = targetClass.newInstance();
|
||||
o = tmp;
|
||||
for (int i = 0; i < itemNames.length; i++) {
|
||||
if (cd.containsKey(itemNames[i])) {
|
||||
Object openItem = cd.get(itemNames[i]);
|
||||
|
@ -458,6 +458,7 @@ public class MBeanServerFactory {
|
||||
**/
|
||||
private static MBeanServerBuilder newBuilder(Class<?> builderClass) {
|
||||
try {
|
||||
@SuppressWarnings("deprecation")
|
||||
final Object abuilder = builderClass.newInstance();
|
||||
return (MBeanServerBuilder)abuilder;
|
||||
} catch (RuntimeException x) {
|
||||
|
@ -531,7 +531,9 @@ public class JMXConnectorFactory {
|
||||
// We have just proved that this cast is correct
|
||||
Class<? extends T> providerClassT = Util.cast(providerClass);
|
||||
try {
|
||||
return providerClassT.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
T result = providerClassT.newInstance();
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
final String msg =
|
||||
"Exception when instantiating provider [" + className +
|
||||
|
@ -86,7 +86,9 @@ public final class FactoryEnumeration {
|
||||
answer = cls;
|
||||
}
|
||||
// Instantiate Class to get factory
|
||||
answer = ((Class) answer).newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = ((Class) answer).newInstance();
|
||||
answer = tmp;
|
||||
ref = new NamedWeakReference<>(answer, className);
|
||||
factories.set(posn-1, ref); // replace Class object or null
|
||||
return answer;
|
||||
|
@ -399,7 +399,9 @@ public final class ResourceManager {
|
||||
className = parser.nextToken() + classSuffix;
|
||||
try {
|
||||
// System.out.println("loading " + className);
|
||||
factory = helper.loadClass(className, loader).newInstance();
|
||||
@SuppressWarnings("deprecation") // Class.newInstance
|
||||
Object tmp = helper.loadClass(className, loader).newInstance();
|
||||
factory = tmp;
|
||||
} catch (InstantiationException e) {
|
||||
NamingException ne =
|
||||
new NamingException("Cannot instantiate " + className);
|
||||
|
@ -192,18 +192,12 @@ public class StartTlsRequest implements ExtendedRequest {
|
||||
}
|
||||
try {
|
||||
VersionHelper helper = VersionHelper.getVersionHelper();
|
||||
Class<?> clas = helper.loadClass(
|
||||
"com.sun.jndi.ldap.ext.StartTlsResponseImpl");
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = helper.loadClass(
|
||||
"com.sun.jndi.ldap.ext.StartTlsResponseImpl").newInstance();
|
||||
resp = (StartTlsResponse) o;
|
||||
|
||||
resp = (StartTlsResponse) clas.newInstance();
|
||||
|
||||
} catch (IllegalAccessException e) {
|
||||
throw wrapException(e);
|
||||
|
||||
} catch (InstantiationException e) {
|
||||
throw wrapException(e);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
} catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
|
||||
throw wrapException(e);
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,9 @@ public class NamingManager {
|
||||
}
|
||||
}
|
||||
|
||||
return (clas != null) ? (ObjectFactory) clas.newInstance() : null;
|
||||
@SuppressWarnings("deprecation") // Class.newInstance
|
||||
ObjectFactory result = (clas != null) ? (ObjectFactory) clas.newInstance() : null;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -710,8 +712,9 @@ public class NamingManager {
|
||||
|
||||
if (factory == null) {
|
||||
try {
|
||||
factory = (InitialContextFactory)
|
||||
helper.loadClass(className).newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = helper.loadClass(className).newInstance();
|
||||
factory = (InitialContextFactory) o;
|
||||
} catch (Exception e) {
|
||||
NoInitialContextException ne =
|
||||
new NoInitialContextException(
|
||||
|
@ -238,10 +238,11 @@ public abstract class Preferences {
|
||||
// dependent on the invoking thread.
|
||||
// Checking AllPermission also seems wrong.
|
||||
try {
|
||||
return (PreferencesFactory)
|
||||
Class.forName(factoryName, false,
|
||||
ClassLoader.getSystemClassLoader())
|
||||
@SuppressWarnings("deprecation")
|
||||
Object result =Class.forName(factoryName, false,
|
||||
ClassLoader.getSystemClassLoader())
|
||||
.newInstance();
|
||||
return (PreferencesFactory)result;
|
||||
} catch (Exception ex) {
|
||||
try {
|
||||
// workaround for javaws, plugin,
|
||||
@ -250,11 +251,12 @@ public abstract class Preferences {
|
||||
if (sm != null) {
|
||||
sm.checkPermission(new java.security.AllPermission());
|
||||
}
|
||||
return (PreferencesFactory)
|
||||
Class.forName(factoryName, false,
|
||||
Thread.currentThread()
|
||||
.getContextClassLoader())
|
||||
@SuppressWarnings("deprecation")
|
||||
Object result = Class.forName(factoryName, false,
|
||||
Thread.currentThread()
|
||||
.getContextClassLoader())
|
||||
.newInstance();
|
||||
return (PreferencesFactory) result;
|
||||
} catch (Exception e) {
|
||||
throw new InternalError(
|
||||
"Can't instantiate Preferences factory "
|
||||
@ -299,9 +301,10 @@ public abstract class Preferences {
|
||||
platformFactory = "java.util.prefs.FileSystemPreferencesFactory";
|
||||
}
|
||||
try {
|
||||
return (PreferencesFactory)
|
||||
Class.forName(platformFactory, false,
|
||||
Preferences.class.getClassLoader()).newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object result = Class.forName(platformFactory, false,
|
||||
Preferences.class.getClassLoader()).newInstance();
|
||||
return (PreferencesFactory) result;
|
||||
} catch (Exception e) {
|
||||
throw new InternalError(
|
||||
"Can't instantiate platform default Preferences factory "
|
||||
|
@ -272,6 +272,7 @@ public class ActivationID implements Serializable {
|
||||
Class<? extends RemoteRef> refClass =
|
||||
Class.forName(RemoteRef.packagePrefix + "." + in.readUTF())
|
||||
.asSubclass(RemoteRef.class);
|
||||
@SuppressWarnings("deprecation")
|
||||
RemoteRef ref = refClass.newInstance();
|
||||
ref.readExternal(in);
|
||||
activator = (Activator)
|
||||
|
@ -681,7 +681,9 @@ public class RMIClassLoader {
|
||||
Class.forName(providerClassName, false,
|
||||
ClassLoader.getSystemClassLoader())
|
||||
.asSubclass(RMIClassLoaderSpi.class);
|
||||
return providerClass.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
RMIClassLoaderSpi result = providerClass.newInstance();
|
||||
return result;
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassDefFoundError(e.getMessage());
|
||||
|
@ -439,18 +439,16 @@ public abstract class RemoteObject implements Remote, java.io.Serializable {
|
||||
RemoteRef.packagePrefix + "." + refClassName;
|
||||
Class<?> refClass = Class.forName(internalRefClassName);
|
||||
try {
|
||||
ref = (RemoteRef) refClass.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = refClass.newInstance();
|
||||
ref = (RemoteRef) tmp;
|
||||
|
||||
/*
|
||||
* If this step fails, assume we found an internal
|
||||
* class that is not meant to be a serializable ref
|
||||
* type.
|
||||
*/
|
||||
} catch (InstantiationException e) {
|
||||
throw new ClassNotFoundException(internalRefClassName, e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ClassNotFoundException(internalRefClassName, e);
|
||||
} catch (ClassCastException e) {
|
||||
} catch (InstantiationException | IllegalAccessException | ClassCastException e) {
|
||||
throw new ClassNotFoundException(internalRefClassName, e);
|
||||
}
|
||||
ref.readExternal(in);
|
||||
|
@ -2066,7 +2066,9 @@ public class Activation implements Serializable {
|
||||
|
||||
try {
|
||||
Class<?> execPolicyClass = getRMIClass(execPolicyClassName);
|
||||
execPolicy = execPolicyClass.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = execPolicyClass.newInstance();
|
||||
execPolicy = tmp;
|
||||
execPolicyMethod =
|
||||
execPolicyClass.getMethod("checkExecCommand",
|
||||
ActivationGroupDesc.class,
|
||||
|
@ -111,8 +111,9 @@ public final class TerminalFactory {
|
||||
type = "PC/SC";
|
||||
Provider sun = Security.getProvider("SunPCSC");
|
||||
if (sun == null) {
|
||||
Class<?> clazz = Class.forName("sun.security.smartcardio.SunPCSC");
|
||||
sun = (Provider)clazz.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = Class.forName("sun.security.smartcardio.SunPCSC").newInstance();
|
||||
sun = (Provider)o;
|
||||
}
|
||||
factory = TerminalFactory.getInstance(type, null, sun);
|
||||
} catch (Exception e) {
|
||||
|
@ -2962,7 +2962,9 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
|
||||
SQLData obj = null;
|
||||
try {
|
||||
ReflectUtil.checkPackageAccess(c);
|
||||
obj = (SQLData) c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = c.newInstance();
|
||||
obj = (SQLData) tmp;
|
||||
} catch(Exception ex) {
|
||||
throw new SQLException("Unable to Instantiate: ", ex);
|
||||
}
|
||||
@ -5710,7 +5712,9 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
|
||||
SQLData obj = null;
|
||||
try {
|
||||
ReflectUtil.checkPackageAccess(c);
|
||||
obj = (SQLData) c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = c.newInstance();
|
||||
obj = (SQLData) tmp;
|
||||
} catch(Exception ex) {
|
||||
throw new SQLException("Unable to Instantiate: ", ex);
|
||||
}
|
||||
|
@ -574,7 +574,9 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
|
||||
SQLData obj = null;
|
||||
try {
|
||||
ReflectUtil.checkPackageAccess(c);
|
||||
obj = (SQLData)c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = c.newInstance();
|
||||
obj = (SQLData)tmp;
|
||||
} catch (Exception ex) {
|
||||
throw new SQLException("Unable to Instantiate: ", ex);
|
||||
}
|
||||
|
@ -136,8 +136,9 @@ public class RowSetProvider {
|
||||
}
|
||||
// getFactoryClass takes care of adding the read edge if
|
||||
// necessary
|
||||
Class<?> c = getFactoryClass(factoryClassName, null, false);
|
||||
factory = (RowSetFactory) c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = getFactoryClass(factoryClassName, null, false).newInstance();
|
||||
factory = (RowSetFactory) o;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new SQLException( "RowSetFactory: " + factoryClassName +
|
||||
@ -202,6 +203,7 @@ public class RowSetProvider {
|
||||
// getFactoryClass takes care of adding the read edge if
|
||||
// necessary
|
||||
Class<?> providerClass = getFactoryClass(factoryClassName, cl, false);
|
||||
@SuppressWarnings("deprecation")
|
||||
RowSetFactory instance = (RowSetFactory) providerClass.newInstance();
|
||||
if (debug) {
|
||||
trace("Created new instance of " + providerClass +
|
||||
|
@ -478,7 +478,9 @@ public class SQLInputImpl implements SQLInput {
|
||||
SQLData obj = null;
|
||||
try {
|
||||
ReflectUtil.checkPackageAccess(c);
|
||||
obj = (SQLData)c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = c.newInstance();
|
||||
obj = (SQLData)tmp;
|
||||
} catch (Exception ex) {
|
||||
throw new SQLException("Unable to Instantiate: ", ex);
|
||||
}
|
||||
|
@ -582,14 +582,12 @@ public class SyncFactory {
|
||||
* there.
|
||||
**/
|
||||
c = Class.forName(providerID, true, cl);
|
||||
return (SyncProvider) c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object result = c.newInstance();
|
||||
return (SyncProvider)result;
|
||||
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
|
||||
throw new SyncFactoryException("IllegalAccessException: " + e.getMessage());
|
||||
} catch (InstantiationException e) {
|
||||
throw new SyncFactoryException("InstantiationException: " + e.getMessage());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new SyncFactoryException("ClassNotFoundException: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,9 @@ public class SignatureAlgorithm extends Algorithm {
|
||||
log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
|
||||
+ implementingClass + "\"");
|
||||
}
|
||||
return implementingClass.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
SignatureAlgorithmSpi result = implementingClass.newInstance();
|
||||
return result;
|
||||
} catch (IllegalAccessException ex) {
|
||||
Object exArgs[] = { algorithmURI, ex.getMessage() };
|
||||
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs, ex);
|
||||
|
@ -115,7 +115,9 @@ public class Canonicalizer {
|
||||
Class<? extends CanonicalizerSpi> implementingClass =
|
||||
canonicalizerHash.get(algorithmURI);
|
||||
|
||||
canonicalizerSpi = implementingClass.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
CanonicalizerSpi tmp = implementingClass.newInstance();
|
||||
canonicalizerSpi = tmp;
|
||||
canonicalizerSpi.reset = true;
|
||||
} catch (Exception e) {
|
||||
Object exArgs[] = { algorithmURI };
|
||||
|
@ -182,6 +182,7 @@ public class KeyResolver {
|
||||
public static void register(String className, boolean globalResolver)
|
||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||
JavaUtils.checkRegisterPermission();
|
||||
@SuppressWarnings("deprecation")
|
||||
KeyResolverSpi keyResolverSpi =
|
||||
(KeyResolverSpi) Class.forName(className).newInstance();
|
||||
keyResolverSpi.setGlobalResolver(globalResolver);
|
||||
@ -207,7 +208,9 @@ public class KeyResolver {
|
||||
KeyResolverSpi keyResolverSpi = null;
|
||||
Exception ex = null;
|
||||
try {
|
||||
keyResolverSpi = (KeyResolverSpi) Class.forName(className).newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = Class.forName(className).newInstance();
|
||||
keyResolverSpi = (KeyResolverSpi) tmp;
|
||||
} catch (ClassNotFoundException e) {
|
||||
ex = e;
|
||||
} catch (IllegalAccessException e) {
|
||||
@ -272,6 +275,7 @@ public class KeyResolver {
|
||||
JavaUtils.checkRegisterPermission();
|
||||
List<KeyResolver> keyResolverList = new ArrayList<KeyResolver>(classNames.size());
|
||||
for (String className : classNames) {
|
||||
@SuppressWarnings("deprecation")
|
||||
KeyResolverSpi keyResolverSpi =
|
||||
(KeyResolverSpi) Class.forName(className).newInstance();
|
||||
keyResolverSpi.setGlobalResolver(false);
|
||||
|
@ -110,7 +110,9 @@ public abstract class KeyResolverSpi {
|
||||
KeyResolverSpi tmp = this;
|
||||
if (globalResolver) {
|
||||
try {
|
||||
tmp = getClass().newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
KeyResolverSpi krs = getClass().newInstance();
|
||||
tmp = krs;
|
||||
} catch (InstantiationException e) {
|
||||
throw new KeyResolverException("", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
|
@ -160,7 +160,9 @@ public final class Transform extends SignatureElementProxy {
|
||||
throw new InvalidTransformException("signature.Transform.UnknownTransform", exArgs);
|
||||
}
|
||||
try {
|
||||
transformSpi = transformSpiClass.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
TransformSpi tmp = transformSpiClass.newInstance();
|
||||
transformSpi = tmp;
|
||||
} catch (InstantiationException ex) {
|
||||
Object exArgs[] = { algorithmURI };
|
||||
throw new InvalidTransformException(
|
||||
@ -345,7 +347,9 @@ public final class Transform extends SignatureElementProxy {
|
||||
}
|
||||
TransformSpi newTransformSpi = null;
|
||||
try {
|
||||
newTransformSpi = transformSpiClass.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
TransformSpi tmp = transformSpiClass.newInstance();
|
||||
newTransformSpi = tmp;
|
||||
} catch (InstantiationException ex) {
|
||||
Object exArgs[] = { algorithmURI };
|
||||
throw new InvalidTransformException(
|
||||
|
@ -99,8 +99,10 @@ public class ResourceResolver {
|
||||
ResourceResolver resolverTmp = resolver;
|
||||
if (!resolver.resolverSpi.engineIsThreadSafe()) {
|
||||
try {
|
||||
resolverTmp =
|
||||
new ResourceResolver(resolver.resolverSpi.getClass().newInstance());
|
||||
@SuppressWarnings("deprecation")
|
||||
ResourceResolver tmp = new ResourceResolver(resolver.resolverSpi.getClass().newInstance());
|
||||
resolverTmp = tmp;
|
||||
;
|
||||
} catch (InstantiationException e) {
|
||||
throw new ResourceResolverException("", e, context.attr, context.baseUri);
|
||||
} catch (IllegalAccessException e) {
|
||||
@ -246,6 +248,7 @@ public class ResourceResolver {
|
||||
public static void register(Class<? extends ResourceResolverSpi> className, boolean start) {
|
||||
JavaUtils.checkRegisterPermission();
|
||||
try {
|
||||
@SuppressWarnings("deprecation")
|
||||
ResourceResolverSpi resourceResolverSpi = className.newInstance();
|
||||
register(resourceResolverSpi, start);
|
||||
} catch (IllegalAccessException e) {
|
||||
|
@ -121,6 +121,7 @@ public class Translator extends AccessibleContext
|
||||
Class<?> translatorClass = getTranslatorClass(o.getClass());
|
||||
if (translatorClass != null) {
|
||||
try {
|
||||
@SuppressWarnings("deprecation")
|
||||
Translator t = (Translator)translatorClass.newInstance();
|
||||
t.setSource(o);
|
||||
a = t;
|
||||
|
@ -148,6 +148,7 @@ public class AbstractCharsetProvider
|
||||
true,
|
||||
this.getClass().getClassLoader());
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Charset cs = (Charset)c.newInstance();
|
||||
cache.put(csn, new SoftReference<Charset>(cs));
|
||||
return cs;
|
||||
|
@ -88,8 +88,9 @@ public final class P11Util {
|
||||
p = Security.getProvider(providerName);
|
||||
if (p == null) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(className);
|
||||
p = (Provider)clazz.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = Class.forName(className).newInstance();
|
||||
p = (Provider)o;
|
||||
} catch (Exception e) {
|
||||
throw new ProviderException
|
||||
("Could not find provider " + providerName, e);
|
||||
|
@ -1446,7 +1446,9 @@ public final class SunPKCS11 extends AuthProvider {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return (CallbackHandler)c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object result = c.newInstance();
|
||||
return (CallbackHandler)result;
|
||||
}
|
||||
});
|
||||
// save it
|
||||
|
@ -89,9 +89,10 @@ public abstract class HttpServerProvider {
|
||||
if (cn == null)
|
||||
return false;
|
||||
try {
|
||||
Class<?> c = Class.forName(cn, true,
|
||||
ClassLoader.getSystemClassLoader());
|
||||
provider = (HttpServerProvider)c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = Class.forName(cn, true,
|
||||
ClassLoader.getSystemClassLoader()).newInstance();
|
||||
provider = (HttpServerProvider)o;
|
||||
return true;
|
||||
} catch (ClassNotFoundException |
|
||||
IllegalAccessException |
|
||||
|
@ -82,7 +82,9 @@ public class TerminalFactory
|
||||
}
|
||||
else {
|
||||
try {
|
||||
t = (Terminal) Thread.currentThread().getContextClassLoader().loadClass(type).newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = Thread.currentThread().getContextClassLoader().loadClass(type).newInstance();
|
||||
t = (Terminal) o;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalArgumentException(MessageFormat.format("Invalid terminal type: {0}", type), e);
|
||||
|
@ -61,6 +61,7 @@ public class ConsoleRunner
|
||||
List<Completer> completorList = new ArrayList<Completer>();
|
||||
|
||||
for (StringTokenizer tok = new StringTokenizer(completors, ","); tok.hasMoreTokens();) {
|
||||
@SuppressWarnings("deprecation")
|
||||
Object obj = Class.forName(tok.nextToken()).newInstance();
|
||||
completorList.add((Completer) obj);
|
||||
}
|
||||
|
@ -128,7 +128,9 @@ public class ProcessAttachingConnector
|
||||
if (lib.equals("dt_shmem")) {
|
||||
try {
|
||||
Class<?> c = Class.forName("com.sun.tools.jdi.SharedMemoryTransportService");
|
||||
ts = (TransportService)c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object tmp = c.newInstance();
|
||||
ts = (TransportService)tmp;
|
||||
} catch (Exception x) { }
|
||||
}
|
||||
}
|
||||
|
@ -53,17 +53,19 @@ public class RawCommandLineLauncher extends AbstractLauncher implements Launchin
|
||||
super();
|
||||
|
||||
try {
|
||||
Class<?> c = Class.forName("com.sun.tools.jdi.SharedMemoryTransportService");
|
||||
transportService = (TransportService)c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o =
|
||||
Class.forName("com.sun.tools.jdi.SharedMemoryTransportService").newInstance();
|
||||
transportService = (TransportService)o;
|
||||
transport = new Transport() {
|
||||
public String name() {
|
||||
return "dt_shmem";
|
||||
}
|
||||
};
|
||||
} catch (ClassNotFoundException x) {
|
||||
} catch (UnsatisfiedLinkError x) {
|
||||
} catch (InstantiationException x) {
|
||||
} catch (IllegalAccessException x) {
|
||||
} catch (ClassNotFoundException |
|
||||
UnsatisfiedLinkError |
|
||||
InstantiationException |
|
||||
IllegalAccessException x) {
|
||||
};
|
||||
|
||||
if (transportService == null) {
|
||||
|
@ -64,18 +64,20 @@ public class SunCommandLineLauncher extends AbstractLauncher implements Launchin
|
||||
* transport or the socket transport
|
||||
*/
|
||||
try {
|
||||
Class<?> c = Class.forName("com.sun.tools.jdi.SharedMemoryTransportService");
|
||||
transportService = (TransportService)c.newInstance();
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o =
|
||||
Class.forName("com.sun.tools.jdi.SharedMemoryTransportService").newInstance();
|
||||
transportService = (TransportService)o;
|
||||
transport = new Transport() {
|
||||
public String name() {
|
||||
return "dt_shmem";
|
||||
}
|
||||
};
|
||||
usingSharedMemory = true;
|
||||
} catch (ClassNotFoundException x) {
|
||||
} catch (UnsatisfiedLinkError x) {
|
||||
} catch (InstantiationException x) {
|
||||
} catch (IllegalAccessException x) {
|
||||
} catch (ClassNotFoundException |
|
||||
UnsatisfiedLinkError |
|
||||
InstantiationException |
|
||||
IllegalAccessException x) {
|
||||
};
|
||||
if (transportService == null) {
|
||||
transportService = new SocketTransportService();
|
||||
|
@ -46,7 +46,7 @@ public class LocaleDataProvider extends LocaleData.CommonResourceBundleProvider
|
||||
Class<?> c = Class.forName(LocaleDataProvider.class.getModule(), bundleName);
|
||||
if (c != null && ResourceBundle.class.isAssignableFrom(c)) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "deprecation"})
|
||||
ResourceBundle rb = ((Class<ResourceBundle>) c).newInstance();
|
||||
return rb;
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user