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