7146763: Warnings cleanup in the sun.rmi and related packages
Summary: Cleanup warnings and use jkd7 features in sun.rmi.*
Reviewed-by: smarks, chegar, forax, dmocek
--- a/jdk/make/sun/rmi/cgi/Makefile Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/make/sun/rmi/cgi/Makefile Fri Mar 02 13:48:43 2012 -0800
@@ -28,6 +28,8 @@
#
BUILDDIR = ../../..
+JAVAC_MAX_WARNINGS = true
+JAVAC_WARNINGS_FATAL = true
# java-rmi.cgi is a JDK tool
PACKAGE = sun.rmi
PRODUCT = sun
--- a/jdk/make/sun/rmi/registry/Makefile Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/make/sun/rmi/registry/Makefile Fri Mar 02 13:48:43 2012 -0800
@@ -28,6 +28,9 @@
#
BUILDDIR = ../../..
+JAVAC_MAX_WARNINGS = true
+JAVAC_WARNINGS_FATAL = true
+JAVAC_LINT_OPTIONS = -Xlint:all,-deprecation
PACKAGE = sun.rmi.registry
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/sun/rmi/rmi/Makefile Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/make/sun/rmi/rmi/Makefile Fri Mar 02 13:48:43 2012 -0800
@@ -28,6 +28,9 @@
#
BUILDDIR = ../../..
+JAVAC_MAX_WARNINGS = true
+JAVAC_WARNINGS_FATAL = true
+JAVAC_LINT_OPTIONS = -Xlint:all,-deprecation
PACKAGE = sun.rmi
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/sun/rmi/rmid/Makefile Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/make/sun/rmi/rmid/Makefile Fri Mar 02 13:48:43 2012 -0800
@@ -29,6 +29,8 @@
#
BUILDDIR = ../../..
+JAVAC_MAX_WARNINGS = true
+JAVAC_WARNINGS_FATAL = true
PACKAGE = sun.rmi.activation
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/src/share/classes/com/sun/rmi/rmid/ExecOptionPermission.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/com/sun/rmi/rmid/ExecOptionPermission.java Fri Mar 02 13:48:43 2012 -0800
@@ -223,7 +223,7 @@
implements java.io.Serializable
{
- private Hashtable permissions;
+ private Hashtable<String, Permission> permissions;
private boolean all_allowed; // true if "*" is in the collection
private static final long serialVersionUID = -1242475729790124375L;
@@ -231,7 +231,7 @@
* Create an empty ExecOptionPermissionCollection.
*/
public ExecOptionPermissionCollection() {
- permissions = new Hashtable(11);
+ permissions = new Hashtable<>(11);
all_allowed = false;
}
@@ -291,7 +291,7 @@
String pname = p.getName();
- Permission x = (Permission) permissions.get(pname);
+ Permission x = permissions.get(pname);
if (x != null)
// we have a direct hit!
@@ -306,7 +306,7 @@
while ((last = pname.lastIndexOf(".", offset)) != -1) {
pname = pname.substring(0, last+1) + "*";
- x = (Permission) permissions.get(pname);
+ x = permissions.get(pname);
if (x != null) {
return x.implies(permission);
@@ -321,7 +321,7 @@
while ((last = pname.lastIndexOf("=", offset)) != -1) {
pname = pname.substring(0, last+1) + "*";
- x = (Permission) permissions.get(pname);
+ x = permissions.get(pname);
if (x != null) {
return x.implies(permission);
@@ -341,7 +341,7 @@
* @return an enumeration of all the ExecOptionPermission objects.
*/
- public Enumeration elements()
+ public Enumeration<Permission> elements()
{
return permissions.elements();
}
--- a/jdk/src/share/classes/com/sun/rmi/rmid/ExecPermission.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/com/sun/rmi/rmid/ExecPermission.java Fri Mar 02 13:48:43 2012 -0800
@@ -227,7 +227,7 @@
extends PermissionCollection
implements java.io.Serializable
{
- private Vector permissions;
+ private Vector<Permission> permissions;
private static final long serialVersionUID = -3352558508888368273L;
@@ -235,7 +235,7 @@
* Create an empty ExecPermissionCollection.
*/
public ExecPermissionCollection() {
- permissions = new Vector();
+ permissions = new Vector<>();
}
/**
@@ -274,10 +274,10 @@
if (! (permission instanceof ExecPermission))
return false;
- Enumeration e = permissions.elements();
+ Enumeration<Permission> e = permissions.elements();
while (e.hasMoreElements()) {
- ExecPermission x = (ExecPermission) e.nextElement();
+ ExecPermission x = (ExecPermission)e.nextElement();
if (x.implies(permission)) {
return true;
}
@@ -291,7 +291,7 @@
*
* @return an enumeration of all the ExecPermission objects.
*/
- public Enumeration elements()
+ public Enumeration<Permission> elements()
{
return permissions.elements();
}
--- a/jdk/src/share/classes/sun/rmi/log/ReliableLog.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/log/ReliableLog.java Fri Mar 02 13:48:43 2012 -0800
@@ -344,10 +344,9 @@
return ClassLoader.getSystemClassLoader();
}
});
- Class cl = loader.loadClass(logClassName);
- if (LogFile.class.isAssignableFrom(cl)) {
- return cl.getConstructor(String.class, String.class);
- }
+ Class<? extends LogFile> cl =
+ loader.loadClass(logClassName).asSubclass(LogFile.class);
+ return cl.getConstructor(String.class, String.class);
} catch (Exception e) {
System.err.println("Exception occurred:");
e.printStackTrace();
@@ -595,10 +594,10 @@
} else {
name = versionFile;
}
- DataOutputStream out =
- new DataOutputStream(new FileOutputStream(fName(name)));
- writeInt(out, version);
- out.close();
+ try (FileOutputStream fos = new FileOutputStream(fName(name));
+ DataOutputStream out = new DataOutputStream(fos)) {
+ writeInt(out, version);
+ }
}
/**
@@ -629,11 +628,9 @@
* @exception IOException If an I/O error has occurred.
*/
private int readVersion(String name) throws IOException {
- DataInputStream in = new DataInputStream(new FileInputStream(name));
- try {
+ try (DataInputStream in = new DataInputStream
+ (new FileInputStream(name))) {
return in.readInt();
- } finally {
- in.close();
}
}
--- a/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java Fri Mar 02 13:48:43 2012 -0800
@@ -77,9 +77,9 @@
/* indicate compatibility with JDK 1.1.x version of class */
private static final long serialVersionUID = 4666870661827494597L;
private Hashtable<String, Remote> bindings
- = new Hashtable<String, Remote>(101);
+ = new Hashtable<>(101);
private static Hashtable<InetAddress, InetAddress> allowedAccessCache
- = new Hashtable<InetAddress, InetAddress>(3);
+ = new Hashtable<>(3);
private static RegistryImpl registry;
private static ObjID id = new ObjID(ObjID.REGISTRY_ID);
@@ -194,9 +194,9 @@
synchronized (bindings) {
int i = bindings.size();
names = new String[i];
- Enumeration enum_ = bindings.keys();
+ Enumeration<String> enum_ = bindings.keys();
while ((--i) >= 0)
- names[i] = (String)enum_.nextElement();
+ names[i] = enum_.nextElement();
}
return names;
}
--- a/jdk/src/share/classes/sun/rmi/rmic/BatchEnvironment.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/rmic/BatchEnvironment.java Fri Mar 02 13:48:43 2012 -0800
@@ -160,7 +160,7 @@
}
/** list of generated source files created in this environment */
- private Vector generatedFiles = new Vector();
+ private Vector<File> generatedFiles = new Vector<>();
/**
* Remember a generated source file generated so that it
@@ -177,9 +177,9 @@
*/
public void deleteGeneratedFiles() {
synchronized(generatedFiles) {
- Enumeration enumeration = generatedFiles.elements();
+ Enumeration<File> enumeration = generatedFiles.elements();
while (enumeration.hasMoreElements()) {
- File file = (File) enumeration.nextElement();
+ File file = enumeration.nextElement();
file.delete();
}
generatedFiles.removeAllElements();
--- a/jdk/src/share/classes/sun/rmi/rmic/Main.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/rmic/Main.java Fri Mar 02 13:48:43 2012 -0800
@@ -73,14 +73,15 @@
File destDir;
int flags;
long tm;
- Vector classes;
+ Vector<String> classes;
boolean nowrite;
boolean nocompile;
boolean keepGenerated;
boolean status;
String[] generatorArgs;
- Vector generators;
- Class environmentClass = BatchEnvironment.class;
+ Vector<Generator> generators;
+ Class<? extends BatchEnvironment> environmentClass =
+ BatchEnvironment.class;
boolean iiopGeneration = false;
/**
@@ -183,7 +184,7 @@
destDir = null;
flags = F_WARNINGS;
tm = System.currentTimeMillis();
- classes = new Vector();
+ classes = new Vector<>();
nowrite = false;
nocompile = false;
keepGenerated = false;
@@ -191,7 +192,7 @@
if (generatorArgs == null) {
return false;
}
- generators = new Vector();
+ generators = new Vector<>();
// Pre-process command line for @file arguments
try {
@@ -411,7 +412,7 @@
// Get the environment required by this generator...
- Class envClass = BatchEnvironment.class;
+ Class<?> envClass = BatchEnvironment.class;
String env = getString("generator.env." + arg);
if (env != null) {
try {
@@ -423,7 +424,7 @@
// Yes, so switch to the new one...
- environmentClass = envClass;
+ environmentClass = BatchEnvironment.class.asSubclass(environmentClass);
} else {
@@ -495,8 +496,9 @@
try {
Class[] ctorArgTypes = {OutputStream.class,ClassPath.class,Main.class};
Object[] ctorArgs = {out,classPath,this};
- Constructor constructor = environmentClass.getConstructor(ctorArgTypes);
- result = (BatchEnvironment) constructor.newInstance(ctorArgs);
+ Constructor<? extends BatchEnvironment> constructor =
+ environmentClass.getConstructor(ctorArgTypes);
+ result = constructor.newInstance(ctorArgs);
result.reset();
}
catch (Exception e) {
@@ -530,7 +532,7 @@
*/
for (int i = classes.size()-1; i >= 0; i-- ) {
Identifier implClassName =
- Identifier.lookup((String)classes.elementAt(i));
+ Identifier.lookup(classes.elementAt(i));
/*
* Fix bugid 4049354: support using '.' as an inner class
@@ -558,7 +560,7 @@
try {
ClassDefinition def = decl.getClassDefinition(env);
for (int j = 0; j < generators.size(); j++) {
- Generator gen = (Generator)generators.elementAt(j);
+ Generator gen = generators.elementAt(j);
gen.generate(env, def, destDir);
}
} catch (ClassNotFound ex) {
@@ -673,7 +675,7 @@
do {
done = true;
- for (Enumeration e = env.getClasses() ; e.hasMoreElements() ; ) {
+ for (Enumeration<?> e = env.getClasses() ; e.hasMoreElements() ; ) {
ClassDeclaration c = (ClassDeclaration)e.nextElement();
done = compileClass(c,buf,env);
}
@@ -682,7 +684,9 @@
/*
* Compile a single class.
+ * Fallthrough is intentional
*/
+ @SuppressWarnings("fallthrough")
public boolean compileClass (ClassDeclaration c,
ByteArrayOutputStream buf,
BatchEnvironment env)
@@ -879,6 +883,6 @@
args[1] = (arg1 != null ? arg1.toString() : "null");
args[2] = (arg2 != null ? arg2.toString() : "null");
- return java.text.MessageFormat.format(format, args);
+ return java.text.MessageFormat.format(format, (Object[]) args);
}
}
--- a/jdk/src/share/classes/sun/rmi/rmic/RMIGenerator.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/rmic/RMIGenerator.java Fri Mar 02 13:48:43 2012 -0800
@@ -61,7 +61,7 @@
*/
public class RMIGenerator implements RMIConstants, Generator {
- private static final Hashtable versionOptions = new Hashtable();
+ private static final Hashtable<String, Integer> versionOptions = new Hashtable<>();
static {
versionOptions.put("-v1.1", new Integer(STUB_VERSION_1_1));
versionOptions.put("-vcompat", new Integer(STUB_VERSION_FAT));
@@ -96,7 +96,7 @@
return false;
}
explicitVersion = arg;
- version = ((Integer) versionOptions.get(arg)).intValue();
+ version = versionOptions.get(arg);
argv[i] = null;
}
}
@@ -519,7 +519,7 @@
* follows a previous catch of it or of one of its superclasses.
* The following method invocation takes care of these details.
*/
- Vector catchList = computeUniqueCatchList(exceptions);
+ Vector<ClassDefinition> catchList = computeUniqueCatchList(exceptions);
/*
* If we need to catch any particular exceptions (i.e. this method
@@ -615,10 +615,10 @@
* UnexpectedException, and end the try block.
*/
if (catchList.size() > 0) {
- for (Enumeration enumeration = catchList.elements();
+ for (Enumeration<ClassDefinition> enumeration = catchList.elements();
enumeration.hasMoreElements();)
{
- ClassDefinition def = (ClassDefinition) enumeration.nextElement();
+ ClassDefinition def = enumeration.nextElement();
p.pOlnI("} catch (" + def.getName() + " e) {");
p.pln("throw e;");
}
@@ -650,8 +650,8 @@
* of its superclasses is in the throws clause of the method, indicating
* that no exceptions need to be caught.
*/
- private Vector computeUniqueCatchList(ClassDeclaration[] exceptions) {
- Vector uniqueList = new Vector(); // unique exceptions to catch
+ private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
+ Vector<ClassDefinition> uniqueList = new Vector<>(); // unique exceptions to catch
uniqueList.addElement(defRuntimeException);
uniqueList.addElement(defRemoteException);
@@ -682,8 +682,7 @@
* exceptions that need to be caught:
*/
for (int j = 0; j < uniqueList.size();) {
- ClassDefinition def =
- (ClassDefinition) uniqueList.elementAt(j);
+ ClassDefinition def = uniqueList.elementAt(j);
if (def.superClassOf(env, decl)) {
/*
* If a superclass of this exception is already on
--- a/jdk/src/share/classes/sun/rmi/rmic/newrmic/Main.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/rmic/newrmic/Main.java Fri Mar 02 13:48:43 2012 -0800
@@ -455,7 +455,7 @@
BatchEnvironment env;
try {
Constructor<? extends BatchEnvironment> cons =
- batch.envClass.getConstructor(new Class[] { RootDoc.class });
+ batch.envClass.getConstructor(new Class<?>[] { RootDoc.class });
env = cons.newInstance(rootDoc);
} catch (NoSuchMethodException e) {
throw new AssertionError(e);
--- a/jdk/src/share/classes/sun/rmi/rmic/newrmic/Resources.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/rmic/newrmic/Resources.java Fri Mar 02 13:48:43 2012 -0800
@@ -69,7 +69,7 @@
format = "missing resource key: key = \"" + key + "\", " +
"arguments = \"{0}\", \"{1}\", \"{2}\"";
}
- return MessageFormat.format(format, args);
+ return MessageFormat.format(format, (Object[]) args);
}
/**
--- a/jdk/src/share/classes/sun/rmi/server/ActivatableRef.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/server/ActivatableRef.java Fri Mar 02 13:48:43 2012 -0800
@@ -80,7 +80,7 @@
String className = desc.getClassName();
try {
- Class cl =
+ Class<?> cl =
RMIClassLoader.loadClass(desc.getLocation(), className);
RemoteRef clientRef = new ActivatableRef(id, null);
return Util.createProxy(cl, clientRef, false);
@@ -373,8 +373,8 @@
if (className.equals("")) return;
try {
- Class refClass = Class.forName(RemoteRef.packagePrefix + "." +
- className);
+ Class<?> refClass = Class.forName(RemoteRef.packagePrefix + "." +
+ className);
ref = (RemoteRef)refClass.newInstance();
ref.readExternal(in);
} catch (InstantiationException e) {
--- a/jdk/src/share/classes/sun/rmi/server/Activation.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/server/Activation.java Fri Mar 02 13:48:43 2012 -0800
@@ -138,7 +138,6 @@
/** indicate compatibility with JDK 1.2 version of class */
private static final long serialVersionUID = 2921265612698155191L;
-
private static final byte MAJOR_VERSION = 1;
private static final byte MINOR_VERSION = 0;
@@ -298,6 +297,7 @@
private static class SystemRegistryImpl extends RegistryImpl {
private static final String NAME = ActivationSystem.class.getName();
+ private static final long serialVersionUID = 4877330021609408794L;
private final ActivationSystem systemStub;
SystemRegistryImpl(int port,
@@ -804,9 +804,8 @@
ActivationGroupDesc desc = null;
ActivationGroupID groupID = null;
long incarnation = 0;
- Map<ActivationID,ObjectEntry> objects =
- new HashMap<ActivationID,ObjectEntry>();
- Set<ActivationID> restartSet = new HashSet<ActivationID>();
+ Map<ActivationID,ObjectEntry> objects = new HashMap<>();
+ Set<ActivationID> restartSet = new HashSet<>();
transient ActivationInstantiator group = null;
transient int status = NORMAL;
@@ -1057,6 +1056,11 @@
}
}
+ /*
+ * Fallthrough from TERMINATE to TERMINATING
+ * is intentional
+ */
+ @SuppressWarnings("fallthrough")
private void await() {
while (true) {
switch (status) {
@@ -1228,14 +1232,13 @@
PipeWriter.plugTogetherPair
(child.getInputStream(), System.out,
child.getErrorStream(), System.err);
-
- MarshalOutputStream out =
- new MarshalOutputStream(child.getOutputStream());
- out.writeObject(id);
- out.writeObject(desc);
- out.writeLong(incarnation);
- out.flush();
- out.close();
+ try (MarshalOutputStream out =
+ new MarshalOutputStream(child.getOutputStream())) {
+ out.writeObject(id);
+ out.writeObject(desc);
+ out.writeLong(incarnation);
+ out.flush();
+ }
} catch (IOException e) {
@@ -1352,7 +1355,7 @@
cmdenv = desc.getCommandEnvironment();
// argv is the literal command to exec
- List<String> argv = new ArrayList<String>();
+ List<String> argv = new ArrayList<>();
// Command name/path
argv.add((cmdenv != null && cmdenv.getCommandPath() != null)
@@ -1957,7 +1960,7 @@
}
String log = null;
- List<String> childArgs = new ArrayList<String>();
+ List<String> childArgs = new ArrayList<>();
/*
* Parse arguments
@@ -2031,8 +2034,7 @@
}
try {
- Class<?> execPolicyClass =
- RMIClassLoader.loadClass(execPolicyClassName);
+ Class<?> execPolicyClass = getRMIClass(execPolicyClassName);
execPolicy = execPolicyClass.newInstance();
execPolicyMethod =
execPolicyClass.getMethod("checkExecCommand",
@@ -2123,6 +2125,10 @@
}
}
+ @SuppressWarnings("deprecation")
+ private static Class<?> getRMIClass(String execPolicyClassName) throws Exception {
+ return RMIClassLoader.loadClass(execPolicyClassName);
+ }
/*
* Dijkstra semaphore operations to limit the number of subprocesses
* rmid attempts to make at once.
--- a/jdk/src/share/classes/sun/rmi/server/ActivationGroupImpl.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/server/ActivationGroupImpl.java Fri Mar 02 13:48:43 2012 -0800
@@ -66,10 +66,10 @@
/** maps persistent IDs to activated remote objects */
private final Hashtable<ActivationID,ActiveEntry> active =
- new Hashtable<ActivationID,ActiveEntry>();
+ new Hashtable<>();
private boolean groupInactive = false;
private final ActivationGroupID groupID;
- private final List<ActivationID> lockedIDs = new ArrayList<ActivationID>();
+ private final List<ActivationID> lockedIDs = new ArrayList<>();
/**
* Creates a default activation group implementation.
@@ -296,14 +296,9 @@
active.put(id, entry);
return entry.mobj;
- } catch (NoSuchMethodException e) {
- /* user forgot to provide activatable constructor? */
- throw new ActivationException
- ("Activatable object must provide an activation"+
- " constructor", e);
-
- } catch (NoSuchMethodError e) {
- /* code recompiled and user forgot to provide
+ } catch (NoSuchMethodException | NoSuchMethodError e) {
+ /* user forgot to provide activatable constructor?
+ * or code recompiled and user forgot to provide
* activatable constructor?
*/
throw new ActivationException
--- a/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java Fri Mar 02 13:48:43 2012 -0800
@@ -112,11 +112,11 @@
* 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.
@@ -149,8 +149,8 @@
* but first try to resolve the named class through the given
* "default loader".
*/
- public static Class loadClass(String codebase, String name,
- ClassLoader defaultLoader)
+ public static Class<?> loadClass(String codebase, String name,
+ ClassLoader defaultLoader)
throws MalformedURLException, ClassNotFoundException
{
if (loaderLog.isLoggable(Log.BRIEF)) {
@@ -170,7 +170,7 @@
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, " +
@@ -189,7 +189,7 @@
* 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();
/*
@@ -261,15 +261,13 @@
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.
*/
@@ -358,7 +356,7 @@
* 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();
@@ -375,7 +373,7 @@
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 " +
@@ -424,7 +422,7 @@
* 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 " +
@@ -450,7 +448,7 @@
}
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, " +
@@ -472,8 +470,8 @@
* implement interface classes named by the given array of
* interface names.
*/
- public static Class loadProxyClass(String codebase, String[] interfaces,
- ClassLoader defaultLoader)
+ public static Class<?> loadProxyClass(String codebase, String[] interfaces,
+ ClassLoader defaultLoader)
throws MalformedURLException, ClassNotFoundException
{
if (loaderLog.isLoggable(Log.BRIEF)) {
@@ -537,7 +535,7 @@
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,
@@ -584,8 +582,8 @@
* resolved without the security-offending codebase anyway;
* if so, return successfully (see bugids 4191926 & 4349670).
*/
- Class c = loadProxyClass(interfaces, defaultLoader, parent,
- false);
+ Class<?> c = loadProxyClass(interfaces, defaultLoader, parent,
+ false);
if (loaderLog.isLoggable(Log.VERBOSE)) {
loaderLog.log(Log.VERBOSE,
"(access to codebase denied) " +
@@ -608,7 +606,7 @@
}
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());
@@ -629,14 +627,14 @@
* class will implement classes which are named in the supplied
* interfaceNames.
*/
- private static Class loadProxyClass(String[] interfaceNames,
- ClassLoader defaultLoader,
- ClassLoader codebaseLoader,
- boolean preferCodebase)
+ 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:
@@ -692,7 +690,7 @@
* 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 {
@@ -727,7 +725,7 @@
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())) {
@@ -778,7 +776,7 @@
/** 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
@@ -1171,9 +1169,9 @@
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());
}
}
}
--- a/jdk/src/share/classes/sun/rmi/server/MarshalInputStream.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/server/MarshalInputStream.java Fri Mar 02 13:48:43 2012 -0800
@@ -65,14 +65,14 @@
/** table to hold sun classes to which access is explicitly permitted */
protected static Map<String, Class<?>> permittedSunClasses
- = new HashMap<String, Class<?>>(3);
+ = new HashMap<>(3);
/** if true, don't try superclass first in resolveClass() */
private boolean skipDefaultResolveClass = false;
/** callbacks to make when done() called: maps Object to Runnable */
private final Map<Object, Runnable> doneCallbacks
- = new HashMap<Object, Runnable>(3);
+ = new HashMap<>(3);
/**
* if true, load classes (if not available locally) only from the
@@ -168,7 +168,7 @@
* from which to load the specified class.
* It will find, load, and return the class.
*/
- protected Class resolveClass(ObjectStreamClass classDesc)
+ protected Class<?> resolveClass(ObjectStreamClass classDesc)
throws IOException, ClassNotFoundException
{
/*
@@ -230,7 +230,7 @@
* resolveProxyClass is extended to acquire (if present) the location
* to determine the class loader to define the proxy class in.
*/
- protected Class resolveProxyClass(String[] interfaces)
+ protected Class<?> resolveProxyClass(String[] interfaces)
throws IOException, ClassNotFoundException
{
/*
@@ -262,7 +262,7 @@
* Fix for 4179055: Need to assist resolving sun stubs; resolve
* class locally if it is a "permitted" sun class
*/
- private Class checkSunClass(String className, AccessControlException e)
+ private Class<?> checkSunClass(String className, AccessControlException e)
throws AccessControlException
{
// ensure that we are giving out a stub for the correct reason
--- a/jdk/src/share/classes/sun/rmi/server/UnicastRef.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/server/UnicastRef.java Fri Mar 02 13:48:43 2012 -0800
@@ -65,6 +65,7 @@
Log.getLog("sun.rmi.client.call", "RMI",
AccessController.doPrivileged(
new GetBooleanAction("sun.rmi.client.logCalls")));
+ private static final long serialVersionUID = 8258372400816541186L;
protected LiveRef ref;
--- a/jdk/src/share/classes/sun/rmi/server/UnicastRef2.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/server/UnicastRef2.java Fri Mar 02 13:48:43 2012 -0800
@@ -36,6 +36,7 @@
* implementation of javax.management.remote.rmi.RMIConnector.
**/
public class UnicastRef2 extends UnicastRef {
+ private static final long serialVersionUID = 1829537514995881838L;
/**
* Create a new (empty) Unicast remote reference.
--- a/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java Fri Mar 02 13:48:43 2012 -0800
@@ -189,7 +189,7 @@
boolean permanent)
throws RemoteException
{
- Class implClass = impl.getClass();
+ Class<?> implClass = impl.getClass();
Remote stub;
try {
@@ -327,7 +327,7 @@
// marshal return value
try {
ObjectOutput out = call.getResultStream(true);
- Class rtype = method.getReturnType();
+ Class<?> rtype = method.getReturnType();
if (rtype != void.class) {
marshalValue(rtype, result, out);
}
@@ -537,7 +537,7 @@
HashToMethod_Maps() {}
protected Map<Long,Method> computeValue(Class<?> remoteClass) {
- Map<Long,Method> map = new HashMap<Long,Method>();
+ Map<Long,Method> map = new HashMap<>();
for (Class<?> cl = remoteClass;
cl != null;
cl = cl.getSuperclass())
--- a/jdk/src/share/classes/sun/rmi/server/Util.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/server/Util.java Fri Mar 02 13:48:43 2012 -0800
@@ -119,12 +119,12 @@
* @throws StubNotFoundException if problem locating/creating stub or
* creating the dynamic proxy instance
**/
- public static Remote createProxy(Class implClass,
+ public static Remote createProxy(Class<?> implClass,
RemoteRef clientRef,
boolean forceStubUse)
throws StubNotFoundException
{
- Class remoteClass;
+ Class<?> remoteClass;
try {
remoteClass = getRemoteClass(implClass);
@@ -162,7 +162,7 @@
*
* @param remoteClass the class to obtain remote interfaces from
*/
- private static boolean stubClassExists(Class remoteClass) {
+ private static boolean stubClassExists(Class<?> remoteClass) {
if (!withoutStubs.containsKey(remoteClass)) {
try {
Class.forName(remoteClass.getName() + "_Stub",
@@ -182,11 +182,11 @@
* @throws ClassNotFoundException if no class is found to have a
* remote interface
*/
- private static Class getRemoteClass(Class cl)
+ private static Class<?> getRemoteClass(Class<?> cl)
throws ClassNotFoundException
{
while (cl != null) {
- Class[] interfaces = cl.getInterfaces();
+ Class<?>[] interfaces = cl.getInterfaces();
for (int i = interfaces.length -1; i >= 0; i--) {
if (Remote.class.isAssignableFrom(interfaces[i]))
return cl; // this class implements remote object
@@ -206,8 +206,8 @@
* any illegal remote interfaces
* @throws NullPointerException if remoteClass is null
*/
- private static Class[] getRemoteInterfaces(Class remoteClass) {
- ArrayList<Class<?>> list = new ArrayList<Class<?>>();
+ private static Class<?>[] getRemoteInterfaces(Class<?> remoteClass) {
+ ArrayList<Class<?>> list = new ArrayList<>();
getRemoteInterfaces(list, remoteClass);
return list.toArray(new Class<?>[list.size()]);
}
@@ -220,15 +220,15 @@
* any illegal remote interfaces
* @throws NullPointerException if the specified class or list is null
*/
- private static void getRemoteInterfaces(ArrayList<Class<?>> list, Class cl) {
- Class superclass = cl.getSuperclass();
+ private static void getRemoteInterfaces(ArrayList<Class<?>> list, Class<?> cl) {
+ Class<?> superclass = cl.getSuperclass();
if (superclass != null) {
getRemoteInterfaces(list, superclass);
}
- Class[] interfaces = cl.getInterfaces();
+ Class<?>[] interfaces = cl.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
- Class intf = interfaces[i];
+ Class<?> intf = interfaces[i];
/*
* If it is a remote interface (if it extends from
* java.rmi.Remote) and is not already in the list,
@@ -272,7 +272,7 @@
* the stub class is initiated from class loader of the specified class
* (which may be the bootstrap class loader).
**/
- private static RemoteStub createStub(Class remoteClass, RemoteRef ref)
+ private static RemoteStub createStub(Class<?> remoteClass, RemoteRef ref)
throws StubNotFoundException
{
String stubname = remoteClass.getName() + "_Stub";
@@ -285,7 +285,7 @@
try {
Class<?> stubcl =
Class.forName(stubname, false, remoteClass.getClassLoader());
- Constructor cons = stubcl.getConstructor(stubConsParamTypes);
+ Constructor<?> cons = stubcl.getConstructor(stubConsParamTypes);
return (RemoteStub) cons.newInstance(new Object[] { ref });
} catch (ClassNotFoundException e) {
@@ -315,7 +315,7 @@
static Skeleton createSkeleton(Remote object)
throws SkeletonNotFoundException
{
- Class cl;
+ Class<?> cl;
try {
cl = getRemoteClass(object.getClass());
} catch (ClassNotFoundException ex ) {
@@ -327,7 +327,7 @@
// now try to load the skeleton based ont he name of the class
String skelname = cl.getName() + "_Skel";
try {
- Class skelcl = Class.forName(skelname, false, cl.getClassLoader());
+ Class<?> skelcl = Class.forName(skelname, false, cl.getClassLoader());
return (Skeleton)skelcl.newInstance();
} catch (ClassNotFoundException ex) {
@@ -391,12 +391,12 @@
private static String getMethodNameAndDescriptor(Method m) {
StringBuffer desc = new StringBuffer(m.getName());
desc.append('(');
- Class[] paramTypes = m.getParameterTypes();
+ Class<?>[] paramTypes = m.getParameterTypes();
for (int i = 0; i < paramTypes.length; i++) {
desc.append(getTypeDescriptor(paramTypes[i]));
}
desc.append(')');
- Class returnType = m.getReturnType();
+ Class<?> returnType = m.getReturnType();
if (returnType == void.class) { // optimization: handle void here
desc.append('V');
} else {
@@ -409,7 +409,7 @@
* Get the descriptor of a particular type, as appropriate for either
* a parameter or return type in a method descriptor.
*/
- private static String getTypeDescriptor(Class type) {
+ private static String getTypeDescriptor(Class<?> type) {
if (type.isPrimitive()) {
if (type == int.class) {
return "I";
@@ -454,7 +454,7 @@
* top-level type (and perhaps other enclosing types), the
* separator will be '$', etc.
**/
- public static String getUnqualifiedName(Class c) {
+ public static String getUnqualifiedName(Class<?> c) {
String binaryName = c.getName();
return binaryName.substring(binaryName.lastIndexOf('.') + 1);
}
--- a/jdk/src/share/classes/sun/rmi/server/WeakClassHashMap.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/server/WeakClassHashMap.java Fri Mar 02 13:48:43 2012 -0800
@@ -46,8 +46,7 @@
**/
public abstract class WeakClassHashMap<V> {
- private Map<Class<?>,ValueCell<V>> internalMap =
- new WeakHashMap<Class<?>,ValueCell<V>>();
+ private Map<Class<?>,ValueCell<V>> internalMap = new WeakHashMap<>();
protected WeakClassHashMap() { }
--- a/jdk/src/share/classes/sun/rmi/transport/ConnectionInputStream.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/ConnectionInputStream.java Fri Mar 02 13:48:43 2012 -0800
@@ -43,7 +43,7 @@
private boolean dgcAckNeeded = false;
/** Hashtable mapping Endpoints to lists of LiveRefs to register */
- private Map incomingRefTable = new HashMap(5);
+ private Map<Endpoint, List<LiveRef>> incomingRefTable = new HashMap<>(5);
/** identifier for gc ack*/
private UID ackID;
@@ -70,10 +70,10 @@
Endpoint ep = ref.getEndpoint();
// check whether endpoint is already in the hashtable
- List refList = (List) incomingRefTable.get(ep);
+ List<LiveRef> refList = incomingRefTable.get(ep);
if (refList == null) {
- refList = new ArrayList();
+ refList = new ArrayList<LiveRef>();
incomingRefTable.put(ep, refList);
}
@@ -89,13 +89,9 @@
*/
void registerRefs() throws IOException {
if (!incomingRefTable.isEmpty()) {
- Set entrySet = incomingRefTable.entrySet();
- Iterator iter = entrySet.iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry) iter.next();
- Endpoint ep = (Endpoint) entry.getKey();
- List refList = (List) entry.getValue();
- DGCClient.registerRefs(ep, refList);
+ for (Map.Entry<Endpoint, List<LiveRef>> entry :
+ incomingRefTable.entrySet()) {
+ DGCClient.registerRefs(entry.getKey(), entry.getValue());
}
}
}
--- a/jdk/src/share/classes/sun/rmi/transport/DGCAckHandler.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/DGCAckHandler.java Fri Mar 02 13:48:43 2012 -0800
@@ -78,7 +78,7 @@
Collections.synchronizedMap(new HashMap<UID,DGCAckHandler>());
private final UID id;
- private List<Object> objList = new ArrayList<Object>(); // null if released
+ private List<Object> objList = new ArrayList<>(); // null if released
private Future<?> task = null;
/**
--- a/jdk/src/share/classes/sun/rmi/transport/DGCClient.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/DGCClient.java Fri Mar 02 13:48:43 2012 -0800
@@ -125,7 +125,7 @@
* All of the LiveRefs in the list must be for remote objects at the
* given endpoint.
*/
- static void registerRefs(Endpoint ep, List refs) {
+ static void registerRefs(Endpoint ep, List<LiveRef> refs) {
/*
* Look up the given endpoint and register the refs with it.
* The retrieved entry may get removed from the global endpoint
@@ -176,9 +176,9 @@
private DGC dgc;
/** table of refs held for endpoint: maps LiveRef to RefEntry */
- private Map refTable = new HashMap(5);
+ private Map<LiveRef, RefEntry> refTable = new HashMap<>(5);
/** set of RefEntry instances from last (failed) dirty call */
- private Set invalidRefs = new HashSet(5);
+ private Set<RefEntry> invalidRefs = new HashSet<>(5);
/** true if this entry has been removed from the global table */
private boolean removed = false;
@@ -200,12 +200,12 @@
private boolean interruptible = false;
/** reference queue for phantom references */
- private ReferenceQueue refQueue = new ReferenceQueue();
+ private ReferenceQueue<LiveRef> refQueue = new ReferenceQueue<>();
/** set of clean calls that need to be made */
- private Set pendingCleans = new HashSet(5);
+ private Set<CleanRequest> pendingCleans = new HashSet<>(5);
/** global endpoint table: maps Endpoint to EndpointEntry */
- private static Map endpointTable = new HashMap(5);
+ private static Map<Endpoint,EndpointEntry> endpointTable = new HashMap<>(5);
/** handle for GC latency request (for future cancellation) */
private static GC.LatencyRequest gcLatencyRequest = null;
@@ -215,7 +215,7 @@
*/
public static EndpointEntry lookup(Endpoint ep) {
synchronized (endpointTable) {
- EndpointEntry entry = (EndpointEntry) endpointTable.get(ep);
+ EndpointEntry entry = endpointTable.get(ep);
if (entry == null) {
entry = new EndpointEntry(ep);
endpointTable.put(ep, entry);
@@ -260,10 +260,10 @@
*
* This method must NOT be called while synchronized on this entry.
*/
- public boolean registerRefs(List refs) {
+ public boolean registerRefs(List<LiveRef> refs) {
assert !Thread.holdsLock(this);
- Set refsToDirty = null; // entries for refs needing dirty
+ Set<RefEntry> refsToDirty = null; // entries for refs needing dirty
long sequenceNum; // sequence number for dirty call
synchronized (this) {
@@ -271,18 +271,18 @@
return false;
}
- Iterator iter = refs.iterator();
+ Iterator<LiveRef> iter = refs.iterator();
while (iter.hasNext()) {
- LiveRef ref = (LiveRef) iter.next();
+ LiveRef ref = iter.next();
assert ref.getEndpoint().equals(endpoint);
- RefEntry refEntry = (RefEntry) refTable.get(ref);
+ RefEntry refEntry = refTable.get(ref);
if (refEntry == null) {
LiveRef refClone = (LiveRef) ref.clone();
refEntry = new RefEntry(refClone);
refTable.put(refClone, refEntry);
if (refsToDirty == null) {
- refsToDirty = new HashSet(5);
+ refsToDirty = new HashSet<>(5);
}
refsToDirty.add(refEntry);
}
@@ -345,7 +345,7 @@
*
* This method must NOT be called while synchronized on this entry.
*/
- private void makeDirtyCall(Set refEntries, long sequenceNum) {
+ private void makeDirtyCall(Set<RefEntry> refEntries, long sequenceNum) {
assert !Thread.holdsLock(this);
ObjID[] ids;
@@ -443,9 +443,9 @@
* refs, so that clean calls for them in the future
* will be strong.
*/
- Iterator iter = refEntries.iterator();
+ Iterator<RefEntry> iter = refEntries.iterator();
while (iter.hasNext()) {
- RefEntry refEntry = (RefEntry) iter.next();
+ RefEntry refEntry = iter.next();
refEntry.markDirtyFailed();
}
}
@@ -497,7 +497,7 @@
long timeToWait;
RefEntry.PhantomLiveRef phantom = null;
boolean needRenewal = false;
- Set refsToDirty = null;
+ Set<RefEntry> refsToDirty = null;
long sequenceNum = Long.MIN_VALUE;
synchronized (EndpointEntry.this) {
@@ -564,7 +564,7 @@
needRenewal = true;
if (!invalidRefs.isEmpty()) {
refsToDirty = invalidRefs;
- invalidRefs = new HashSet(5);
+ invalidRefs = new HashSet<>(5);
}
sequenceNum = getNextSequenceNum();
}
@@ -594,8 +594,8 @@
private void processPhantomRefs(RefEntry.PhantomLiveRef phantom) {
assert Thread.holdsLock(this);
- Set strongCleans = null;
- Set normalCleans = null;
+ Set<RefEntry> strongCleans = null;
+ Set<RefEntry> normalCleans = null;
do {
RefEntry refEntry = phantom.getRefEntry();
@@ -603,12 +603,12 @@
if (refEntry.isRefSetEmpty()) {
if (refEntry.hasDirtyFailed()) {
if (strongCleans == null) {
- strongCleans = new HashSet(5);
+ strongCleans = new HashSet<>(5);
}
strongCleans.add(refEntry);
} else {
if (normalCleans == null) {
- normalCleans = new HashSet(5);
+ normalCleans = new HashSet<>(5);
}
normalCleans.add(refEntry);
}
@@ -659,9 +659,9 @@
private void makeCleanCalls() {
assert !Thread.holdsLock(this);
- Iterator iter = pendingCleans.iterator();
+ Iterator<CleanRequest> iter = pendingCleans.iterator();
while (iter.hasNext()) {
- CleanRequest request = (CleanRequest) iter.next();
+ CleanRequest request = iter.next();
try {
dgc.clean(request.objIDs, request.sequenceNum, vmid,
request.strong);
@@ -683,11 +683,11 @@
* Create an array of ObjIDs (needed for the DGC remote calls)
* from the ids in the given set of refs.
*/
- private static ObjID[] createObjIDArray(Set refEntries) {
+ private static ObjID[] createObjIDArray(Set<RefEntry> refEntries) {
ObjID[] ids = new ObjID[refEntries.size()];
- Iterator iter = refEntries.iterator();
+ Iterator<RefEntry> iter = refEntries.iterator();
for (int i = 0; i < ids.length; i++) {
- ids[i] = ((RefEntry) iter.next()).getRef().getObjID();
+ ids[i] = iter.next().getRef().getObjID();
}
return ids;
}
@@ -704,7 +704,7 @@
/** LiveRef value for this entry (not a registered instance) */
private LiveRef ref;
/** set of phantom references to registered instances */
- private Set refSet = new HashSet(5);
+ private Set<PhantomLiveRef> refSet = new HashSet<>(5);
/** true if a dirty call containing this ref has failed */
private boolean dirtyFailed = false;
@@ -792,7 +792,7 @@
* used to detect when the LiveRef becomes permanently
* unreachable in this VM.
*/
- private class PhantomLiveRef extends PhantomReference {
+ private class PhantomLiveRef extends PhantomReference<LiveRef> {
public PhantomLiveRef(LiveRef ref) {
super(ref, EndpointEntry.this.refQueue);
--- a/jdk/src/share/classes/sun/rmi/transport/DGCImpl.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/DGCImpl.java Fri Mar 02 13:48:43 2012 -0800
@@ -84,7 +84,7 @@
/** remote implementation of DGC interface for this VM */
private static DGCImpl dgc;
/** table that maps VMID to LeaseInfo */
- private Map<VMID,LeaseInfo> leaseTable = new HashMap<VMID,LeaseInfo>();
+ private Map<VMID,LeaseInfo> leaseTable = new HashMap<>();
/** checks for lease expiration */
private Future<?> checker = null;
@@ -236,7 +236,7 @@
long time = System.currentTimeMillis();
/* List of vmids that need to be removed from the leaseTable */
- List<LeaseInfo> toUnregister = new ArrayList<LeaseInfo>();
+ List<LeaseInfo> toUnregister = new ArrayList<>();
/* Build a list of leaseInfo objects that need to have
* targets removed from their notifySet. Remove expired
@@ -313,7 +313,7 @@
private static class LeaseInfo {
VMID vmid;
long expiration;
- Set<Target> notifySet = new HashSet<Target>();
+ Set<Target> notifySet = new HashSet<>();
LeaseInfo(VMID vmid, long lease) {
this.vmid = vmid;
--- a/jdk/src/share/classes/sun/rmi/transport/ObjectTable.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/ObjectTable.java Fri Mar 02 13:48:43 2012 -0800
@@ -62,9 +62,9 @@
/** tables mapping to Target, keyed from ObjectEndpoint and impl object */
private static final Map<ObjectEndpoint,Target> objTable =
- new HashMap<ObjectEndpoint,Target>();
+ new HashMap<>();
private static final Map<WeakRef,Target> implTable =
- new HashMap<WeakRef,Target>();
+ new HashMap<>();
/**
* lock guarding keepAliveCount, reaper, and gcLatencyRequest.
@@ -79,7 +79,7 @@
private static Thread reaper = null;
/** queue notified when weak refs in the table are cleared */
- static final ReferenceQueue reapQueue = new ReferenceQueue();
+ static final ReferenceQueue<Object> reapQueue = new ReferenceQueue<>();
/** handle for GC latency request (for future cancellation) */
private static GC.LatencyRequest gcLatencyRequest = null;
--- a/jdk/src/share/classes/sun/rmi/transport/StreamRemoteCall.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/StreamRemoteCall.java Fri Mar 02 13:48:43 2012 -0800
@@ -199,6 +199,7 @@
/**
* Do whatever it takes to execute the call.
*/
+ @SuppressWarnings("fallthrough")
public void executeCall() throws Exception {
byte returnType;
@@ -252,6 +253,7 @@
} else {
throw new UnmarshalException("Return type not Exception");
}
+ // Exception is thrown before fallthrough can occur
default:
if (Transport.transportLog.isLoggable(Log.BRIEF)) {
Transport.transportLog.log(Log.BRIEF,
--- a/jdk/src/share/classes/sun/rmi/transport/Target.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/Target.java Fri Mar 02 13:48:43 2012 -0800
@@ -53,9 +53,10 @@
/** stub for remote object */
private final Remote stub;
/** set of clients that hold references to this target */
- private final Vector refSet = new Vector();
+ private final Vector<VMID> refSet = new Vector<>();
/** table that maps client endpoints to sequence numbers */
- private final Hashtable sequenceTable = new Hashtable(5);
+ private final Hashtable<VMID, SequenceEntry> sequenceTable =
+ new Hashtable<>(5);
/** access control context in which target was created */
private final AccessControlContext acc;
/** context class loader in which target was created */
@@ -241,7 +242,7 @@
*/
synchronized void referenced(long sequenceNum, VMID vmid) {
// check sequence number for vmid
- SequenceEntry entry = (SequenceEntry) sequenceTable.get(vmid);
+ SequenceEntry entry = sequenceTable.get(vmid);
if (entry == null) {
sequenceTable.put(vmid, new SequenceEntry(sequenceNum));
} else if (entry.sequenceNum < sequenceNum) {
@@ -280,7 +281,7 @@
synchronized void unreferenced(long sequenceNum, VMID vmid, boolean strong)
{
// check sequence number for vmid
- SequenceEntry entry = (SequenceEntry) sequenceTable.get(vmid);
+ SequenceEntry entry = sequenceTable.get(vmid);
if (entry == null || entry.sequenceNum > sequenceNum) {
// late clean call; ignore
return;
@@ -366,9 +367,9 @@
*/
unpinImpl();
DGCImpl dgc = DGCImpl.getDGCImpl();
- Enumeration enum_ = refSet.elements();
+ Enumeration<VMID> enum_ = refSet.elements();
while (enum_.hasMoreElements()) {
- VMID vmid = (VMID) enum_.nextElement();
+ VMID vmid = enum_.nextElement();
dgc.unregisterTarget(vmid, this);
}
return true;
--- a/jdk/src/share/classes/sun/rmi/transport/Transport.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/Transport.java Fri Mar 02 13:48:43 2012 -0800
@@ -62,7 +62,7 @@
Log.getLog("sun.rmi.transport.misc", "transport", Transport.logLevel);
/** References the current transport when a call is being serviced */
- private static final ThreadLocal currentTransport = new ThreadLocal();
+ private static final ThreadLocal<Transport> currentTransport = new ThreadLocal<>();
/** ObjID for DGCImpl */
private static final ObjID dgcID = new ObjID(ObjID.DGC_ID);
@@ -104,7 +104,7 @@
* returns null.
**/
static Transport currentTransport() {
- return (Transport) currentTransport.get();
+ return currentTransport.get();
}
/**
--- a/jdk/src/share/classes/sun/rmi/transport/WeakRef.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/WeakRef.java Fri Mar 02 13:48:43 2012 -0800
@@ -41,7 +41,7 @@
* @author Ann Wollrath
* @author Peter Jones
*/
-class WeakRef extends WeakReference {
+class WeakRef extends WeakReference<Object> {
/** value of the referent's "identity" hash code */
private int hashValue;
@@ -60,7 +60,7 @@
/**
* Create a new WeakRef to the given object, registered with a queue.
*/
- public WeakRef(Object obj, ReferenceQueue q) {
+ public WeakRef(Object obj, ReferenceQueue<Object> q) {
super(obj, q);
setHashValue(obj); // cache object's "identity" hash code
}
--- a/jdk/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java Fri Mar 02 13:48:43 2012 -0800
@@ -33,6 +33,7 @@
* in a client's request.
*/
class CGIClientException extends Exception {
+ private static final long serialVersionUID = 8147981687059865216L;
public CGIClientException(String s) {
super(s);
@@ -44,6 +45,8 @@
*/
class CGIServerException extends Exception {
+ private static final long serialVersionUID = 6928425456704527017L;
+
public CGIServerException(String s) {
super(s);
}
@@ -111,9 +114,9 @@
};
/* construct table mapping command strings to handlers */
- private static Hashtable commandLookup;
+ private static Hashtable<String, CGICommandHandler> commandLookup;
static {
- commandLookup = new Hashtable();
+ commandLookup = new Hashtable<>();
for (int i = 0; i < commands.length; ++ i)
commandLookup.put(commands[i].getName(), commands[i]);
}
@@ -140,7 +143,7 @@
param = QueryString.substring(delim + 1);
}
CGICommandHandler handler =
- (CGICommandHandler) commandLookup.get(command);
+ commandLookup.get(command);
if (handler != null)
try {
handler.execute(param);
@@ -200,7 +203,7 @@
/**
* "forward" command: Forward request body to local port on the server,
- * and send reponse back to client.
+ * and send response back to client.
*/
final class CGIForwardCommand implements CGICommandHandler {
@@ -208,6 +211,11 @@
return "forward";
}
+ @SuppressWarnings("deprecation")
+ private String getLine (DataInputStream socketIn) throws IOException {
+ return socketIn.readLine();
+ }
+
public void execute(String param) throws CGIClientException, CGIServerException
{
if (!CGIHandler.RequestMethod.equals("POST"))
@@ -276,7 +284,7 @@
int responseContentLength = -1;
do {
try {
- line = socketIn.readLine();
+ line = getLine(socketIn);
} catch (IOException e) {
throw new CGIServerException("error reading from server");
}
@@ -285,8 +293,8 @@
"unexpected EOF reading server response");
if (line.toLowerCase().startsWith(key)) {
- if (contentLengthFound)
- ; // what would we want to do in this case??
+ // if contentLengthFound is true
+ // we should probably do something here
responseContentLength =
Integer.parseInt(line.substring(key.length()).trim());
contentLengthFound = true;
--- a/jdk/src/share/classes/sun/rmi/transport/proxy/HttpInputStream.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/proxy/HttpInputStream.java Fri Mar 02 13:48:43 2012 -0800
@@ -70,8 +70,8 @@
throw new EOFException();
if (line.toLowerCase().startsWith(key)) {
- if (contentLengthFound)
- ; // what would we want to do in this case??
+ // if contentLengthFound is true
+ // we should probably do something here
bytesLeft =
Integer.parseInt(line.substring(key.length()).trim());
contentLengthFound = true;
--- a/jdk/src/share/classes/sun/rmi/transport/proxy/HttpSendSocket.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/proxy/HttpSendSocket.java Fri Mar 02 13:48:43 2012 -0800
@@ -203,7 +203,7 @@
message += "HttpSendSocket.readNotify: response body: ";
try {
- DataInputStream din = new DataInputStream(in);
+ BufferedReader din = new BufferedReader(new InputStreamReader(in));
String line;
while ((line = din.readLine()) != null)
message += line + lineSeparator;
--- a/jdk/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java Fri Mar 02 13:48:43 2012 -0800
@@ -74,20 +74,21 @@
"sun.rmi.transport.proxy.eagerHttpFallback")).booleanValue();
/** table of hosts successfully connected to and the factory used */
- private Hashtable successTable = new Hashtable();
+ private Hashtable<String, RMISocketFactory> successTable =
+ new Hashtable<>();
/** maximum number of hosts to remember successful connection to */
private static final int MaxRememberedHosts = 64;
/** list of the hosts in successTable in initial connection order */
- private Vector hostList = new Vector(MaxRememberedHosts);
+ private Vector<String> hostList = new Vector<>(MaxRememberedHosts);
- /** default factory to initally use for direct socket connection */
+ /** default factory for initial use for direct socket connection */
protected RMISocketFactory initialFactory = new RMIDirectSocketFactory();
/** ordered list of factories to try as alternate connection
* mechanisms if a direct socket connections fails */
- protected Vector altFactoryList;
+ protected Vector<RMISocketFactory> altFactoryList;
/**
* Create a RMIMasterSocketFactory object. Establish order of
@@ -95,7 +96,7 @@
* socket connection fails.
*/
public RMIMasterSocketFactory() {
- altFactoryList = new Vector(2);
+ altFactoryList = new Vector<>(2);
boolean setFactories = false;
try {
@@ -152,7 +153,7 @@
* If we remember successfully connecting to this host before,
* use the same factory.
*/
- factory = (RMISocketFactory) successTable.get(host);
+ factory = successTable.get(host);
if (factory != null) {
if (proxyLog.isLoggable(Log.BRIEF)) {
proxyLog.log(Log.BRIEF,
@@ -207,9 +208,7 @@
return initialSocket;
- } catch (UnknownHostException e) {
- initialFailure = e;
- } catch (NoRouteToHostException e) {
+ } catch (UnknownHostException | NoRouteToHostException e) {
initialFailure = e;
} catch (SocketException e) {
if (eagerHttpFallback) {
@@ -227,22 +226,20 @@
// Finally, try any alternate connection mechanisms.
for (int i = 0; i < altFactoryList.size(); ++ i) {
- factory = (RMISocketFactory) altFactoryList.elementAt(i);
- try {
- if (proxyLog.isLoggable(Log.BRIEF)) {
- proxyLog.log(Log.BRIEF,
- "trying with factory: " + factory);
- }
-
+ factory = altFactoryList.elementAt(i);
+ if (proxyLog.isLoggable(Log.BRIEF)) {
+ proxyLog.log(Log.BRIEF,
+ "trying with factory: " + factory);
+ }
+ try (Socket testSocket =
+ factory.createSocket(host, port)) {
// For HTTP connections, the output (POST request) must
// be sent before we verify a successful connection.
// So, sacrifice a socket for the sake of testing...
// The following sequence should verify a successful
// HTTP connection if no IOException is thrown.
- Socket testSocket = factory.createSocket(host, port);
InputStream in = testSocket.getInputStream();
int b = in.read(); // probably -1 for EOF...
- testSocket.close();
} catch (IOException ex) {
if (proxyLog.isLoggable(Log.BRIEF)) {
proxyLog.log(Log.BRIEF, "factory failed: ", ex);
@@ -276,9 +273,7 @@
}
// if connector ever does get socket, it won't be used
connector.notUsed();
- } catch (UnknownHostException e) {
- initialFailure = e;
- } catch (NoRouteToHostException e) {
+ } catch (UnknownHostException | NoRouteToHostException e) {
initialFailure = e;
} catch (SocketException e) {
if (eagerHttpFallback) {
--- a/jdk/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java Fri Mar 02 13:48:43 2012 -0800
@@ -85,7 +85,7 @@
private DataOutputStream dataOut;
/** table holding currently open connection IDs and related info */
- private Hashtable connectionTable = new Hashtable(7);
+ private Hashtable<Integer, MultiplexConnectionInfo> connectionTable = new Hashtable<>(7);
/** number of currently open connections */
private int numConnections = 0;
@@ -131,7 +131,6 @@
{
try {
int op, id, length;
- Integer idObj;
MultiplexConnectionInfo info;
while (true) {
@@ -148,9 +147,7 @@
multiplexLog.log(Log.VERBOSE, "operation OPEN " + id);
}
- idObj = new Integer(id);
- info =
- (MultiplexConnectionInfo) connectionTable.get(idObj);
+ info = connectionTable.get(id);
if (info != null)
throw new IOException(
"OPEN: Connection ID already exists");
@@ -158,7 +155,7 @@
info.in = new MultiplexInputStream(this, info, 2048);
info.out = new MultiplexOutputStream(this, info, 2048);
synchronized (connectionTable) {
- connectionTable.put(idObj, info);
+ connectionTable.put(id, info);
++ numConnections;
}
sun.rmi.transport.Connection conn;
@@ -174,9 +171,7 @@
multiplexLog.log(Log.VERBOSE, "operation CLOSE " + id);
}
- idObj = new Integer(id);
- info =
- (MultiplexConnectionInfo) connectionTable.get(idObj);
+ info = connectionTable.get(id);
if (info == null)
throw new IOException(
"CLOSE: Invalid connection ID");
@@ -185,7 +180,7 @@
if (!info.closed)
sendCloseAck(info);
synchronized (connectionTable) {
- connectionTable.remove(idObj);
+ connectionTable.remove(id);
-- numConnections;
}
break;
@@ -199,9 +194,7 @@
"operation CLOSEACK " + id);
}
- idObj = new Integer(id);
- info =
- (MultiplexConnectionInfo) connectionTable.get(idObj);
+ info = connectionTable.get(id);
if (info == null)
throw new IOException(
"CLOSEACK: Invalid connection ID");
@@ -211,7 +204,7 @@
info.in.disconnect();
info.out.disconnect();
synchronized (connectionTable) {
- connectionTable.remove(idObj);
+ connectionTable.remove(id);
-- numConnections;
}
break;
@@ -219,9 +212,7 @@
// remote endpoint declaring additional bytes receivable
case REQUEST:
id = dataIn.readUnsignedShort();
- idObj = new Integer(id);
- info =
- (MultiplexConnectionInfo) connectionTable.get(idObj);
+ info = connectionTable.get(id);
if (info == null)
throw new IOException(
"REQUEST: Invalid connection ID");
@@ -238,9 +229,7 @@
// remote endpoint transmitting data packet
case TRANSMIT:
id = dataIn.readUnsignedShort();
- idObj = new Integer(id);
- info =
- (MultiplexConnectionInfo) connectionTable.get(idObj);
+ info = connectionTable.get(id);
if (info == null)
throw new IOException("SEND: Invalid connection ID");
length = dataIn.readInt();
@@ -273,7 +262,6 @@
// If all possible 32768 IDs are used,
// this method will block searching for a new ID forever.
int id;
- Integer idObj;
do {
lastID = (++ lastID) & 0x7FFF;
id = lastID;
@@ -283,8 +271,7 @@
// two endpoints.
if (orig)
id |= 0x8000;
- idObj = new Integer(id);
- } while (connectionTable.get(idObj) != null);
+ } while (connectionTable.get(id) != null);
// create multiplexing streams and bookkeeping information
MultiplexConnectionInfo info = new MultiplexConnectionInfo(id);
@@ -298,7 +285,7 @@
if (numConnections >= maxConnections)
throw new IOException("Cannot exceed " + maxConnections +
" simultaneous multiplexed connections");
- connectionTable.put(idObj, info);
+ connectionTable.put(id, info);
++ numConnections;
}
@@ -331,10 +318,10 @@
return;
alive = false;
- Enumeration enum_ = connectionTable.elements();
+ Enumeration<MultiplexConnectionInfo> enum_ =
+ connectionTable.elements();
while (enum_.hasMoreElements()) {
- MultiplexConnectionInfo info =
- (MultiplexConnectionInfo) enum_.nextElement();
+ MultiplexConnectionInfo info = enum_.nextElement();
info.in.disconnect();
info.out.disconnect();
}
--- a/jdk/src/share/classes/sun/rmi/transport/tcp/TCPChannel.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/tcp/TCPChannel.java Fri Mar 02 13:48:43 2012 -0800
@@ -64,7 +64,7 @@
private final TCPTransport tr;
/** list of cached connections */
private final List<TCPConnection> freeList =
- new ArrayList<TCPConnection>();
+ new ArrayList<>();
/** frees cached connections that have expired (guarded by freeList) */
private Future<?> reaper = null;
@@ -480,7 +480,7 @@
private TCPTransport transport;
/** queue of connections to be accepted */
- private List<Connection> queue = new ArrayList<Connection>();
+ private List<Connection> queue = new ArrayList<>();
/** thread ID counter */
private static int threadNum = 0;
--- a/jdk/src/share/classes/sun/rmi/transport/tcp/TCPEndpoint.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/tcp/TCPEndpoint.java Fri Mar 02 13:48:43 2012 -0800
@@ -148,7 +148,7 @@
// TBD: should this be a weak hash table?
private static final
Map<TCPEndpoint,LinkedList<TCPEndpoint>> localEndpoints =
- new HashMap<TCPEndpoint,LinkedList<TCPEndpoint>>();
+ new HashMap<>();
/**
* Create an endpoint for a specified host and port.
@@ -623,10 +623,9 @@
try {
TCPEndpoint.shedConnectionCaches();
// REMIND: should we retry createSocket?
- } catch (OutOfMemoryError mem) {
+ } catch (OutOfMemoryError | Exception mem) {
// don't quit if out of memory
- } catch (Exception ex) {
- // don't quit if shed fails non-catastrophically
+ // or shed fails non-catastrophically
}
throw new ConnectIOException("Exception creating connection to: " +
--- a/jdk/src/share/classes/sun/rmi/transport/tcp/TCPTransport.java Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/transport/tcp/TCPTransport.java Fri Mar 02 13:48:43 2012 -0800
@@ -119,7 +119,7 @@
/** client host for the current thread's connection */
private static final ThreadLocal<ConnectionHandler>
- threadConnectionHandler = new ThreadLocal<ConnectionHandler>();
+ threadConnectionHandler = new ThreadLocal<>();
/** endpoints for this transport */
private final LinkedList<TCPEndpoint> epList;
@@ -129,7 +129,7 @@
private ServerSocket server = null;
/** table mapping endpoints to channels */
private final Map<TCPEndpoint,Reference<TCPChannel>> channelTable =
- new WeakHashMap<TCPEndpoint,Reference<TCPChannel>>();
+ new WeakHashMap<>();
static final RMISocketFactory defaultSocketFactory =
RMISocketFactory.getDefaultSocketFactory();