提交 3fa0aee5 编写于 作者: K khazra

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