From 0006ef0cc8131ef46b06c772a23c5b21b32af8ba Mon Sep 17 00:00:00 2001 From: Kurchi Subhra Hazra Date: Fri, 2 Mar 2012 13:48:43 -0800 Subject: [PATCH 1/2] 7146763: Warnings cleanup in the sun.rmi and related packages Cleanup warnings and use jkd7 features in sun.rmi.* Reviewed-by: smarks, chegar, forax, dmocek --- jdk/make/sun/rmi/cgi/Makefile | 2 + jdk/make/sun/rmi/registry/Makefile | 3 + jdk/make/sun/rmi/rmi/Makefile | 3 + jdk/make/sun/rmi/rmid/Makefile | 2 + .../sun/rmi/rmid/ExecOptionPermission.java | 12 ++-- .../com/sun/rmi/rmid/ExecPermission.java | 10 +-- .../classes/sun/rmi/log/ReliableLog.java | 21 +++--- .../sun/rmi/registry/RegistryImpl.java | 8 +-- .../sun/rmi/rmic/BatchEnvironment.java | 6 +- jdk/src/share/classes/sun/rmi/rmic/Main.java | 30 +++++---- .../classes/sun/rmi/rmic/RMIGenerator.java | 17 +++-- .../classes/sun/rmi/rmic/newrmic/Main.java | 2 +- .../sun/rmi/rmic/newrmic/Resources.java | 2 +- .../sun/rmi/server/ActivatableRef.java | 6 +- .../classes/sun/rmi/server/Activation.java | 38 ++++++----- .../sun/rmi/server/ActivationGroupImpl.java | 15 ++--- .../classes/sun/rmi/server/LoaderHandler.java | 66 +++++++++---------- .../sun/rmi/server/MarshalInputStream.java | 10 +-- .../classes/sun/rmi/server/UnicastRef.java | 1 + .../classes/sun/rmi/server/UnicastRef2.java | 1 + .../sun/rmi/server/UnicastServerRef.java | 6 +- .../share/classes/sun/rmi/server/Util.java | 38 +++++------ .../sun/rmi/server/WeakClassHashMap.java | 3 +- .../rmi/transport/ConnectionInputStream.java | 16 ++--- .../sun/rmi/transport/DGCAckHandler.java | 2 +- .../classes/sun/rmi/transport/DGCClient.java | 58 ++++++++-------- .../classes/sun/rmi/transport/DGCImpl.java | 6 +- .../sun/rmi/transport/ObjectTable.java | 6 +- .../sun/rmi/transport/StreamRemoteCall.java | 2 + .../classes/sun/rmi/transport/Target.java | 13 ++-- .../classes/sun/rmi/transport/Transport.java | 4 +- .../classes/sun/rmi/transport/WeakRef.java | 4 +- .../sun/rmi/transport/proxy/CGIHandler.java | 22 +++++-- .../rmi/transport/proxy/HttpInputStream.java | 4 +- .../rmi/transport/proxy/HttpSendSocket.java | 2 +- .../proxy/RMIMasterSocketFactory.java | 37 +++++------ .../transport/tcp/ConnectionMultiplexer.java | 41 ++++-------- .../sun/rmi/transport/tcp/TCPChannel.java | 4 +- .../sun/rmi/transport/tcp/TCPEndpoint.java | 7 +- .../sun/rmi/transport/tcp/TCPTransport.java | 4 +- 40 files changed, 266 insertions(+), 268 deletions(-) diff --git a/jdk/make/sun/rmi/cgi/Makefile b/jdk/make/sun/rmi/cgi/Makefile index 0400417b55e..48a0805aecf 100644 --- a/jdk/make/sun/rmi/cgi/Makefile +++ b/jdk/make/sun/rmi/cgi/Makefile @@ -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 diff --git a/jdk/make/sun/rmi/registry/Makefile b/jdk/make/sun/rmi/registry/Makefile index bd5dffe8b34..fbfa4b7aaca 100644 --- a/jdk/make/sun/rmi/registry/Makefile +++ b/jdk/make/sun/rmi/registry/Makefile @@ -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 diff --git a/jdk/make/sun/rmi/rmi/Makefile b/jdk/make/sun/rmi/rmi/Makefile index 1718329b00c..4aecf020d7b 100644 --- a/jdk/make/sun/rmi/rmi/Makefile +++ b/jdk/make/sun/rmi/rmi/Makefile @@ -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 diff --git a/jdk/make/sun/rmi/rmid/Makefile b/jdk/make/sun/rmi/rmid/Makefile index c8f3ce66fc1..10f36cee458 100644 --- a/jdk/make/sun/rmi/rmid/Makefile +++ b/jdk/make/sun/rmi/rmid/Makefile @@ -29,6 +29,8 @@ # BUILDDIR = ../../.. +JAVAC_MAX_WARNINGS = true +JAVAC_WARNINGS_FATAL = true PACKAGE = sun.rmi.activation PRODUCT = sun include $(BUILDDIR)/common/Defs.gmk diff --git a/jdk/src/share/classes/com/sun/rmi/rmid/ExecOptionPermission.java b/jdk/src/share/classes/com/sun/rmi/rmid/ExecOptionPermission.java index 75fe0a27fac..fd6f50cdaf3 100644 --- a/jdk/src/share/classes/com/sun/rmi/rmid/ExecOptionPermission.java +++ b/jdk/src/share/classes/com/sun/rmi/rmid/ExecOptionPermission.java @@ -223,7 +223,7 @@ public final class ExecOptionPermission extends Permission implements java.io.Serializable { - private Hashtable permissions; + private Hashtable permissions; private boolean all_allowed; // true if "*" is in the collection private static final long serialVersionUID = -1242475729790124375L; @@ -231,7 +231,7 @@ public final class ExecOptionPermission extends Permission * Create an empty ExecOptionPermissionCollection. */ public ExecOptionPermissionCollection() { - permissions = new Hashtable(11); + permissions = new Hashtable<>(11); all_allowed = false; } @@ -291,7 +291,7 @@ public final class ExecOptionPermission extends Permission 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 @@ public final class ExecOptionPermission extends Permission 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 @@ public final class ExecOptionPermission extends Permission 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 @@ public final class ExecOptionPermission extends Permission * @return an enumeration of all the ExecOptionPermission objects. */ - public Enumeration elements() + public Enumeration elements() { return permissions.elements(); } diff --git a/jdk/src/share/classes/com/sun/rmi/rmid/ExecPermission.java b/jdk/src/share/classes/com/sun/rmi/rmid/ExecPermission.java index 45674fee2b4..067b9db91bf 100644 --- a/jdk/src/share/classes/com/sun/rmi/rmid/ExecPermission.java +++ b/jdk/src/share/classes/com/sun/rmi/rmid/ExecPermission.java @@ -227,7 +227,7 @@ public final class ExecPermission extends Permission extends PermissionCollection implements java.io.Serializable { - private Vector permissions; + private Vector permissions; private static final long serialVersionUID = -3352558508888368273L; @@ -235,7 +235,7 @@ public final class ExecPermission extends Permission * Create an empty ExecPermissionCollection. */ public ExecPermissionCollection() { - permissions = new Vector(); + permissions = new Vector<>(); } /** @@ -274,10 +274,10 @@ public final class ExecPermission extends Permission if (! (permission instanceof ExecPermission)) return false; - Enumeration e = permissions.elements(); + Enumeration 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 @@ public final class ExecPermission extends Permission * * @return an enumeration of all the ExecPermission objects. */ - public Enumeration elements() + public Enumeration elements() { return permissions.elements(); } diff --git a/jdk/src/share/classes/sun/rmi/log/ReliableLog.java b/jdk/src/share/classes/sun/rmi/log/ReliableLog.java index fe512c2d87c..a24751432b3 100644 --- a/jdk/src/share/classes/sun/rmi/log/ReliableLog.java +++ b/jdk/src/share/classes/sun/rmi/log/ReliableLog.java @@ -344,10 +344,9 @@ public class ReliableLog { return ClassLoader.getSystemClassLoader(); } }); - Class cl = loader.loadClass(logClassName); - if (LogFile.class.isAssignableFrom(cl)) { - return cl.getConstructor(String.class, String.class); - } + Class 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 @@ public class ReliableLog { } 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 @@ public class ReliableLog { * @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(); } } diff --git a/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java b/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java index 1257132ae16..34579c204de 100644 --- a/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java +++ b/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java @@ -77,9 +77,9 @@ public class RegistryImpl extends java.rmi.server.RemoteServer /* indicate compatibility with JDK 1.1.x version of class */ private static final long serialVersionUID = 4666870661827494597L; private Hashtable bindings - = new Hashtable(101); + = new Hashtable<>(101); private static Hashtable allowedAccessCache - = new Hashtable(3); + = new Hashtable<>(3); private static RegistryImpl registry; private static ObjID id = new ObjID(ObjID.REGISTRY_ID); @@ -194,9 +194,9 @@ public class RegistryImpl extends java.rmi.server.RemoteServer synchronized (bindings) { int i = bindings.size(); names = new String[i]; - Enumeration enum_ = bindings.keys(); + Enumeration enum_ = bindings.keys(); while ((--i) >= 0) - names[i] = (String)enum_.nextElement(); + names[i] = enum_.nextElement(); } return names; } diff --git a/jdk/src/share/classes/sun/rmi/rmic/BatchEnvironment.java b/jdk/src/share/classes/sun/rmi/rmic/BatchEnvironment.java index 3eff0bbbb93..396d54d2548 100644 --- a/jdk/src/share/classes/sun/rmi/rmic/BatchEnvironment.java +++ b/jdk/src/share/classes/sun/rmi/rmic/BatchEnvironment.java @@ -160,7 +160,7 @@ public class BatchEnvironment extends sun.tools.javac.BatchEnvironment { } /** list of generated source files created in this environment */ - private Vector generatedFiles = new Vector(); + private Vector generatedFiles = new Vector<>(); /** * Remember a generated source file generated so that it @@ -177,9 +177,9 @@ public class BatchEnvironment extends sun.tools.javac.BatchEnvironment { */ public void deleteGeneratedFiles() { synchronized(generatedFiles) { - Enumeration enumeration = generatedFiles.elements(); + Enumeration enumeration = generatedFiles.elements(); while (enumeration.hasMoreElements()) { - File file = (File) enumeration.nextElement(); + File file = enumeration.nextElement(); file.delete(); } generatedFiles.removeAllElements(); diff --git a/jdk/src/share/classes/sun/rmi/rmic/Main.java b/jdk/src/share/classes/sun/rmi/rmic/Main.java index 562e3892ae9..54890c57291 100644 --- a/jdk/src/share/classes/sun/rmi/rmic/Main.java +++ b/jdk/src/share/classes/sun/rmi/rmic/Main.java @@ -73,14 +73,15 @@ public class Main implements sun.rmi.rmic.Constants { File destDir; int flags; long tm; - Vector classes; + Vector classes; boolean nowrite; boolean nocompile; boolean keepGenerated; boolean status; String[] generatorArgs; - Vector generators; - Class environmentClass = BatchEnvironment.class; + Vector generators; + Class environmentClass = + BatchEnvironment.class; boolean iiopGeneration = false; /** @@ -183,7 +184,7 @@ public class Main implements sun.rmi.rmic.Constants { destDir = null; flags = F_WARNINGS; tm = System.currentTimeMillis(); - classes = new Vector(); + classes = new Vector<>(); nowrite = false; nocompile = false; keepGenerated = false; @@ -191,7 +192,7 @@ public class Main implements sun.rmi.rmic.Constants { if (generatorArgs == null) { return false; } - generators = new Vector(); + generators = new Vector<>(); // Pre-process command line for @file arguments try { @@ -411,7 +412,7 @@ public class Main implements sun.rmi.rmic.Constants { // 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 @@ public class Main implements sun.rmi.rmic.Constants { // Yes, so switch to the new one... - environmentClass = envClass; + environmentClass = BatchEnvironment.class.asSubclass(environmentClass); } else { @@ -495,8 +496,9 @@ public class Main implements sun.rmi.rmic.Constants { 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 constructor = + environmentClass.getConstructor(ctorArgTypes); + result = constructor.newInstance(ctorArgs); result.reset(); } catch (Exception e) { @@ -530,7 +532,7 @@ public class Main implements sun.rmi.rmic.Constants { */ 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 @@ public class Main implements sun.rmi.rmic.Constants { 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 @@ public class Main implements sun.rmi.rmic.Constants { 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 @@ public class Main implements sun.rmi.rmic.Constants { /* * Compile a single class. + * Fallthrough is intentional */ + @SuppressWarnings("fallthrough") public boolean compileClass (ClassDeclaration c, ByteArrayOutputStream buf, BatchEnvironment env) @@ -879,6 +883,6 @@ public class Main implements sun.rmi.rmic.Constants { 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); } } diff --git a/jdk/src/share/classes/sun/rmi/rmic/RMIGenerator.java b/jdk/src/share/classes/sun/rmi/rmic/RMIGenerator.java index 043ca87901a..48390366085 100644 --- a/jdk/src/share/classes/sun/rmi/rmic/RMIGenerator.java +++ b/jdk/src/share/classes/sun/rmi/rmic/RMIGenerator.java @@ -61,7 +61,7 @@ import com.sun.corba.se.impl.util.Utility; */ public class RMIGenerator implements RMIConstants, Generator { - private static final Hashtable versionOptions = new Hashtable(); + private static final Hashtable 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 @@ public class RMIGenerator implements RMIConstants, Generator { return false; } explicitVersion = arg; - version = ((Integer) versionOptions.get(arg)).intValue(); + version = versionOptions.get(arg); argv[i] = null; } } @@ -519,7 +519,7 @@ public class RMIGenerator implements RMIConstants, Generator { * 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 catchList = computeUniqueCatchList(exceptions); /* * If we need to catch any particular exceptions (i.e. this method @@ -615,10 +615,10 @@ public class RMIGenerator implements RMIConstants, Generator { * UnexpectedException, and end the try block. */ if (catchList.size() > 0) { - for (Enumeration enumeration = catchList.elements(); + for (Enumeration 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 @@ public class RMIGenerator implements RMIConstants, Generator { * 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 computeUniqueCatchList(ClassDeclaration[] exceptions) { + Vector uniqueList = new Vector<>(); // unique exceptions to catch uniqueList.addElement(defRuntimeException); uniqueList.addElement(defRemoteException); @@ -682,8 +682,7 @@ public class RMIGenerator implements RMIConstants, Generator { * 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 diff --git a/jdk/src/share/classes/sun/rmi/rmic/newrmic/Main.java b/jdk/src/share/classes/sun/rmi/rmic/newrmic/Main.java index d80213680c6..1e59be43605 100644 --- a/jdk/src/share/classes/sun/rmi/rmic/newrmic/Main.java +++ b/jdk/src/share/classes/sun/rmi/rmic/newrmic/Main.java @@ -455,7 +455,7 @@ public class Main { BatchEnvironment env; try { Constructor 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); diff --git a/jdk/src/share/classes/sun/rmi/rmic/newrmic/Resources.java b/jdk/src/share/classes/sun/rmi/rmic/newrmic/Resources.java index f8ea7fc28c8..6b3ba17f5ee 100644 --- a/jdk/src/share/classes/sun/rmi/rmic/newrmic/Resources.java +++ b/jdk/src/share/classes/sun/rmi/rmic/newrmic/Resources.java @@ -69,7 +69,7 @@ public final class Resources { format = "missing resource key: key = \"" + key + "\", " + "arguments = \"{0}\", \"{1}\", \"{2}\""; } - return MessageFormat.format(format, args); + return MessageFormat.format(format, (Object[]) args); } /** diff --git a/jdk/src/share/classes/sun/rmi/server/ActivatableRef.java b/jdk/src/share/classes/sun/rmi/server/ActivatableRef.java index 9364e0d0d58..29a3529806a 100644 --- a/jdk/src/share/classes/sun/rmi/server/ActivatableRef.java +++ b/jdk/src/share/classes/sun/rmi/server/ActivatableRef.java @@ -80,7 +80,7 @@ public class ActivatableRef implements RemoteRef { 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 @@ public class ActivatableRef implements RemoteRef { 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) { diff --git a/jdk/src/share/classes/sun/rmi/server/Activation.java b/jdk/src/share/classes/sun/rmi/server/Activation.java index 919edb7fb65..c1ec95e6784 100644 --- a/jdk/src/share/classes/sun/rmi/server/Activation.java +++ b/jdk/src/share/classes/sun/rmi/server/Activation.java @@ -138,7 +138,6 @@ public class Activation implements Serializable { /** 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 @@ public class Activation implements Serializable { 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 @@ public class Activation implements Serializable { ActivationGroupDesc desc = null; ActivationGroupID groupID = null; long incarnation = 0; - Map objects = - new HashMap(); - Set restartSet = new HashSet(); + Map objects = new HashMap<>(); + Set restartSet = new HashSet<>(); transient ActivationInstantiator group = null; transient int status = NORMAL; @@ -1057,6 +1056,11 @@ public class Activation implements Serializable { } } + /* + * Fallthrough from TERMINATE to TERMINATING + * is intentional + */ + @SuppressWarnings("fallthrough") private void await() { while (true) { switch (status) { @@ -1228,14 +1232,13 @@ public class Activation implements Serializable { 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 @@ public class Activation implements Serializable { cmdenv = desc.getCommandEnvironment(); // argv is the literal command to exec - List argv = new ArrayList(); + List argv = new ArrayList<>(); // Command name/path argv.add((cmdenv != null && cmdenv.getCommandPath() != null) @@ -1957,7 +1960,7 @@ public class Activation implements Serializable { } String log = null; - List childArgs = new ArrayList(); + List childArgs = new ArrayList<>(); /* * Parse arguments @@ -2031,8 +2034,7 @@ public class Activation implements Serializable { } try { - Class execPolicyClass = - RMIClassLoader.loadClass(execPolicyClassName); + Class execPolicyClass = getRMIClass(execPolicyClassName); execPolicy = execPolicyClass.newInstance(); execPolicyMethod = execPolicyClass.getMethod("checkExecCommand", @@ -2123,6 +2125,10 @@ public class Activation implements Serializable { } } + @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. diff --git a/jdk/src/share/classes/sun/rmi/server/ActivationGroupImpl.java b/jdk/src/share/classes/sun/rmi/server/ActivationGroupImpl.java index 1ee26a5c51f..dd89d510733 100644 --- a/jdk/src/share/classes/sun/rmi/server/ActivationGroupImpl.java +++ b/jdk/src/share/classes/sun/rmi/server/ActivationGroupImpl.java @@ -66,10 +66,10 @@ public class ActivationGroupImpl extends ActivationGroup { /** maps persistent IDs to activated remote objects */ private final Hashtable active = - new Hashtable(); + new Hashtable<>(); private boolean groupInactive = false; private final ActivationGroupID groupID; - private final List lockedIDs = new ArrayList(); + private final List lockedIDs = new ArrayList<>(); /** * Creates a default activation group implementation. @@ -296,14 +296,9 @@ public class ActivationGroupImpl extends ActivationGroup { 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 diff --git a/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java b/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java index e7db8c869fc..956e80b2334 100644 --- a/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java +++ b/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java @@ -112,11 +112,11 @@ public final class LoaderHandler { * garbage collected. */ private static final HashMap loaderTable - = new HashMap(5); + = new HashMap<>(5); /** reference queue for cleared class loader entries */ private static final ReferenceQueue refQueue - = new ReferenceQueue(); + = new ReferenceQueue<>(); /* * Disallow anyone from creating one of these. @@ -149,8 +149,8 @@ public final class LoaderHandler { * 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 @@ public final class LoaderHandler { 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 @@ public final class LoaderHandler { * 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 @@ public final class LoaderHandler { 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 @@ public final class LoaderHandler { * 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 @@ public final class LoaderHandler { 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 @@ public final class LoaderHandler { * 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 @@ public final class LoaderHandler { } 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 @@ public final class LoaderHandler { * 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 @@ public final class LoaderHandler { 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 @@ public final class LoaderHandler { * 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 @@ public final class LoaderHandler { } 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 @@ public final class LoaderHandler { * 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 @@ public final class LoaderHandler { * 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 @@ public final class LoaderHandler { 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 @@ public final class LoaderHandler { /** map from weak(key=string) to [URL[], soft(key)] */ private static final Map pathToURLsCache - = new WeakHashMap(5); + = new WeakHashMap<>(5); /** * Convert an array of URL objects into a corresponding string @@ -1171,9 +1169,9 @@ public final class LoaderHandler { private void checkPermissions() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { // should never be null? - Enumeration enum_ = permissions.elements(); + Enumeration enum_ = permissions.elements(); while (enum_.hasMoreElements()) { - sm.checkPermission((Permission) enum_.nextElement()); + sm.checkPermission(enum_.nextElement()); } } } diff --git a/jdk/src/share/classes/sun/rmi/server/MarshalInputStream.java b/jdk/src/share/classes/sun/rmi/server/MarshalInputStream.java index cb32017b4ad..daa0f720e2e 100644 --- a/jdk/src/share/classes/sun/rmi/server/MarshalInputStream.java +++ b/jdk/src/share/classes/sun/rmi/server/MarshalInputStream.java @@ -65,14 +65,14 @@ public class MarshalInputStream extends ObjectInputStream { /** table to hold sun classes to which access is explicitly permitted */ protected static Map> permittedSunClasses - = new HashMap>(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 doneCallbacks - = new HashMap(3); + = new HashMap<>(3); /** * if true, load classes (if not available locally) only from the @@ -168,7 +168,7 @@ public class MarshalInputStream extends ObjectInputStream { * 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 @@ public class MarshalInputStream extends ObjectInputStream { * 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 @@ public class MarshalInputStream extends ObjectInputStream { * 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 diff --git a/jdk/src/share/classes/sun/rmi/server/UnicastRef.java b/jdk/src/share/classes/sun/rmi/server/UnicastRef.java index b928cfb9a46..c2f1df14d4e 100644 --- a/jdk/src/share/classes/sun/rmi/server/UnicastRef.java +++ b/jdk/src/share/classes/sun/rmi/server/UnicastRef.java @@ -65,6 +65,7 @@ public class UnicastRef implements RemoteRef { Log.getLog("sun.rmi.client.call", "RMI", AccessController.doPrivileged( new GetBooleanAction("sun.rmi.client.logCalls"))); + private static final long serialVersionUID = 8258372400816541186L; protected LiveRef ref; diff --git a/jdk/src/share/classes/sun/rmi/server/UnicastRef2.java b/jdk/src/share/classes/sun/rmi/server/UnicastRef2.java index c2abc1f7434..2facc1e56c4 100644 --- a/jdk/src/share/classes/sun/rmi/server/UnicastRef2.java +++ b/jdk/src/share/classes/sun/rmi/server/UnicastRef2.java @@ -36,6 +36,7 @@ import sun.rmi.transport.LiveRef; * 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. diff --git a/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java b/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java index fe199a23137..5213742de16 100644 --- a/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java +++ b/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java @@ -189,7 +189,7 @@ public class UnicastServerRef extends UnicastRef boolean permanent) throws RemoteException { - Class implClass = impl.getClass(); + Class implClass = impl.getClass(); Remote stub; try { @@ -327,7 +327,7 @@ public class UnicastServerRef extends UnicastRef // 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 @@ public class UnicastServerRef extends UnicastRef HashToMethod_Maps() {} protected Map computeValue(Class remoteClass) { - Map map = new HashMap(); + Map map = new HashMap<>(); for (Class cl = remoteClass; cl != null; cl = cl.getSuperclass()) diff --git a/jdk/src/share/classes/sun/rmi/server/Util.java b/jdk/src/share/classes/sun/rmi/server/Util.java index c3b6b4aa9b3..2cf01ffaf07 100644 --- a/jdk/src/share/classes/sun/rmi/server/Util.java +++ b/jdk/src/share/classes/sun/rmi/server/Util.java @@ -119,12 +119,12 @@ public final class Util { * @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 @@ public final class Util { * * @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 @@ public final class Util { * @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 @@ public final class Util { * any illegal remote interfaces * @throws NullPointerException if remoteClass is null */ - private static Class[] getRemoteInterfaces(Class remoteClass) { - ArrayList> list = new ArrayList>(); + private static Class[] getRemoteInterfaces(Class remoteClass) { + ArrayList> list = new ArrayList<>(); getRemoteInterfaces(list, remoteClass); return list.toArray(new Class[list.size()]); } @@ -220,15 +220,15 @@ public final class Util { * any illegal remote interfaces * @throws NullPointerException if the specified class or list is null */ - private static void getRemoteInterfaces(ArrayList> list, Class cl) { - Class superclass = cl.getSuperclass(); + private static void getRemoteInterfaces(ArrayList> 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 @@ public final class Util { * 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 @@ public final class Util { 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 @@ public final class Util { static Skeleton createSkeleton(Remote object) throws SkeletonNotFoundException { - Class cl; + Class cl; try { cl = getRemoteClass(object.getClass()); } catch (ClassNotFoundException ex ) { @@ -327,7 +327,7 @@ public final class Util { // 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 @@ public final class Util { 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 @@ public final class Util { * 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 @@ public final class Util { * 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); } diff --git a/jdk/src/share/classes/sun/rmi/server/WeakClassHashMap.java b/jdk/src/share/classes/sun/rmi/server/WeakClassHashMap.java index 1aff57674f8..734e4ff80b8 100644 --- a/jdk/src/share/classes/sun/rmi/server/WeakClassHashMap.java +++ b/jdk/src/share/classes/sun/rmi/server/WeakClassHashMap.java @@ -46,8 +46,7 @@ import java.util.WeakHashMap; **/ public abstract class WeakClassHashMap { - private Map,ValueCell> internalMap = - new WeakHashMap,ValueCell>(); + private Map,ValueCell> internalMap = new WeakHashMap<>(); protected WeakClassHashMap() { } diff --git a/jdk/src/share/classes/sun/rmi/transport/ConnectionInputStream.java b/jdk/src/share/classes/sun/rmi/transport/ConnectionInputStream.java index f79482bbfd3..2c2a81f790d 100644 --- a/jdk/src/share/classes/sun/rmi/transport/ConnectionInputStream.java +++ b/jdk/src/share/classes/sun/rmi/transport/ConnectionInputStream.java @@ -43,7 +43,7 @@ class ConnectionInputStream extends MarshalInputStream { private boolean dgcAckNeeded = false; /** Hashtable mapping Endpoints to lists of LiveRefs to register */ - private Map incomingRefTable = new HashMap(5); + private Map> incomingRefTable = new HashMap<>(5); /** identifier for gc ack*/ private UID ackID; @@ -70,10 +70,10 @@ class ConnectionInputStream extends MarshalInputStream { Endpoint ep = ref.getEndpoint(); // check whether endpoint is already in the hashtable - List refList = (List) incomingRefTable.get(ep); + List refList = incomingRefTable.get(ep); if (refList == null) { - refList = new ArrayList(); + refList = new ArrayList(); incomingRefTable.put(ep, refList); } @@ -89,13 +89,9 @@ class ConnectionInputStream extends MarshalInputStream { */ 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> entry : + incomingRefTable.entrySet()) { + DGCClient.registerRefs(entry.getKey(), entry.getValue()); } } } diff --git a/jdk/src/share/classes/sun/rmi/transport/DGCAckHandler.java b/jdk/src/share/classes/sun/rmi/transport/DGCAckHandler.java index 27354575f11..7c757dd388a 100644 --- a/jdk/src/share/classes/sun/rmi/transport/DGCAckHandler.java +++ b/jdk/src/share/classes/sun/rmi/transport/DGCAckHandler.java @@ -78,7 +78,7 @@ public class DGCAckHandler { Collections.synchronizedMap(new HashMap()); private final UID id; - private List objList = new ArrayList(); // null if released + private List objList = new ArrayList<>(); // null if released private Future task = null; /** diff --git a/jdk/src/share/classes/sun/rmi/transport/DGCClient.java b/jdk/src/share/classes/sun/rmi/transport/DGCClient.java index 039935cb189..c6e3266ce81 100644 --- a/jdk/src/share/classes/sun/rmi/transport/DGCClient.java +++ b/jdk/src/share/classes/sun/rmi/transport/DGCClient.java @@ -125,7 +125,7 @@ final class DGCClient { * 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 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 @@ final class DGCClient { private DGC dgc; /** table of refs held for endpoint: maps LiveRef to RefEntry */ - private Map refTable = new HashMap(5); + private Map refTable = new HashMap<>(5); /** set of RefEntry instances from last (failed) dirty call */ - private Set invalidRefs = new HashSet(5); + private Set invalidRefs = new HashSet<>(5); /** true if this entry has been removed from the global table */ private boolean removed = false; @@ -200,12 +200,12 @@ final class DGCClient { private boolean interruptible = false; /** reference queue for phantom references */ - private ReferenceQueue refQueue = new ReferenceQueue(); + private ReferenceQueue refQueue = new ReferenceQueue<>(); /** set of clean calls that need to be made */ - private Set pendingCleans = new HashSet(5); + private Set pendingCleans = new HashSet<>(5); /** global endpoint table: maps Endpoint to EndpointEntry */ - private static Map endpointTable = new HashMap(5); + private static Map endpointTable = new HashMap<>(5); /** handle for GC latency request (for future cancellation) */ private static GC.LatencyRequest gcLatencyRequest = null; @@ -215,7 +215,7 @@ final class DGCClient { */ 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 @@ final class DGCClient { * * This method must NOT be called while synchronized on this entry. */ - public boolean registerRefs(List refs) { + public boolean registerRefs(List refs) { assert !Thread.holdsLock(this); - Set refsToDirty = null; // entries for refs needing dirty + Set refsToDirty = null; // entries for refs needing dirty long sequenceNum; // sequence number for dirty call synchronized (this) { @@ -271,18 +271,18 @@ final class DGCClient { return false; } - Iterator iter = refs.iterator(); + Iterator 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 @@ final class DGCClient { * * This method must NOT be called while synchronized on this entry. */ - private void makeDirtyCall(Set refEntries, long sequenceNum) { + private void makeDirtyCall(Set refEntries, long sequenceNum) { assert !Thread.holdsLock(this); ObjID[] ids; @@ -443,9 +443,9 @@ final class DGCClient { * refs, so that clean calls for them in the future * will be strong. */ - Iterator iter = refEntries.iterator(); + Iterator iter = refEntries.iterator(); while (iter.hasNext()) { - RefEntry refEntry = (RefEntry) iter.next(); + RefEntry refEntry = iter.next(); refEntry.markDirtyFailed(); } } @@ -497,7 +497,7 @@ final class DGCClient { long timeToWait; RefEntry.PhantomLiveRef phantom = null; boolean needRenewal = false; - Set refsToDirty = null; + Set refsToDirty = null; long sequenceNum = Long.MIN_VALUE; synchronized (EndpointEntry.this) { @@ -564,7 +564,7 @@ final class DGCClient { needRenewal = true; if (!invalidRefs.isEmpty()) { refsToDirty = invalidRefs; - invalidRefs = new HashSet(5); + invalidRefs = new HashSet<>(5); } sequenceNum = getNextSequenceNum(); } @@ -594,8 +594,8 @@ final class DGCClient { private void processPhantomRefs(RefEntry.PhantomLiveRef phantom) { assert Thread.holdsLock(this); - Set strongCleans = null; - Set normalCleans = null; + Set strongCleans = null; + Set normalCleans = null; do { RefEntry refEntry = phantom.getRefEntry(); @@ -603,12 +603,12 @@ final class DGCClient { 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 @@ final class DGCClient { private void makeCleanCalls() { assert !Thread.holdsLock(this); - Iterator iter = pendingCleans.iterator(); + Iterator 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 @@ final class DGCClient { * 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 refEntries) { ObjID[] ids = new ObjID[refEntries.size()]; - Iterator iter = refEntries.iterator(); + Iterator 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 @@ final class DGCClient { /** 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 refSet = new HashSet<>(5); /** true if a dirty call containing this ref has failed */ private boolean dirtyFailed = false; @@ -792,7 +792,7 @@ final class DGCClient { * used to detect when the LiveRef becomes permanently * unreachable in this VM. */ - private class PhantomLiveRef extends PhantomReference { + private class PhantomLiveRef extends PhantomReference { public PhantomLiveRef(LiveRef ref) { super(ref, EndpointEntry.this.refQueue); diff --git a/jdk/src/share/classes/sun/rmi/transport/DGCImpl.java b/jdk/src/share/classes/sun/rmi/transport/DGCImpl.java index caaa381eb38..5e59cb10172 100644 --- a/jdk/src/share/classes/sun/rmi/transport/DGCImpl.java +++ b/jdk/src/share/classes/sun/rmi/transport/DGCImpl.java @@ -84,7 +84,7 @@ final class DGCImpl implements DGC { /** remote implementation of DGC interface for this VM */ private static DGCImpl dgc; /** table that maps VMID to LeaseInfo */ - private Map leaseTable = new HashMap(); + private Map leaseTable = new HashMap<>(); /** checks for lease expiration */ private Future checker = null; @@ -236,7 +236,7 @@ final class DGCImpl implements DGC { long time = System.currentTimeMillis(); /* List of vmids that need to be removed from the leaseTable */ - List toUnregister = new ArrayList(); + List toUnregister = new ArrayList<>(); /* Build a list of leaseInfo objects that need to have * targets removed from their notifySet. Remove expired @@ -313,7 +313,7 @@ final class DGCImpl implements DGC { private static class LeaseInfo { VMID vmid; long expiration; - Set notifySet = new HashSet(); + Set notifySet = new HashSet<>(); LeaseInfo(VMID vmid, long lease) { this.vmid = vmid; diff --git a/jdk/src/share/classes/sun/rmi/transport/ObjectTable.java b/jdk/src/share/classes/sun/rmi/transport/ObjectTable.java index 8c3e5cf2900..97956cc7839 100644 --- a/jdk/src/share/classes/sun/rmi/transport/ObjectTable.java +++ b/jdk/src/share/classes/sun/rmi/transport/ObjectTable.java @@ -62,9 +62,9 @@ public final class ObjectTable { /** tables mapping to Target, keyed from ObjectEndpoint and impl object */ private static final Map objTable = - new HashMap(); + new HashMap<>(); private static final Map implTable = - new HashMap(); + new HashMap<>(); /** * lock guarding keepAliveCount, reaper, and gcLatencyRequest. @@ -79,7 +79,7 @@ public final class ObjectTable { private static Thread reaper = null; /** queue notified when weak refs in the table are cleared */ - static final ReferenceQueue reapQueue = new ReferenceQueue(); + static final ReferenceQueue reapQueue = new ReferenceQueue<>(); /** handle for GC latency request (for future cancellation) */ private static GC.LatencyRequest gcLatencyRequest = null; diff --git a/jdk/src/share/classes/sun/rmi/transport/StreamRemoteCall.java b/jdk/src/share/classes/sun/rmi/transport/StreamRemoteCall.java index f0c3c292a91..d6d6ee822f5 100644 --- a/jdk/src/share/classes/sun/rmi/transport/StreamRemoteCall.java +++ b/jdk/src/share/classes/sun/rmi/transport/StreamRemoteCall.java @@ -199,6 +199,7 @@ public class StreamRemoteCall implements RemoteCall { /** * Do whatever it takes to execute the call. */ + @SuppressWarnings("fallthrough") public void executeCall() throws Exception { byte returnType; @@ -252,6 +253,7 @@ public class StreamRemoteCall implements RemoteCall { } 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, diff --git a/jdk/src/share/classes/sun/rmi/transport/Target.java b/jdk/src/share/classes/sun/rmi/transport/Target.java index f784064b68c..bd1aded1657 100644 --- a/jdk/src/share/classes/sun/rmi/transport/Target.java +++ b/jdk/src/share/classes/sun/rmi/transport/Target.java @@ -53,9 +53,10 @@ public final class Target { /** 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 refSet = new Vector<>(); /** table that maps client endpoints to sequence numbers */ - private final Hashtable sequenceTable = new Hashtable(5); + private final Hashtable 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 @@ public final class Target { */ 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 @@ public final class Target { 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 @@ public final class Target { */ unpinImpl(); DGCImpl dgc = DGCImpl.getDGCImpl(); - Enumeration enum_ = refSet.elements(); + Enumeration enum_ = refSet.elements(); while (enum_.hasMoreElements()) { - VMID vmid = (VMID) enum_.nextElement(); + VMID vmid = enum_.nextElement(); dgc.unregisterTarget(vmid, this); } return true; diff --git a/jdk/src/share/classes/sun/rmi/transport/Transport.java b/jdk/src/share/classes/sun/rmi/transport/Transport.java index 82a3fe7812b..bfafe9888b5 100644 --- a/jdk/src/share/classes/sun/rmi/transport/Transport.java +++ b/jdk/src/share/classes/sun/rmi/transport/Transport.java @@ -62,7 +62,7 @@ public abstract class Transport { 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 currentTransport = new ThreadLocal<>(); /** ObjID for DGCImpl */ private static final ObjID dgcID = new ObjID(ObjID.DGC_ID); @@ -104,7 +104,7 @@ public abstract class Transport { * returns null. **/ static Transport currentTransport() { - return (Transport) currentTransport.get(); + return currentTransport.get(); } /** diff --git a/jdk/src/share/classes/sun/rmi/transport/WeakRef.java b/jdk/src/share/classes/sun/rmi/transport/WeakRef.java index 98bd0dbaace..c20a8a13089 100644 --- a/jdk/src/share/classes/sun/rmi/transport/WeakRef.java +++ b/jdk/src/share/classes/sun/rmi/transport/WeakRef.java @@ -41,7 +41,7 @@ import sun.rmi.runtime.Log; * @author Ann Wollrath * @author Peter Jones */ -class WeakRef extends WeakReference { +class WeakRef extends WeakReference { /** value of the referent's "identity" hash code */ private int hashValue; @@ -60,7 +60,7 @@ class WeakRef extends WeakReference { /** * Create a new WeakRef to the given object, registered with a queue. */ - public WeakRef(Object obj, ReferenceQueue q) { + public WeakRef(Object obj, ReferenceQueue q) { super(obj, q); setHashValue(obj); // cache object's "identity" hash code } diff --git a/jdk/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java b/jdk/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java index 25a84fa6660..918986deec9 100644 --- a/jdk/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java +++ b/jdk/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java @@ -33,6 +33,7 @@ import java.util.Hashtable; * 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 CGIClientException extends Exception { */ class CGIServerException extends Exception { + private static final long serialVersionUID = 6928425456704527017L; + public CGIServerException(String s) { super(s); } @@ -111,9 +114,9 @@ public final class CGIHandler { }; /* construct table mapping command strings to handlers */ - private static Hashtable commandLookup; + private static Hashtable 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 @@ public final class CGIHandler { 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 @@ public final class CGIHandler { /** * "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 @@ final class CGIForwardCommand implements CGICommandHandler { 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 @@ final class CGIForwardCommand implements CGICommandHandler { 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 @@ final class CGIForwardCommand implements CGICommandHandler { "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; diff --git a/jdk/src/share/classes/sun/rmi/transport/proxy/HttpInputStream.java b/jdk/src/share/classes/sun/rmi/transport/proxy/HttpInputStream.java index dc320c8a9b3..773493e48df 100644 --- a/jdk/src/share/classes/sun/rmi/transport/proxy/HttpInputStream.java +++ b/jdk/src/share/classes/sun/rmi/transport/proxy/HttpInputStream.java @@ -70,8 +70,8 @@ class HttpInputStream extends FilterInputStream { 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; diff --git a/jdk/src/share/classes/sun/rmi/transport/proxy/HttpSendSocket.java b/jdk/src/share/classes/sun/rmi/transport/proxy/HttpSendSocket.java index b599e1bf2ce..0d790d5db67 100644 --- a/jdk/src/share/classes/sun/rmi/transport/proxy/HttpSendSocket.java +++ b/jdk/src/share/classes/sun/rmi/transport/proxy/HttpSendSocket.java @@ -203,7 +203,7 @@ class HttpSendSocket extends Socket implements RMISocketInfo { 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; diff --git a/jdk/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java b/jdk/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java index 2a2bf2a3f8a..2caf6ac0162 100644 --- a/jdk/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java +++ b/jdk/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java @@ -74,20 +74,21 @@ public class RMIMasterSocketFactory extends RMISocketFactory { "sun.rmi.transport.proxy.eagerHttpFallback")).booleanValue(); /** table of hosts successfully connected to and the factory used */ - private Hashtable successTable = new Hashtable(); + private Hashtable 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 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 altFactoryList; /** * Create a RMIMasterSocketFactory object. Establish order of @@ -95,7 +96,7 @@ public class RMIMasterSocketFactory extends RMISocketFactory { * socket connection fails. */ public RMIMasterSocketFactory() { - altFactoryList = new Vector(2); + altFactoryList = new Vector<>(2); boolean setFactories = false; try { @@ -152,7 +153,7 @@ public class RMIMasterSocketFactory extends RMISocketFactory { * 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 @@ public class RMIMasterSocketFactory extends RMISocketFactory { 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 @@ public class RMIMasterSocketFactory extends RMISocketFactory { // 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 @@ public class RMIMasterSocketFactory extends RMISocketFactory { } // 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) { diff --git a/jdk/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java b/jdk/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java index a3b66962acb..47b7143508d 100644 --- a/jdk/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java +++ b/jdk/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java @@ -85,7 +85,7 @@ final class ConnectionMultiplexer { private DataOutputStream dataOut; /** table holding currently open connection IDs and related info */ - private Hashtable connectionTable = new Hashtable(7); + private Hashtable connectionTable = new Hashtable<>(7); /** number of currently open connections */ private int numConnections = 0; @@ -131,7 +131,6 @@ final class ConnectionMultiplexer { { try { int op, id, length; - Integer idObj; MultiplexConnectionInfo info; while (true) { @@ -148,9 +147,7 @@ final class ConnectionMultiplexer { 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 @@ final class ConnectionMultiplexer { 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 @@ final class ConnectionMultiplexer { 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 @@ final class ConnectionMultiplexer { if (!info.closed) sendCloseAck(info); synchronized (connectionTable) { - connectionTable.remove(idObj); + connectionTable.remove(id); -- numConnections; } break; @@ -199,9 +194,7 @@ final class ConnectionMultiplexer { "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 @@ final class ConnectionMultiplexer { info.in.disconnect(); info.out.disconnect(); synchronized (connectionTable) { - connectionTable.remove(idObj); + connectionTable.remove(id); -- numConnections; } break; @@ -219,9 +212,7 @@ final class ConnectionMultiplexer { // 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 @@ final class ConnectionMultiplexer { // 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 @@ final class ConnectionMultiplexer { // 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 @@ final class ConnectionMultiplexer { // 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 @@ final class ConnectionMultiplexer { 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 @@ final class ConnectionMultiplexer { return; alive = false; - Enumeration enum_ = connectionTable.elements(); + Enumeration enum_ = + connectionTable.elements(); while (enum_.hasMoreElements()) { - MultiplexConnectionInfo info = - (MultiplexConnectionInfo) enum_.nextElement(); + MultiplexConnectionInfo info = enum_.nextElement(); info.in.disconnect(); info.out.disconnect(); } diff --git a/jdk/src/share/classes/sun/rmi/transport/tcp/TCPChannel.java b/jdk/src/share/classes/sun/rmi/transport/tcp/TCPChannel.java index e3aa730548d..7ab872cf7ed 100644 --- a/jdk/src/share/classes/sun/rmi/transport/tcp/TCPChannel.java +++ b/jdk/src/share/classes/sun/rmi/transport/tcp/TCPChannel.java @@ -64,7 +64,7 @@ public class TCPChannel implements Channel { private final TCPTransport tr; /** list of cached connections */ private final List freeList = - new ArrayList(); + new ArrayList<>(); /** frees cached connections that have expired (guarded by freeList) */ private Future reaper = null; @@ -480,7 +480,7 @@ class ConnectionAcceptor implements Runnable { private TCPTransport transport; /** queue of connections to be accepted */ - private List queue = new ArrayList(); + private List queue = new ArrayList<>(); /** thread ID counter */ private static int threadNum = 0; diff --git a/jdk/src/share/classes/sun/rmi/transport/tcp/TCPEndpoint.java b/jdk/src/share/classes/sun/rmi/transport/tcp/TCPEndpoint.java index 58978775a34..4af340532dc 100644 --- a/jdk/src/share/classes/sun/rmi/transport/tcp/TCPEndpoint.java +++ b/jdk/src/share/classes/sun/rmi/transport/tcp/TCPEndpoint.java @@ -148,7 +148,7 @@ public class TCPEndpoint implements Endpoint { // TBD: should this be a weak hash table? private static final Map> localEndpoints = - new HashMap>(); + new HashMap<>(); /** * Create an endpoint for a specified host and port. @@ -623,10 +623,9 @@ public class TCPEndpoint implements Endpoint { 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: " + diff --git a/jdk/src/share/classes/sun/rmi/transport/tcp/TCPTransport.java b/jdk/src/share/classes/sun/rmi/transport/tcp/TCPTransport.java index a22c720e51a..e2b9841c11b 100644 --- a/jdk/src/share/classes/sun/rmi/transport/tcp/TCPTransport.java +++ b/jdk/src/share/classes/sun/rmi/transport/tcp/TCPTransport.java @@ -119,7 +119,7 @@ public class TCPTransport extends Transport { /** client host for the current thread's connection */ private static final ThreadLocal - threadConnectionHandler = new ThreadLocal(); + threadConnectionHandler = new ThreadLocal<>(); /** endpoints for this transport */ private final LinkedList epList; @@ -129,7 +129,7 @@ public class TCPTransport extends Transport { private ServerSocket server = null; /** table mapping endpoints to channels */ private final Map> channelTable = - new WeakHashMap>(); + new WeakHashMap<>(); static final RMISocketFactory defaultSocketFactory = RMISocketFactory.getDefaultSocketFactory(); From 2d9226ff6065f469b06e7a34929b2dbb32b090ba Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Sun, 4 Mar 2012 07:41:34 +0000 Subject: [PATCH 2/2] 7145043: HttpServerProvider.java:81: warning - @code("httpServerProvider") is an unknown tag Reviewed-by: michaelm --- .../classes/com/sun/net/httpserver/spi/HttpServerProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java b/jdk/src/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java index 7b5c05331fe..02ede0b69d4 100644 --- a/jdk/src/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java +++ b/jdk/src/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java @@ -76,7 +76,7 @@ public abstract class HttpServerProvider { * * @throws SecurityException * If a security manager has been installed and it denies - * {@link RuntimePermission}{@code("httpServerProvider")} + * {@link RuntimePermission}{@code ("httpServerProvider")} */ protected HttpServerProvider() { SecurityManager sm = System.getSecurityManager();