src/share/classes/sun/rmi/server/LoaderHandler.java
Print this page
@@ -110,15 +110,15 @@
* to class loader instances. Entries hold class loaders with weak
* references, so this table does not prevent loaders from being
* garbage collected.
*/
private static final HashMap<LoaderKey, LoaderEntry> loaderTable
- = new HashMap<LoaderKey, LoaderEntry>(5);
+ = new HashMap<>(5);
/** reference queue for cleared class loader entries */
private static final ReferenceQueue<Loader> refQueue
- = new ReferenceQueue<Loader>();
+ = new ReferenceQueue<>();
/*
* Disallow anyone from creating one of these.
*/
private LoaderHandler() {}
@@ -147,11 +147,11 @@
/**
* Load a class from a network location (one or more URLs),
* but first try to resolve the named class through the given
* "default loader".
*/
- public static Class loadClass(String codebase, String name,
+ public static Class<?> loadClass(String codebase, String name,
ClassLoader defaultLoader)
throws MalformedURLException, ClassNotFoundException
{
if (loaderLog.isLoggable(Log.BRIEF)) {
loaderLog.log(Log.BRIEF,
@@ -168,11 +168,11 @@
urls = getDefaultCodebaseURLs();
}
if (defaultLoader != null) {
try {
- Class c = Class.forName(name, false, defaultLoader);
+ Class<?> c = Class.forName(name, false, defaultLoader);
if (loaderLog.isLoggable(Log.VERBOSE)) {
loaderLog.log(Log.VERBOSE,
"class \"" + name + "\" found via defaultLoader, " +
"defined by " + c.getClassLoader());
}
@@ -187,11 +187,11 @@
/**
* Returns the class annotation (representing the location for
* a class) that RMI will use to annotate the call stream when
* marshalling objects of the given class.
*/
- public static String getClassAnnotation(Class cl) {
+ public static String getClassAnnotation(Class<?> cl) {
String name = cl.getName();
/*
* Class objects for arrays of primitive types never need an
* annotation, because they never need to be (or can be) downloaded.
@@ -259,19 +259,17 @@
}
}
annotation = urlsToPath(urls);
}
- } catch (SecurityException e) {
+ } catch (SecurityException | IOException e) {
/*
- * If access was denied to the knowledge of the class
- * loader's URLs, fall back to the default behavior.
- */
- } catch (IOException e) {
- /*
- * This shouldn't happen, although it is declared to be
- * thrown by openConnection() and getPermission(). If it
+ * SecurityException: If access was denied to the knowledge of
+ * the class loader's URLs, fall back to the default behavior.
+ *
+ * IOException: This shouldn't happen, although it is declared
+ * to be thrown by openConnection() and getPermission(). If it
* does happen, forget about this class loader's URLs and
* fall back to the default behavior.
*/
}
}
@@ -356,11 +354,11 @@
/**
* Load a class from the RMI class loader corresponding to the given
* codebase URL path in the current execution context.
*/
- private static Class loadClass(URL[] urls, String name)
+ private static Class<?> loadClass(URL[] urls, String name)
throws ClassNotFoundException
{
ClassLoader parent = getRMIContextClassLoader();
if (loaderLog.isLoggable(Log.VERBOSE)) {
loaderLog.log(Log.VERBOSE,
@@ -373,11 +371,11 @@
* (see bugid 4140511).
*/
SecurityManager sm = System.getSecurityManager();
if (sm == null) {
try {
- Class c = Class.forName(name, false, parent);
+ Class<?> c = Class.forName(name, false, parent);
if (loaderLog.isLoggable(Log.VERBOSE)) {
loaderLog.log(Log.VERBOSE,
"class \"" + name + "\" found via " +
"thread context class loader " +
"(no security manager: codebase disabled), " +
@@ -422,11 +420,11 @@
/*
* But first, check to see if the named class could have been
* resolved without the security-offending codebase anyway;
* if so, return successfully (see bugids 4191926 & 4349670).
*/
- Class c = Class.forName(name, false, parent);
+ Class<?> c = Class.forName(name, false, parent);
if (loaderLog.isLoggable(Log.VERBOSE)) {
loaderLog.log(Log.VERBOSE,
"class \"" + name + "\" found via " +
"thread context class loader " +
"(access to codebase denied), " +
@@ -448,11 +446,11 @@
"access to class loader denied", e);
}
}
try {
- Class c = Class.forName(name, false, loader);
+ Class<?> c = Class.forName(name, false, loader);
if (loaderLog.isLoggable(Log.VERBOSE)) {
loaderLog.log(Log.VERBOSE,
"class \"" + name + "\" " + "found via codebase, " +
"defined by " + c.getClassLoader());
}
@@ -470,11 +468,11 @@
* Define and return a dynamic proxy class in a class loader with
* URLs supplied in the given location. The proxy class will
* implement interface classes named by the given array of
* interface names.
*/
- public static Class loadProxyClass(String codebase, String[] interfaces,
+ public static Class<?> loadProxyClass(String codebase, String[] interfaces,
ClassLoader defaultLoader)
throws MalformedURLException, ClassNotFoundException
{
if (loaderLog.isLoggable(Log.BRIEF)) {
loaderLog.log(Log.BRIEF,
@@ -535,11 +533,11 @@
* loaders and use the would-de parent instead.
*/
SecurityManager sm = System.getSecurityManager();
if (sm == null) {
try {
- Class c = loadProxyClass(interfaces, defaultLoader, parent,
+ Class<?> c = loadProxyClass(interfaces, defaultLoader, parent,
false);
if (loaderLog.isLoggable(Log.VERBOSE)) {
loaderLog.log(Log.VERBOSE,
"(no security manager: codebase disabled) " +
"proxy class defined by " + c.getClassLoader());
@@ -582,11 +580,11 @@
/*
* But first, check to see if the proxy class could have been
* resolved without the security-offending codebase anyway;
* if so, return successfully (see bugids 4191926 & 4349670).
*/
- Class c = loadProxyClass(interfaces, defaultLoader, parent,
+ Class<?> c = loadProxyClass(interfaces, defaultLoader, parent,
false);
if (loaderLog.isLoggable(Log.VERBOSE)) {
loaderLog.log(Log.VERBOSE,
"(access to codebase denied) " +
"proxy class defined by " + c.getClassLoader());
@@ -606,11 +604,11 @@
"access to class loader denied", e);
}
}
try {
- Class c = loadProxyClass(interfaces, defaultLoader, loader, true);
+ Class<?> c = loadProxyClass(interfaces, defaultLoader, loader, true);
if (loaderLog.isLoggable(Log.VERBOSE)) {
loaderLog.log(Log.VERBOSE,
"proxy class defined by " + c.getClassLoader());
}
return c;
@@ -627,18 +625,18 @@
* Define a proxy class in the default loader if appropriate.
* Define the class in an RMI class loader otherwise. The proxy
* class will implement classes which are named in the supplied
* interfaceNames.
*/
- private static Class loadProxyClass(String[] interfaceNames,
+ private static Class<?> loadProxyClass(String[] interfaceNames,
ClassLoader defaultLoader,
ClassLoader codebaseLoader,
boolean preferCodebase)
throws ClassNotFoundException
{
ClassLoader proxyLoader = null;
- Class[] classObjs = new Class[interfaceNames.length];
+ Class<?>[] classObjs = new Class<?>[interfaceNames.length];
boolean[] nonpublic = { false };
defaultLoaderCase:
if (defaultLoader != null) {
try {
@@ -690,11 +688,11 @@
/**
* Define a proxy class in the given class loader. The proxy
* class will implement the given interfaces Classes.
*/
- private static Class loadProxyClass(ClassLoader loader, Class[] interfaces)
+ private static Class<?> loadProxyClass(ClassLoader loader, Class[] interfaces)
throws ClassNotFoundException
{
try {
return Proxy.getProxyClass(loader, interfaces);
} catch (IllegalArgumentException e) {
@@ -725,11 +723,11 @@
{
/* loader of a non-public interface class */
ClassLoader nonpublicLoader = null;
for (int i = 0; i < interfaces.length; i++) {
- Class cl =
+ Class<?> cl =
(classObjs[i] = Class.forName(interfaces[i], false, loader));
if (!Modifier.isPublic(cl.getModifiers())) {
ClassLoader current = cl.getClassLoader();
if (loaderLog.isLoggable(Log.VERBOSE)) {
@@ -776,11 +774,11 @@
return urls;
}
/** map from weak(key=string) to [URL[], soft(key)] */
private static final Map<String, Object[]> pathToURLsCache
- = new WeakHashMap<String, Object[]>(5);
+ = new WeakHashMap<>(5);
/**
* Convert an array of URL objects into a corresponding string
* containing a space-separated list of URLs.
*
@@ -1169,13 +1167,13 @@
* permissions necessary to load classes from this loader.
*/
private void checkPermissions() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) { // should never be null?
- Enumeration enum_ = permissions.elements();
+ Enumeration<Permission> enum_ = permissions.elements();
while (enum_.hasMoreElements()) {
- sm.checkPermission((Permission) enum_.nextElement());
+ sm.checkPermission(enum_.nextElement());
}
}
}
/**