提交 0064db34 编写于 作者: M martin

6600143: Remove another 450 unnecessary casts

Reviewed-by: alanb, iris, lmalvent, bristor, peterjones, darcy, wetmore
上级 240ad09d
...@@ -32,9 +32,9 @@ class CommandNode extends AbstractCommandNode { ...@@ -32,9 +32,9 @@ class CommandNode extends AbstractCommandNode {
void constrain(Context ctx) { void constrain(Context ctx) {
if (components.size() == 3) { if (components.size() == 3) {
Node out = (Node)components.get(0); Node out = components.get(0);
Node reply = (Node)components.get(1); Node reply = components.get(1);
Node error = (Node)components.get(2); Node error = components.get(2);
if (!(out instanceof OutNode)) { if (!(out instanceof OutNode)) {
error("Expected 'Out' item, got: " + out); error("Expected 'Out' item, got: " + out);
} }
...@@ -45,7 +45,7 @@ class CommandNode extends AbstractCommandNode { ...@@ -45,7 +45,7 @@ class CommandNode extends AbstractCommandNode {
error("Expected 'ErrorSet' item, got: " + error); error("Expected 'ErrorSet' item, got: " + error);
} }
} else if (components.size() == 1) { } else if (components.size() == 1) {
Node evt = (Node)components.get(0); Node evt = components.get(0);
if (!(evt instanceof EventNode)) { if (!(evt instanceof EventNode)) {
error("Expected 'Event' item, got: " + evt); error("Expected 'Event' item, got: " + evt);
} }
......
...@@ -98,7 +98,7 @@ class ConstantSetNode extends AbstractNamedNode { ...@@ -98,7 +98,7 @@ class ConstantSetNode extends AbstractNamedNode {
if (constantMap == null) { if (constantMap == null) {
return ""; return "";
} }
String com = (String) constantMap.get(key); String com = constantMap.get(key);
if(com == null){ if(com == null){
return ""; return "";
} else { } else {
......
...@@ -37,7 +37,7 @@ class RepeatNode extends AbstractTypeNode { ...@@ -37,7 +37,7 @@ class RepeatNode extends AbstractTypeNode {
if (components.size() != 1) { if (components.size() != 1) {
error("Repeat must have exactly one member, use Group for more"); error("Repeat must have exactly one member, use Group for more");
} }
member = (Node)(components.get(0)); member = components.get(0);
if (!(member instanceof TypeNode)) { if (!(member instanceof TypeNode)) {
error("Repeat member must be type specifier"); error("Repeat member must be type specifier");
} }
......
...@@ -91,9 +91,7 @@ abstract public class EventRequestSpec { ...@@ -91,9 +91,7 @@ abstract public class EventRequestSpec {
void attemptImmediateResolve(VirtualMachine vm) { void attemptImmediateResolve(VirtualMachine vm) {
// try to resolve immediately // try to resolve immediately
Iterator iter = vm.allClasses().iterator(); for (ReferenceType refType : vm.allClasses()) {
while (iter.hasNext()) {
ReferenceType refType = (ReferenceType)iter.next();
if (refSpec.matches(refType)) { if (refSpec.matches(refType)) {
try { try {
resolve(refType); resolve(refType);
......
...@@ -47,9 +47,8 @@ class EventRequestSpecList { ...@@ -47,9 +47,8 @@ class EventRequestSpecList {
*/ */
void resolve(ReferenceType refType) { void resolve(ReferenceType refType) {
synchronized(eventRequestSpecs) { synchronized(eventRequestSpecs) {
Iterator iter = eventRequestSpecs.iterator(); for (EventRequestSpec spec : eventRequestSpecs) {
while (iter.hasNext()) { spec.attemptResolve(refType);
((EventRequestSpec)iter.next()).attemptResolve(refType);
} }
} }
} }
...@@ -79,7 +78,7 @@ class EventRequestSpecList { ...@@ -79,7 +78,7 @@ class EventRequestSpecList {
BreakpointSpec BreakpointSpec
createMethodBreakpoint(String classPattern, createMethodBreakpoint(String classPattern,
String methodId, List methodArgs) { String methodId, List<String> methodArgs) {
ReferenceTypeSpec refSpec = ReferenceTypeSpec refSpec =
new PatternReferenceTypeSpec(classPattern); new PatternReferenceTypeSpec(classPattern);
return new MethodBreakpointSpec(this, refSpec, return new MethodBreakpointSpec(this, refSpec,
...@@ -132,47 +131,48 @@ class EventRequestSpecList { ...@@ -132,47 +131,48 @@ class EventRequestSpecList {
// -------- notify routines -------------------- // -------- notify routines --------------------
private Vector specListeners() { @SuppressWarnings("unchecked")
return (Vector)runtime.specListeners.clone(); private Vector<SpecListener> specListeners() {
return (Vector<SpecListener>)runtime.specListeners.clone();
} }
void notifySet(EventRequestSpec spec) { void notifySet(EventRequestSpec spec) {
Vector l = specListeners(); Vector<SpecListener> l = specListeners();
SpecEvent evt = new SpecEvent(spec); SpecEvent evt = new SpecEvent(spec);
for (int i = 0; i < l.size(); i++) { for (int i = 0; i < l.size(); i++) {
spec.notifySet((SpecListener)l.elementAt(i), evt); spec.notifySet(l.elementAt(i), evt);
} }
} }
void notifyDeferred(EventRequestSpec spec) { void notifyDeferred(EventRequestSpec spec) {
Vector l = specListeners(); Vector<SpecListener> l = specListeners();
SpecEvent evt = new SpecEvent(spec); SpecEvent evt = new SpecEvent(spec);
for (int i = 0; i < l.size(); i++) { for (int i = 0; i < l.size(); i++) {
spec.notifyDeferred((SpecListener)l.elementAt(i), evt); spec.notifyDeferred(l.elementAt(i), evt);
} }
} }
void notifyDeleted(EventRequestSpec spec) { void notifyDeleted(EventRequestSpec spec) {
Vector l = specListeners(); Vector<SpecListener> l = specListeners();
SpecEvent evt = new SpecEvent(spec); SpecEvent evt = new SpecEvent(spec);
for (int i = 0; i < l.size(); i++) { for (int i = 0; i < l.size(); i++) {
spec.notifyDeleted((SpecListener)l.elementAt(i), evt); spec.notifyDeleted(l.elementAt(i), evt);
} }
} }
void notifyResolved(EventRequestSpec spec) { void notifyResolved(EventRequestSpec spec) {
Vector l = specListeners(); Vector<SpecListener> l = specListeners();
SpecEvent evt = new SpecEvent(spec); SpecEvent evt = new SpecEvent(spec);
for (int i = 0; i < l.size(); i++) { for (int i = 0; i < l.size(); i++) {
spec.notifyResolved((SpecListener)l.elementAt(i), evt); spec.notifyResolved(l.elementAt(i), evt);
} }
} }
void notifyError(EventRequestSpec spec, Exception exc) { void notifyError(EventRequestSpec spec, Exception exc) {
Vector l = specListeners(); Vector<SpecListener> l = specListeners();
SpecErrorEvent evt = new SpecErrorEvent(spec, exc); SpecErrorEvent evt = new SpecErrorEvent(spec, exc);
for (int i = 0; i < l.size(); i++) { for (int i = 0; i < l.size(); i++) {
spec.notifyError((SpecListener)l.elementAt(i), evt); spec.notifyError(l.elementAt(i), evt);
} }
} }
} }
...@@ -232,10 +232,7 @@ public class ExecutionManager { ...@@ -232,10 +232,7 @@ public class ExecutionManager {
if (pattern.startsWith("*.")) { if (pattern.startsWith("*.")) {
// Wildcard matches any leading package name. // Wildcard matches any leading package name.
pattern = pattern.substring(1); pattern = pattern.substring(1);
List classes = vm().allClasses(); for (ReferenceType type : vm().allClasses()) {
Iterator iter = classes.iterator();
while (iter.hasNext()) {
ReferenceType type = ((ReferenceType)iter.next());
if (type.name().endsWith(pattern)) { if (type.name().endsWith(pattern)) {
result.add(type); result.add(type);
} }
...@@ -278,7 +275,7 @@ public class ExecutionManager { ...@@ -278,7 +275,7 @@ public class ExecutionManager {
public ThreadGroupReference systemThreadGroup() public ThreadGroupReference systemThreadGroup()
throws NoSessionException { throws NoSessionException {
ensureActiveSession(); ensureActiveSession();
return (ThreadGroupReference)vm().topLevelThreadGroups().get(0); return vm().topLevelThreadGroups().get(0);
} }
/* /*
...@@ -349,10 +346,9 @@ public class ExecutionManager { ...@@ -349,10 +346,9 @@ public class ExecutionManager {
* attach sessions. * attach sessions.
*/ */
VirtualMachineManager mgr = Bootstrap.virtualMachineManager(); VirtualMachineManager mgr = Bootstrap.virtualMachineManager();
List connectors = mgr.attachingConnectors(); AttachingConnector connector = mgr.attachingConnectors().get(0);
AttachingConnector connector = (AttachingConnector)connectors.get(0);
Map<String, Connector.Argument> arguments = connector.defaultArguments(); Map<String, Connector.Argument> arguments = connector.defaultArguments();
((Connector.Argument)arguments.get("port")).setValue(portName); arguments.get("port").setValue(portName);
Session newSession = internalAttach(connector, arguments); Session newSession = internalAttach(connector, arguments);
if (newSession != null) { if (newSession != null) {
...@@ -504,10 +500,7 @@ public class ExecutionManager { ...@@ -504,10 +500,7 @@ public class ExecutionManager {
* if so, it gets removed here. * if so, it gets removed here.
*/ */
EventRequestManager mgr = vm().eventRequestManager(); EventRequestManager mgr = vm().eventRequestManager();
List requests = mgr.stepRequests(); for (StepRequest request : mgr.stepRequests()) {
Iterator iter = requests.iterator();
while (iter.hasNext()) {
StepRequest request = (StepRequest)iter.next();
if (request.thread().equals(thread)) { if (request.thread().equals(thread)) {
mgr.deleteEventRequest(request); mgr.deleteEventRequest(request);
break; break;
...@@ -591,7 +584,7 @@ public class ExecutionManager { ...@@ -591,7 +584,7 @@ public class ExecutionManager {
if (session == null || thread == null) { if (session == null || thread == null) {
return null; return null;
} }
ThreadInfo info = (ThreadInfo)threadInfoMap.get(thread); ThreadInfo info = threadInfoMap.get(thread);
if (info == null) { if (info == null) {
//### Should not hardcode initial frame count and prefetch here! //### Should not hardcode initial frame count and prefetch here!
//info = new ThreadInfo(thread, 10, 10); //info = new ThreadInfo(thread, 10, 10);
...@@ -607,24 +600,22 @@ public class ExecutionManager { ...@@ -607,24 +600,22 @@ public class ExecutionManager {
void validateThreadInfo() { void validateThreadInfo() {
session.interrupted = true; session.interrupted = true;
Iterator iter = threadInfoList.iterator(); for (ThreadInfo threadInfo : threadInfoList) {
while (iter.hasNext()) { threadInfo.validate();
((ThreadInfo)iter.next()).validate();
} }
} }
private void invalidateThreadInfo() { private void invalidateThreadInfo() {
if (session != null) { if (session != null) {
session.interrupted = false; session.interrupted = false;
Iterator iter = threadInfoList.iterator(); for (ThreadInfo threadInfo : threadInfoList) {
while (iter.hasNext()) { threadInfo.invalidate();
((ThreadInfo)iter.next()).invalidate();
} }
} }
} }
void removeThreadInfo(ThreadReference thread) { void removeThreadInfo(ThreadReference thread) {
ThreadInfo info = (ThreadInfo)threadInfoMap.get(thread); ThreadInfo info = threadInfoMap.get(thread);
if (info != null) { if (info != null) {
info.invalidate(); info.invalidate();
threadInfoMap.remove(thread); threadInfoMap.remove(thread);
...@@ -702,7 +693,7 @@ public class ExecutionManager { ...@@ -702,7 +693,7 @@ public class ExecutionManager {
while (inputBuffer.size() < 1) { while (inputBuffer.size() < 1) {
inputLock.wait(); inputLock.wait();
} }
line = (String)inputBuffer.removeLast(); line = inputBuffer.removeLast();
} catch (InterruptedException e) {} } catch (InterruptedException e) {}
} }
} }
...@@ -774,7 +765,7 @@ public class ExecutionManager { ...@@ -774,7 +765,7 @@ public class ExecutionManager {
public BreakpointSpec public BreakpointSpec
createMethodBreakpoint(String classPattern, createMethodBreakpoint(String classPattern,
String methodId, List methodArgs) { String methodId, List<String> methodArgs) {
return specList.createMethodBreakpoint(classPattern, return specList.createMethodBreakpoint(classPattern,
methodId, methodArgs); methodId, methodArgs);
} }
...@@ -811,7 +802,7 @@ public class ExecutionManager { ...@@ -811,7 +802,7 @@ public class ExecutionManager {
specList.install(spec, vm()); specList.install(spec, vm());
} }
public List eventRequestSpecs() { public List<EventRequestSpec> eventRequestSpecs() {
return specList.eventRequestSpecs(); return specList.eventRequestSpecs();
} }
} }
...@@ -82,9 +82,7 @@ class JDIEventSource extends Thread { ...@@ -82,9 +82,7 @@ class JDIEventSource extends Thread {
boolean interrupted = es.suspendedAll(); boolean interrupted = es.suspendedAll();
es.notify(firstListener); es.notify(firstListener);
boolean wantInterrupt = JDIEventSource.this.wantInterrupt; boolean wantInterrupt = JDIEventSource.this.wantInterrupt;
for (Iterator it = session.runtime.jdiListeners.iterator(); for (JDIListener jl : session.runtime.jdiListeners) {
it.hasNext(); ) {
JDIListener jl = (JDIListener)it.next();
es.notify(jl); es.notify(jl);
} }
if (interrupted && !wantInterrupt) { if (interrupted && !wantInterrupt) {
......
...@@ -58,12 +58,12 @@ public class LineBreakpointSpec extends BreakpointSpec { ...@@ -58,12 +58,12 @@ public class LineBreakpointSpec extends BreakpointSpec {
LineNotFoundException { LineNotFoundException {
Location location = null; Location location = null;
try { try {
List locs = clazz.locationsOfLine(lineNumber()); List<Location> locs = clazz.locationsOfLine(lineNumber());
if (locs.size() == 0) { if (locs.size() == 0) {
throw new LineNotFoundException(); throw new LineNotFoundException();
} }
// TODO handle multiple locations // TODO handle multiple locations
location = (Location)locs.get(0); location = locs.get(0);
if (location.method() == null) { if (location.method() == null) {
throw new LineNotFoundException(); throw new LineNotFoundException();
} }
......
...@@ -34,11 +34,11 @@ import java.util.Iterator; ...@@ -34,11 +34,11 @@ import java.util.Iterator;
public class MethodBreakpointSpec extends BreakpointSpec { public class MethodBreakpointSpec extends BreakpointSpec {
String methodId; String methodId;
List methodArgs; List<String> methodArgs;
MethodBreakpointSpec(EventRequestSpecList specs, MethodBreakpointSpec(EventRequestSpecList specs,
ReferenceTypeSpec refSpec, ReferenceTypeSpec refSpec,
String methodId, List methodArgs) { String methodId, List<String> methodArgs) {
super(specs, refSpec); super(specs, refSpec);
this.methodId = methodId; this.methodId = methodId;
this.methodArgs = methodArgs; this.methodArgs = methodArgs;
...@@ -76,7 +76,7 @@ public class MethodBreakpointSpec extends BreakpointSpec { ...@@ -76,7 +76,7 @@ public class MethodBreakpointSpec extends BreakpointSpec {
return methodId; return methodId;
} }
public List methodArgs() { public List<String> methodArgs() {
return methodArgs; return methodArgs;
} }
...@@ -120,14 +120,13 @@ public class MethodBreakpointSpec extends BreakpointSpec { ...@@ -120,14 +120,13 @@ public class MethodBreakpointSpec extends BreakpointSpec {
buffer.append('.'); buffer.append('.');
buffer.append(methodId); buffer.append(methodId);
if (methodArgs != null) { if (methodArgs != null) {
Iterator iter = methodArgs.iterator();
boolean first = true; boolean first = true;
buffer.append('('); buffer.append('(');
while (iter.hasNext()) { for (String name : methodArgs) {
if (!first) { if (!first) {
buffer.append(','); buffer.append(',');
} }
buffer.append((String)iter.next()); buffer.append(name);
first = false; first = false;
} }
buffer.append(")"); buffer.append(")");
...@@ -151,8 +150,8 @@ public class MethodBreakpointSpec extends BreakpointSpec { ...@@ -151,8 +150,8 @@ public class MethodBreakpointSpec extends BreakpointSpec {
* and if the number of arguments in the method matches the * and if the number of arguments in the method matches the
* number of names passed * number of names passed
*/ */
private boolean compareArgTypes(Method method, List nameList) { private boolean compareArgTypes(Method method, List<String> nameList) {
List argTypeNames = method.argumentTypeNames(); List<String> argTypeNames = method.argumentTypeNames();
// If argument counts differ, we can stop here // If argument counts differ, we can stop here
if (argTypeNames.size() != nameList.size()) { if (argTypeNames.size() != nameList.size()) {
...@@ -162,8 +161,8 @@ public class MethodBreakpointSpec extends BreakpointSpec { ...@@ -162,8 +161,8 @@ public class MethodBreakpointSpec extends BreakpointSpec {
// Compare each argument type's name // Compare each argument type's name
int nTypes = argTypeNames.size(); int nTypes = argTypeNames.size();
for (int i = 0; i < nTypes; ++i) { for (int i = 0; i < nTypes; ++i) {
String comp1 = (String)argTypeNames.get(i); String comp1 = argTypeNames.get(i);
String comp2 = (String)nameList.get(i); String comp2 = nameList.get(i);
if (! comp1.equals(comp2)) { if (! comp1.equals(comp2)) {
/* /*
* We have to handle varargs. EG, the * We have to handle varargs. EG, the
...@@ -288,22 +287,17 @@ public class MethodBreakpointSpec extends BreakpointSpec { ...@@ -288,22 +287,17 @@ public class MethodBreakpointSpec extends BreakpointSpec {
List<String> argTypeNames = null; List<String> argTypeNames = null;
if (methodArgs() != null) { if (methodArgs() != null) {
argTypeNames = new ArrayList<String>(methodArgs().size()); argTypeNames = new ArrayList<String>(methodArgs().size());
Iterator iter = methodArgs().iterator(); for (String name : methodArgs()) {
while (iter.hasNext()) {
String name = (String)iter.next();
name = normalizeArgTypeName(name); name = normalizeArgTypeName(name);
argTypeNames.add(name); argTypeNames.add(name);
} }
} }
// Check each method in the class for matches // Check each method in the class for matches
Iterator iter = clazz.methods().iterator();
Method firstMatch = null; // first method with matching name Method firstMatch = null; // first method with matching name
Method exactMatch = null; // (only) method with same name & sig Method exactMatch = null; // (only) method with same name & sig
int matchCount = 0; // > 1 implies overload int matchCount = 0; // > 1 implies overload
while (iter.hasNext()) { for (Method candidate : clazz.methods()) {
Method candidate = (Method)iter.next();
if (candidate.name().equals(methodName())) { if (candidate.name().equals(methodName())) {
matchCount++; matchCount++;
......
...@@ -36,7 +36,7 @@ import java.util.Iterator; ...@@ -36,7 +36,7 @@ import java.util.Iterator;
* Descend the tree of thread groups. * Descend the tree of thread groups.
* @author Robert G. Field * @author Robert G. Field
*/ */
public class ThreadGroupIterator implements Iterator { public class ThreadGroupIterator implements Iterator<ThreadGroupReference> {
private final Stack<Iterator<ThreadGroupReference>> stack private final Stack<Iterator<ThreadGroupReference>> stack
= new Stack<Iterator<ThreadGroupReference>>(); = new Stack<Iterator<ThreadGroupReference>>();
...@@ -56,8 +56,8 @@ public class ThreadGroupIterator implements Iterator { ...@@ -56,8 +56,8 @@ public class ThreadGroupIterator implements Iterator {
} }
*/ */
private Iterator top() { private Iterator<ThreadGroupReference> top() {
return (Iterator)stack.peek(); return stack.peek();
} }
/** /**
...@@ -77,12 +77,12 @@ public class ThreadGroupIterator implements Iterator { ...@@ -77,12 +77,12 @@ public class ThreadGroupIterator implements Iterator {
return !stack.isEmpty(); return !stack.isEmpty();
} }
public Object next() { public ThreadGroupReference next() {
return nextThreadGroup(); return nextThreadGroup();
} }
public ThreadGroupReference nextThreadGroup() { public ThreadGroupReference nextThreadGroup() {
ThreadGroupReference tg = (ThreadGroupReference)top().next(); ThreadGroupReference tg = top().next();
push(tg.threadGroups()); push(tg.threadGroups());
return tg; return tg;
} }
......
...@@ -30,8 +30,8 @@ import com.sun.jdi.ThreadReference; ...@@ -30,8 +30,8 @@ import com.sun.jdi.ThreadReference;
import java.util.List; import java.util.List;
import java.util.Iterator; import java.util.Iterator;
public class ThreadIterator implements Iterator { public class ThreadIterator implements Iterator<ThreadReference> {
Iterator it = null; Iterator<ThreadReference> it = null;
ThreadGroupIterator tgi; ThreadGroupIterator tgi;
public ThreadIterator(ThreadGroupReference tg) { public ThreadIterator(ThreadGroupReference tg) {
...@@ -53,12 +53,12 @@ public class ThreadIterator implements Iterator { ...@@ -53,12 +53,12 @@ public class ThreadIterator implements Iterator {
return true; return true;
} }
public Object next() { public ThreadReference next() {
return it.next(); return it.next();
} }
public ThreadReference nextThread() { public ThreadReference nextThread() {
return (ThreadReference)next(); return next();
} }
public void remove() { public void remove() {
......
...@@ -191,11 +191,12 @@ abstract class LValue { ...@@ -191,11 +191,12 @@ abstract class LValue {
return field; return field;
} }
static List methodsByName(ReferenceType refType, String name, int kind) { static List<Method> methodsByName(ReferenceType refType,
List list = refType.methodsByName(name); String name, int kind) {
Iterator iter = list.iterator(); List<Method> list = refType.methodsByName(name);
Iterator<Method> iter = list.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Method method = (Method)iter.next(); Method method = iter.next();
boolean isStatic = method.isStatic(); boolean isStatic = method.isStatic();
if (((kind == STATIC) && !isStatic) || if (((kind == STATIC) && !isStatic) ||
((kind == INSTANCE) && isStatic)) { ((kind == INSTANCE) && isStatic)) {
...@@ -231,21 +232,21 @@ abstract class LValue { ...@@ -231,21 +232,21 @@ abstract class LValue {
* argType is not assignable from the type of the argument value. * argType is not assignable from the type of the argument value.
* IE, one is an Apple and the other is an Orange. * IE, one is an Apple and the other is an Orange.
*/ */
static int argumentsMatch(List argTypes, List arguments) { static int argumentsMatch(List<Type> argTypes, List<Value> arguments) {
if (argTypes.size() != arguments.size()) { if (argTypes.size() != arguments.size()) {
return DIFFERENT; return DIFFERENT;
} }
Iterator typeIter = argTypes.iterator(); Iterator<Type> typeIter = argTypes.iterator();
Iterator valIter = arguments.iterator(); Iterator<Value> valIter = arguments.iterator();
int result = SAME; int result = SAME;
// If any pair aren't the same, change the // If any pair aren't the same, change the
// result to ASSIGNABLE. If any pair aren't // result to ASSIGNABLE. If any pair aren't
// assignable, return DIFFERENT // assignable, return DIFFERENT
while (typeIter.hasNext()) { while (typeIter.hasNext()) {
Type argType = (Type)typeIter.next(); Type argType = typeIter.next();
Value value = (Value)valIter.next(); Value value = valIter.next();
if (value == null) { if (value == null) {
// Null values can be passed to any non-primitive argument // Null values can be passed to any non-primitive argument
if (primitiveTypeNames.contains(argType.name())) { if (primitiveTypeNames.contains(argType.name())) {
...@@ -333,7 +334,7 @@ abstract class LValue { ...@@ -333,7 +334,7 @@ abstract class LValue {
if (fromType instanceof ArrayType) { if (fromType instanceof ArrayType) {
return isArrayAssignableTo((ArrayType)fromType, toType); return isArrayAssignableTo((ArrayType)fromType, toType);
} }
List interfaces; List<InterfaceType> interfaces;
if (fromType instanceof ClassType) { if (fromType instanceof ClassType) {
ClassType superclazz = ((ClassType)fromType).superclass(); ClassType superclazz = ((ClassType)fromType).superclass();
if ((superclazz != null) && isAssignableTo(superclazz, toType)) { if ((superclazz != null) && isAssignableTo(superclazz, toType)) {
...@@ -344,9 +345,7 @@ abstract class LValue { ...@@ -344,9 +345,7 @@ abstract class LValue {
// fromType must be an InterfaceType // fromType must be an InterfaceType
interfaces = ((InterfaceType)fromType).superinterfaces(); interfaces = ((InterfaceType)fromType).superinterfaces();
} }
Iterator iter = interfaces.iterator(); for (InterfaceType interfaze : interfaces) {
while (iter.hasNext()) {
InterfaceType interfaze = (InterfaceType)iter.next();
if (isAssignableTo(interfaze, toType)) { if (isAssignableTo(interfaze, toType)) {
return true; return true;
} }
...@@ -354,7 +353,8 @@ abstract class LValue { ...@@ -354,7 +353,8 @@ abstract class LValue {
return false; return false;
} }
static Method resolveOverload(List overloads, List arguments) static Method resolveOverload(List<Method> overloads,
List<Value> arguments)
throws ParseException { throws ParseException {
// If there is only one method to call, we'll just choose // If there is only one method to call, we'll just choose
...@@ -362,7 +362,7 @@ abstract class LValue { ...@@ -362,7 +362,7 @@ abstract class LValue {
// the invoke will return a better error message than we // the invoke will return a better error message than we
// could generate here. // could generate here.
if (overloads.size() == 1) { if (overloads.size() == 1) {
return (Method)overloads.get(0); return overloads.get(0);
} }
// Resolving overloads is beyond the scope of this exercise. // Resolving overloads is beyond the scope of this exercise.
...@@ -374,12 +374,10 @@ abstract class LValue { ...@@ -374,12 +374,10 @@ abstract class LValue {
// methods to call. And, since casts aren't implemented, // methods to call. And, since casts aren't implemented,
// the user can't use them to pick a particular overload to call. // the user can't use them to pick a particular overload to call.
// IE, the user is out of luck in this case. // IE, the user is out of luck in this case.
Iterator iter = overloads.iterator();
Method retVal = null; Method retVal = null;
int assignableCount = 0; int assignableCount = 0;
while (iter.hasNext()) { for (Method mm : overloads) {
Method mm = (Method)iter.next(); List<Type> argTypes;
List argTypes;
try { try {
argTypes = mm.argumentTypes(); argTypes = mm.argumentTypes();
} catch (ClassNotLoadedException ee) { } catch (ClassNotLoadedException ee) {
...@@ -443,7 +441,7 @@ abstract class LValue { ...@@ -443,7 +441,7 @@ abstract class LValue {
final ObjectReference obj; final ObjectReference obj;
final ThreadReference thread; final ThreadReference thread;
final Field matchingField; final Field matchingField;
final List overloads; final List<Method> overloads;
Method matchingMethod = null; Method matchingMethod = null;
List<Value> methodArguments = null; List<Value> methodArguments = null;
...@@ -510,7 +508,7 @@ abstract class LValue { ...@@ -510,7 +508,7 @@ abstract class LValue {
final ReferenceType refType; final ReferenceType refType;
final ThreadReference thread; final ThreadReference thread;
final Field matchingField; final Field matchingField;
final List overloads; final List<Method> overloads;
Method matchingMethod = null; Method matchingMethod = null;
List<Value> methodArguments = null; List<Value> methodArguments = null;
...@@ -765,7 +763,7 @@ abstract class LValue { ...@@ -765,7 +763,7 @@ abstract class LValue {
static LValue makeNewObject(VirtualMachine vm, static LValue makeNewObject(VirtualMachine vm,
ExpressionParser.GetFrame frameGetter, ExpressionParser.GetFrame frameGetter,
String className, List<Value> arguments) throws ParseException { String className, List<Value> arguments) throws ParseException {
List classes = vm.classesByName(className); List<ReferenceType> classes = vm.classesByName(className);
if (classes.size() == 0) { if (classes.size() == 0) {
throw new ParseException("No class named: " + className); throw new ParseException("No class named: " + className);
} }
...@@ -774,7 +772,7 @@ abstract class LValue { ...@@ -774,7 +772,7 @@ abstract class LValue {
throw new ParseException("More than one class named: " + throw new ParseException("More than one class named: " +
className); className);
} }
ReferenceType refType = (ReferenceType)classes.get(0); ReferenceType refType = classes.get(0);
if (!(refType instanceof ClassType)) { if (!(refType instanceof ClassType)) {
...@@ -784,9 +782,9 @@ abstract class LValue { ...@@ -784,9 +782,9 @@ abstract class LValue {
ClassType classType = (ClassType)refType; ClassType classType = (ClassType)refType;
List<Method> methods = new ArrayList<Method>(classType.methods()); // writable List<Method> methods = new ArrayList<Method>(classType.methods()); // writable
Iterator iter = methods.iterator(); Iterator<Method> iter = methods.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Method method = (Method)iter.next(); Method method = iter.next();
if (!method.isConstructor()) { if (!method.isConstructor()) {
iter.remove(); iter.remove();
} }
...@@ -858,13 +856,13 @@ abstract class LValue { ...@@ -858,13 +856,13 @@ abstract class LValue {
} }
// check for class name // check for class name
while (izer.hasMoreTokens()) { while (izer.hasMoreTokens()) {
List classes = vm.classesByName(first); List<ReferenceType> classes = vm.classesByName(first);
if (classes.size() > 0) { if (classes.size() > 0) {
if (classes.size() > 1) { if (classes.size() > 1) {
throw new ParseException("More than one class named: " + throw new ParseException("More than one class named: " +
first); first);
} else { } else {
ReferenceType refType = (ReferenceType)classes.get(0); ReferenceType refType = classes.get(0);
LValue lval = new LValueStaticMember(refType, LValue lval = new LValueStaticMember(refType,
izer.nextToken(), thread); izer.nextToken(), thread);
return nFields(lval, izer, thread); return nFields(lval, izer, thread);
......
...@@ -124,9 +124,7 @@ public class ClassTreeTool extends JPanel { ...@@ -124,9 +124,7 @@ public class ClassTreeTool extends JPanel {
public void sessionStart(EventObject e) { public void sessionStart(EventObject e) {
// Get system classes and any others loaded before attaching. // Get system classes and any others loaded before attaching.
try { try {
Iterator iter = runtime.allClasses().iterator(); for (ReferenceType type : runtime.allClasses()) {
while (iter.hasNext()) {
ReferenceType type = ((ReferenceType)iter.next());
root.addClass(type); root.addClass(type);
} }
} catch (VMDisconnectedException ee) { } catch (VMDisconnectedException ee) {
......
...@@ -77,7 +77,7 @@ public class CommandInterpreter { ...@@ -77,7 +77,7 @@ public class CommandInterpreter {
while (ti.hasNext()) { while (ti.hasNext()) {
tlist.add(ti.nextThread()); tlist.add(ti.nextThread());
} }
threads = (ThreadReference[])tlist.toArray(new ThreadReference[tlist.size()]); threads = tlist.toArray(new ThreadReference[tlist.size()]);
} }
return threads; return threads;
} }
...@@ -146,11 +146,9 @@ public class CommandInterpreter { ...@@ -146,11 +146,9 @@ public class CommandInterpreter {
// Command: classes // Command: classes
private void commandClasses() throws NoSessionException { private void commandClasses() throws NoSessionException {
List list = runtime.allClasses();
OutputSink out = env.getOutputSink(); OutputSink out = env.getOutputSink();
//out.println("** classes list **"); //out.println("** classes list **");
for (int i = 0 ; i < list.size() ; i++) { for (ReferenceType refType : runtime.allClasses()) {
ReferenceType refType = (ReferenceType)list.get(i);
out.println(refType.name()); out.println(refType.name());
} }
out.show(); out.show();
...@@ -167,16 +165,16 @@ public class CommandInterpreter { ...@@ -167,16 +165,16 @@ public class CommandInterpreter {
String idClass = t.nextToken(); String idClass = t.nextToken();
ReferenceType cls = findClass(idClass); ReferenceType cls = findClass(idClass);
if (cls != null) { if (cls != null) {
List methods = cls.allMethods(); List<Method> methods = cls.allMethods();
OutputSink out = env.getOutputSink(); OutputSink out = env.getOutputSink();
for (int i = 0; i < methods.size(); i++) { for (int i = 0; i < methods.size(); i++) {
Method method = (Method)methods.get(i); Method method = methods.get(i);
out.print(method.declaringType().name() + " " + out.print(method.declaringType().name() + " " +
method.name() + "("); method.name() + "(");
Iterator it = method.argumentTypeNames().iterator(); Iterator<String> it = method.argumentTypeNames().iterator();
if (it.hasNext()) { if (it.hasNext()) {
while (true) { while (true) {
out.print((String)it.next()); out.print(it.next());
if (!it.hasNext()) { if (!it.hasNext()) {
break; break;
} }
...@@ -193,10 +191,10 @@ public class CommandInterpreter { ...@@ -193,10 +191,10 @@ public class CommandInterpreter {
} }
private ReferenceType findClass(String pattern) throws NoSessionException { private ReferenceType findClass(String pattern) throws NoSessionException {
List results = runtime.findClassesMatchingPattern(pattern); List<ReferenceType> results = runtime.findClassesMatchingPattern(pattern);
if (results.size() > 0) { if (results.size() > 0) {
//### Should handle multiple results sensibly. //### Should handle multiple results sensibly.
return (ReferenceType)results.get(0); return results.get(0);
} }
return null; return null;
} }
...@@ -235,11 +233,11 @@ public class CommandInterpreter { ...@@ -235,11 +233,11 @@ public class CommandInterpreter {
private int printThreadGroup(OutputSink out, ThreadGroupReference tg, int iThread) { private int printThreadGroup(OutputSink out, ThreadGroupReference tg, int iThread) {
out.println("Group " + tg.name() + ":"); out.println("Group " + tg.name() + ":");
List tlist = tg.threads(); List<ThreadReference> tlist = tg.threads();
int maxId = 0; int maxId = 0;
int maxName = 0; int maxName = 0;
for (int i = 0 ; i < tlist.size() ; i++) { for (int i = 0 ; i < tlist.size() ; i++) {
ThreadReference thr = (ThreadReference)tlist.get(i); ThreadReference thr = tlist.get(i);
int len = Utils.description(thr).length(); int len = Utils.description(thr).length();
if (len > maxId) if (len > maxId)
maxId = len; maxId = len;
...@@ -254,7 +252,7 @@ public class CommandInterpreter { ...@@ -254,7 +252,7 @@ public class CommandInterpreter {
String maxNumString = String.valueOf(iThread + tlist.size()); String maxNumString = String.valueOf(iThread + tlist.size());
int maxNumDigits = maxNumString.length(); int maxNumDigits = maxNumString.length();
for (int i = 0 ; i < tlist.size() ; i++) { for (int i = 0 ; i < tlist.size() ; i++) {
ThreadReference thr = (ThreadReference)tlist.get(i); ThreadReference thr = tlist.get(i);
char buf[] = new char[80]; char buf[] = new char[80];
for (int j = 0; j < 79; j++) { for (int j = 0; j < 79; j++) {
buf[j] = ' '; buf[j] = ' ';
...@@ -283,9 +281,7 @@ public class CommandInterpreter { ...@@ -283,9 +281,7 @@ public class CommandInterpreter {
sbOut.setLength(79); sbOut.setLength(79);
out.println(sbOut.toString()); out.println(sbOut.toString());
} }
List tglist = tg.threadGroups(); for (ThreadGroupReference tg0 : tg.threadGroups()) {
for (int ig = 0; ig < tglist.size(); ig++) {
ThreadGroupReference tg0 = (ThreadGroupReference)tglist.get(ig);
if (!tg.equals(tg0)) { // TODO ref mgt if (!tg.equals(tg0)) { // TODO ref mgt
iThread += printThreadGroup(out, tg0, iThread + tlist.size()); iThread += printThreadGroup(out, tg0, iThread + tlist.size());
} }
...@@ -733,7 +729,7 @@ public class CommandInterpreter { ...@@ -733,7 +729,7 @@ public class CommandInterpreter {
if (token.toLowerCase().equals("all")) { if (token.toLowerCase().equals("all")) {
ThreadIterator it = allThreads(); ThreadIterator it = allThreads();
while (it.hasNext()) { while (it.hasNext()) {
ThreadReference thread = (ThreadReference)it.next(); ThreadReference thread = it.next();
out.println(thread.name() + ": "); out.println(thread.name() + ": ");
dumpStack(thread, showPC); dumpStack(thread, showPC);
} }
...@@ -755,7 +751,7 @@ public class CommandInterpreter { ...@@ -755,7 +751,7 @@ public class CommandInterpreter {
//env.failure("Target VM must be in interrupted state."); //env.failure("Target VM must be in interrupted state.");
//env.failure("Current thread isn't suspended."); //env.failure("Current thread isn't suspended.");
//### Should handle extremely long stack traces sensibly for user. //### Should handle extremely long stack traces sensibly for user.
List stack = null; List<StackFrame> stack = null;
try { try {
stack = thread.frames(); stack = thread.frames();
} catch (IncompatibleThreadStateException e) { } catch (IncompatibleThreadStateException e) {
...@@ -772,7 +768,7 @@ public class CommandInterpreter { ...@@ -772,7 +768,7 @@ public class CommandInterpreter {
OutputSink out = env.getOutputSink(); OutputSink out = env.getOutputSink();
int nFrames = stack.size(); int nFrames = stack.size();
for (int i = frameIndex; i < nFrames; i++) { for (int i = frameIndex; i < nFrames; i++) {
StackFrame frame = (StackFrame)stack.get(i); StackFrame frame = stack.get(i);
Location loc = frame.location(); Location loc = frame.location();
Method meth = loc.method(); Method meth = loc.method();
out.print(" [" + (i + 1) + "] "); out.print(" [" + (i + 1) + "] ");
...@@ -780,7 +776,7 @@ public class CommandInterpreter { ...@@ -780,7 +776,7 @@ public class CommandInterpreter {
out.print('.'); out.print('.');
out.print(meth.name()); out.print(meth.name());
out.print(" ("); out.print(" (");
if (meth instanceof Method && ((Method)meth).isNative()) { if (meth.isNative()) {
out.print("native method"); out.print("native method");
} else if (loc.lineNumber() != -1) { } else if (loc.lineNumber() != -1) {
try { try {
...@@ -806,14 +802,13 @@ public class CommandInterpreter { ...@@ -806,14 +802,13 @@ public class CommandInterpreter {
private void listEventRequests() throws NoSessionException { private void listEventRequests() throws NoSessionException {
// Print set breakpoints // Print set breakpoints
Iterator iter = runtime.eventRequestSpecs().iterator(); List<EventRequestSpec> specs = runtime.eventRequestSpecs();
if (!iter.hasNext()) { if (specs.isEmpty()) {
env.notice("No breakpoints/watchpoints/exceptions set."); env.notice("No breakpoints/watchpoints/exceptions set.");
} else { } else {
OutputSink out = env.getOutputSink(); OutputSink out = env.getOutputSink();
out.println("Current breakpoints/watchpoints/exceptions set:"); out.println("Current breakpoints/watchpoints/exceptions set:");
while (iter.hasNext()) { for (EventRequestSpec bp : specs) {
EventRequestSpec bp = (EventRequestSpec)iter.next();
out.println("\t" + bp); out.println("\t" + bp);
} }
out.show(); out.show();
...@@ -926,13 +921,13 @@ public class CommandInterpreter { ...@@ -926,13 +921,13 @@ public class CommandInterpreter {
//### need 'clear all' //### need 'clear all'
BreakpointSpec bpSpec = parseBreakpointSpec(t.nextToken()); BreakpointSpec bpSpec = parseBreakpointSpec(t.nextToken());
if (bpSpec != null) { if (bpSpec != null) {
Iterator iter = runtime.eventRequestSpecs().iterator(); List<EventRequestSpec> specs = runtime.eventRequestSpecs();
if (!iter.hasNext()) {
if (specs.isEmpty()) {
env.notice("No breakpoints set."); env.notice("No breakpoints set.");
} else { } else {
List<BreakpointSpec> toDelete = new ArrayList<BreakpointSpec>(); List<EventRequestSpec> toDelete = new ArrayList<EventRequestSpec>();
while (iter.hasNext()) { for (EventRequestSpec spec : specs) {
BreakpointSpec spec = (BreakpointSpec)iter.next();
if (spec.equals(bpSpec)) { if (spec.equals(bpSpec)) {
toDelete.add(spec); toDelete.add(spec);
} }
...@@ -941,7 +936,7 @@ public class CommandInterpreter { ...@@ -941,7 +936,7 @@ public class CommandInterpreter {
if (toDelete.size() <= 1) { if (toDelete.size() <= 1) {
env.notice("No matching breakpoint set."); env.notice("No matching breakpoint set.");
} }
for (BreakpointSpec spec : toDelete) { for (EventRequestSpec spec : toDelete) {
runtime.delete(spec); runtime.delete(spec);
} }
} }
...@@ -988,7 +983,7 @@ public class CommandInterpreter { ...@@ -988,7 +983,7 @@ public class CommandInterpreter {
lineno = Integer.valueOf(id).intValue(); lineno = Integer.valueOf(id).intValue();
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
// It isn't -- see if it's a method name. // It isn't -- see if it's a method name.
List meths = refType.methodsByName(id); List<Method> meths = refType.methodsByName(id);
if (meths == null || meths.size() == 0) { if (meths == null || meths.size() == 0) {
env.failure(id + env.failure(id +
" is not a valid line number or " + " is not a valid line number or " +
...@@ -1001,7 +996,7 @@ public class CommandInterpreter { ...@@ -1001,7 +996,7 @@ public class CommandInterpreter {
refType.name()); refType.name());
return; return;
} }
loc = ((Method)meths.get(0)).location(); loc = meths.get(0).location();
lineno = loc.lineNumber(); lineno = loc.lineNumber();
} }
} }
...@@ -1121,7 +1116,7 @@ public class CommandInterpreter { ...@@ -1121,7 +1116,7 @@ public class CommandInterpreter {
return; return;
} }
List vars; List<LocalVariable> vars;
try { try {
vars = frame.visibleVariables(); vars = frame.visibleVariables();
if (vars == null || vars.size() == 0) { if (vars == null || vars.size() == 0) {
...@@ -1136,15 +1131,13 @@ public class CommandInterpreter { ...@@ -1136,15 +1131,13 @@ public class CommandInterpreter {
OutputSink out = env.getOutputSink(); OutputSink out = env.getOutputSink();
out.println("Method arguments:"); out.println("Method arguments:");
for (Iterator it = vars.iterator(); it.hasNext(); ) { for (LocalVariable var : vars) {
LocalVariable var = (LocalVariable)it.next();
if (var.isArgument()) { if (var.isArgument()) {
printVar(out, var, frame); printVar(out, var, frame);
} }
} }
out.println("Local variables:"); out.println("Local variables:");
for (Iterator it = vars.iterator(); it.hasNext(); ) { for (LocalVariable var : vars) {
LocalVariable var = (LocalVariable)it.next();
if (!var.isArgument()) { if (!var.isArgument()) {
printVar(out, var, frame); printVar(out, var, frame);
} }
...@@ -1245,8 +1238,7 @@ public class CommandInterpreter { ...@@ -1245,8 +1238,7 @@ public class CommandInterpreter {
private void dump(OutputSink out, private void dump(OutputSink out,
ObjectReference obj, ReferenceType refType, ObjectReference obj, ReferenceType refType,
ReferenceType refTypeBase) { ReferenceType refTypeBase) {
for (Iterator it = refType.fields().iterator(); it.hasNext(); ) { for (Field field : refType.fields()) {
Field field = (Field)it.next();
out.print(" "); out.print(" ");
if (!refType.equals(refTypeBase)) { if (!refType.equals(refTypeBase)) {
out.print(refType.name() + "."); out.print(refType.name() + ".");
...@@ -1261,9 +1253,8 @@ public class CommandInterpreter { ...@@ -1261,9 +1253,8 @@ public class CommandInterpreter {
dump(out, obj, sup, refTypeBase); dump(out, obj, sup, refTypeBase);
} }
} else if (refType instanceof InterfaceType) { } else if (refType instanceof InterfaceType) {
List sups = ((InterfaceType)refType).superinterfaces(); for (InterfaceType sup : ((InterfaceType)refType).superinterfaces()) {
for (Iterator it = sups.iterator(); it.hasNext(); ) { dump(out, obj, sup, refTypeBase);
dump(out, obj, (ReferenceType)it.next(), refTypeBase);
} }
} }
} }
......
...@@ -201,11 +201,11 @@ public class JDBFileFilter extends FileFilter { ...@@ -201,11 +201,11 @@ public class JDBFileFilter extends FileFilter {
if(description == null || isExtensionListInDescription()) { if(description == null || isExtensionListInDescription()) {
fullDescription = description==null ? "(" : description + " ("; fullDescription = description==null ? "(" : description + " (";
// build the description from the extension list // build the description from the extension list
Enumeration extensions = filters.keys(); Enumeration<String> extensions = filters.keys();
if(extensions != null) { if(extensions != null) {
fullDescription += "." + (String) extensions.nextElement(); fullDescription += "." + extensions.nextElement();
while (extensions.hasMoreElements()) { while (extensions.hasMoreElements()) {
fullDescription += ", " + (String) extensions.nextElement(); fullDescription += ", " + extensions.nextElement();
} }
} }
fullDescription += ")"; fullDescription += ")";
......
...@@ -131,14 +131,13 @@ class LaunchTool { ...@@ -131,14 +131,13 @@ class LaunchTool {
final JPanel radioPanel = new JPanel(); final JPanel radioPanel = new JPanel();
final ButtonGroup radioGroup = new ButtonGroup(); final ButtonGroup radioGroup = new ButtonGroup();
VirtualMachineManager manager = Bootstrap.virtualMachineManager(); VirtualMachineManager manager = Bootstrap.virtualMachineManager();
List all = manager.allConnectors(); List<Connector> all = manager.allConnectors();
Map<ButtonModel, Connector> modelToConnector = new HashMap<ButtonModel, Connector>(all.size(), 0.5f); Map<ButtonModel, Connector> modelToConnector = new HashMap<ButtonModel, Connector>(all.size(), 0.5f);
dialog.setModal(true); dialog.setModal(true);
dialog.setTitle("Select Connector Type"); dialog.setTitle("Select Connector Type");
radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.Y_AXIS)); radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.Y_AXIS));
for (Iterator it = all.iterator(); it.hasNext(); ) { for (Connector connector : all) {
Connector connector = (Connector)it.next();
JRadioButton radio = new JRadioButton(connector.description()); JRadioButton radio = new JRadioButton(connector.description());
modelToConnector.put(radio.getModel(), connector); modelToConnector.put(radio.getModel(), connector);
radioPanel.add(radio); radioPanel.add(radio);
...@@ -166,7 +165,7 @@ class LaunchTool { ...@@ -166,7 +165,7 @@ class LaunchTool {
dialog.show(); dialog.show();
return oked[0] ? return oked[0] ?
(Connector)(modelToConnector.get(radioGroup.getSelection())) : modelToConnector.get(radioGroup.getSelection()) :
null; null;
} }
...@@ -188,13 +187,12 @@ class LaunchTool { ...@@ -188,13 +187,12 @@ class LaunchTool {
// guts.add(new JLabel(connector.description())); // guts.add(new JLabel(connector.description()));
final List<ArgRep> argReps = new ArrayList<ArgRep>(args.size()); final List<ArgRep> argReps = new ArrayList<ArgRep>(args.size());
for (Iterator it = args.values().iterator(); it.hasNext(); ) { for (Connector.Argument arg : args.values()) {
Object arg = it.next();
ArgRep ar; ArgRep ar;
if (arg instanceof Connector.BooleanArgument) { if (arg instanceof Connector.BooleanArgument) {
ar = new BooleanArgRep((Connector.BooleanArgument)arg, guts); ar = new BooleanArgRep((Connector.BooleanArgument)arg, guts);
} else { } else {
ar = new StringArgRep((Connector.Argument)arg, guts); ar = new StringArgRep(arg, guts);
} }
argReps.add(ar); argReps.add(ar);
} }
...@@ -202,8 +200,7 @@ class LaunchTool { ...@@ -202,8 +200,7 @@ class LaunchTool {
JPanel buttonPanel = okCancel( dialog, new ActionListener() { JPanel buttonPanel = okCancel( dialog, new ActionListener() {
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
for (Iterator it = argReps.iterator(); it.hasNext(); ) { for (ArgRep ar : argReps) {
ArgRep ar = (ArgRep)it.next();
if (!ar.isSpecified()) { if (!ar.isSpecified()) {
JOptionPane.showMessageDialog(dialog, JOptionPane.showMessageDialog(dialog,
ar.arg.label() + ar.arg.label() +
......
...@@ -42,7 +42,7 @@ public class SearchPath { ...@@ -42,7 +42,7 @@ public class SearchPath {
dlist.add(st.nextToken()); dlist.add(st.nextToken());
} }
pathString = searchPath; pathString = searchPath;
pathArray = (String[])dlist.toArray(new String[dlist.size()]); pathArray = dlist.toArray(new String[dlist.size()]);
} }
public boolean isEmpty() { public boolean isEmpty() {
...@@ -54,7 +54,7 @@ public class SearchPath { ...@@ -54,7 +54,7 @@ public class SearchPath {
} }
public String[] asArray() { public String[] asArray() {
return (String[])pathArray.clone(); return pathArray.clone();
} }
public File resolve(String relativeFileName) { public File resolve(String relativeFileName) {
...@@ -89,7 +89,7 @@ public class SearchPath { ...@@ -89,7 +89,7 @@ public class SearchPath {
} }
} }
} }
return (String[])s.toArray(new String[s.size()]); return s.toArray(new String[s.size()]);
} }
} }
...@@ -113,7 +113,7 @@ public class SourceManager { ...@@ -113,7 +113,7 @@ public class SourceManager {
* Returns null if not available. * Returns null if not available.
*/ */
public SourceModel sourceForClass(ReferenceType refType) { public SourceModel sourceForClass(ReferenceType refType) {
SourceModel sm = (SourceModel)classToSource.get(refType); SourceModel sm = classToSource.get(refType);
if (sm != null) { if (sm != null) {
return sm; return sm;
} }
...@@ -140,10 +140,10 @@ public class SourceManager { ...@@ -140,10 +140,10 @@ public class SourceManager {
*/ */
//### Use hash table for this? //### Use hash table for this?
public SourceModel sourceForFile(File path) { public SourceModel sourceForFile(File path) {
Iterator iter = sourceList.iterator(); Iterator<SourceModel> iter = sourceList.iterator();
SourceModel sm = null; SourceModel sm = null;
while (iter.hasNext()) { while (iter.hasNext()) {
SourceModel candidate = (SourceModel)iter.next(); SourceModel candidate = iter.next();
if (candidate.fileName().equals(path)) { if (candidate.fileName().equals(path)) {
sm = candidate; sm = candidate;
iter.remove(); // Will move to start of list. iter.remove(); // Will move to start of list.
......
...@@ -187,22 +187,17 @@ public class SourceModel extends AbstractListModel { ...@@ -187,22 +187,17 @@ public class SourceModel extends AbstractListModel {
* when sourceLines is set. * when sourceLines is set.
*/ */
private void markClassLines(ReferenceType refType) { private void markClassLines(ReferenceType refType) {
List methods = refType.methods(); for (Method meth : refType.methods()) {
for (Iterator mit = methods.iterator(); mit.hasNext();) {
Method meth = (Method)mit.next();
try { try {
List lines = meth.allLineLocations(); for (Location loc : meth.allLineLocations()) {
for (Iterator lit = lines.iterator(); lit.hasNext();) {
Location loc = (Location)lit.next();
showExecutable(loc.lineNumber(), refType); showExecutable(loc.lineNumber(), refType);
} }
} catch (AbsentInformationException exc) { } catch (AbsentInformationException exc) {
// do nothing // do nothing
} }
} }
List bps = env.getExecutionManager().eventRequestManager().breakpointRequests(); for (BreakpointRequest bp :
for (Iterator it = bps.iterator(); it.hasNext();) { env.getExecutionManager().eventRequestManager().breakpointRequests()) {
BreakpointRequest bp = (BreakpointRequest)it.next();
if (bp.location() != null) { if (bp.location() != null) {
Location loc = bp.location(); Location loc = bp.location();
if (loc.declaringType().equals(refType)) { if (loc.declaringType().equals(refType)) {
...@@ -224,8 +219,8 @@ public class SourceModel extends AbstractListModel { ...@@ -224,8 +219,8 @@ public class SourceModel extends AbstractListModel {
} finally { } finally {
reader.close(); reader.close();
} }
for (Iterator it = classes.iterator(); it.hasNext();) { for (ReferenceType refType : classes) {
markClassLines((ClassType)it.next()); markClassLines(refType);
} }
} }
......
...@@ -139,7 +139,7 @@ public class StackTraceTool extends JPanel { ...@@ -139,7 +139,7 @@ public class StackTraceTool extends JPanel {
String methName = String methName =
meth.declaringType().name() + '.' + meth.name(); meth.declaringType().name() + '.' + meth.name();
String position = ""; String position = "";
if (meth instanceof Method && ((Method)meth).isNative()) { if (meth.isNative()) {
position = " (native method)"; position = " (native method)";
} else if (loc.lineNumber() != -1) { } else if (loc.lineNumber() != -1) {
position = ":" + loc.lineNumber(); position = ":" + loc.lineNumber();
......
...@@ -133,9 +133,7 @@ public class ThreadTreeTool extends JPanel { ...@@ -133,9 +133,7 @@ public class ThreadTreeTool extends JPanel {
public void sessionStart(EventObject e) { public void sessionStart(EventObject e) {
try { try {
Iterator iter = runtime.allThreads().iterator(); for (ThreadReference thread : runtime.allThreads()) {
while (iter.hasNext()) {
ThreadReference thread = ((ThreadReference)iter.next());
root.addThread(thread); root.addThread(thread);
} }
} catch (VMDisconnectedException ee) { } catch (VMDisconnectedException ee) {
...@@ -244,16 +242,16 @@ public class ThreadTreeTool extends JPanel { ...@@ -244,16 +242,16 @@ public class ThreadTreeTool extends JPanel {
} }
} }
private void addThread(List threadPath, ThreadReference thread) { private void addThread(List<String> threadPath, ThreadReference thread) {
int size = threadPath.size(); int size = threadPath.size();
if (size == 0) { if (size == 0) {
return; return;
} else if (size == 1) { } else if (size == 1) {
String name = (String)threadPath.get(0); String name = threadPath.get(0);
insertNode(name, thread); insertNode(name, thread);
} else { } else {
String head = (String)threadPath.get(0); String head = threadPath.get(0);
List tail = threadPath.subList(1, size); List<String> tail = threadPath.subList(1, size);
ThreadTreeNode child = insertNode(head, null); ThreadTreeNode child = insertNode(head, null);
child.addThread(tail, thread); child.addThread(tail, thread);
} }
...@@ -288,17 +286,17 @@ public class ThreadTreeTool extends JPanel { ...@@ -288,17 +286,17 @@ public class ThreadTreeTool extends JPanel {
} }
} }
private void removeThread(List threadPath, ThreadReference thread) { private void removeThread(List<String> threadPath, ThreadReference thread) {
int size = threadPath.size(); int size = threadPath.size();
if (size == 0) { if (size == 0) {
return; return;
} else if (size == 1) { } else if (size == 1) {
String name = (String)threadPath.get(0); String name = threadPath.get(0);
ThreadTreeNode child = findLeafNode(thread, name); ThreadTreeNode child = findLeafNode(thread, name);
treeModel.removeNodeFromParent(child); treeModel.removeNodeFromParent(child);
} else { } else {
String head = (String)threadPath.get(0); String head = threadPath.get(0);
List tail = threadPath.subList(1, size); List<String> tail = threadPath.subList(1, size);
ThreadTreeNode child = findInternalNode(head); ThreadTreeNode child = findInternalNode(head);
child.removeThread(tail, thread); child.removeThread(tail, thread);
if (child.isThreadGroup() && child.getChildCount() < 1) { if (child.isThreadGroup() && child.getChildCount() < 1) {
......
...@@ -34,7 +34,7 @@ import java.util.Iterator; ...@@ -34,7 +34,7 @@ import java.util.Iterator;
class BreakpointSpec extends EventRequestSpec { class BreakpointSpec extends EventRequestSpec {
String methodId; String methodId;
List methodArgs; List<String> methodArgs;
int lineNumber; int lineNumber;
BreakpointSpec(ReferenceTypeSpec refSpec, int lineNumber) { BreakpointSpec(ReferenceTypeSpec refSpec, int lineNumber) {
...@@ -45,7 +45,7 @@ class BreakpointSpec extends EventRequestSpec { ...@@ -45,7 +45,7 @@ class BreakpointSpec extends EventRequestSpec {
} }
BreakpointSpec(ReferenceTypeSpec refSpec, String methodId, BreakpointSpec(ReferenceTypeSpec refSpec, String methodId,
List methodArgs) throws MalformedMemberNameException { List<String> methodArgs) throws MalformedMemberNameException {
super(refSpec); super(refSpec);
this.methodId = methodId; this.methodId = methodId;
this.methodArgs = methodArgs; this.methodArgs = methodArgs;
...@@ -83,7 +83,7 @@ class BreakpointSpec extends EventRequestSpec { ...@@ -83,7 +83,7 @@ class BreakpointSpec extends EventRequestSpec {
return lineNumber; return lineNumber;
} }
List methodArgs() { List<String> methodArgs() {
return methodArgs; return methodArgs;
} }
...@@ -146,14 +146,13 @@ class BreakpointSpec extends EventRequestSpec { ...@@ -146,14 +146,13 @@ class BreakpointSpec extends EventRequestSpec {
buffer.append('.'); buffer.append('.');
buffer.append(methodId); buffer.append(methodId);
if (methodArgs != null) { if (methodArgs != null) {
Iterator iter = methodArgs.iterator();
boolean first = true; boolean first = true;
buffer.append('('); buffer.append('(');
while (iter.hasNext()) { for (String arg : methodArgs) {
if (!first) { if (!first) {
buffer.append(','); buffer.append(',');
} }
buffer.append((String)iter.next()); buffer.append(arg);
first = false; first = false;
} }
buffer.append(")"); buffer.append(")");
...@@ -176,12 +175,12 @@ class BreakpointSpec extends EventRequestSpec { ...@@ -176,12 +175,12 @@ class BreakpointSpec extends EventRequestSpec {
location = method.location(); location = method.location();
} else { } else {
// let AbsentInformationException be thrown // let AbsentInformationException be thrown
List locs = refType.locationsOfLine(lineNumber()); List<Location> locs = refType.locationsOfLine(lineNumber());
if (locs.size() == 0) { if (locs.size() == 0) {
throw new LineNotFoundException(); throw new LineNotFoundException();
} }
// TO DO: handle multiple locations // TO DO: handle multiple locations
location = (Location)locs.get(0); location = locs.get(0);
if (location.method() == null) { if (location.method() == null) {
throw new LineNotFoundException(); throw new LineNotFoundException();
} }
...@@ -202,8 +201,8 @@ class BreakpointSpec extends EventRequestSpec { ...@@ -202,8 +201,8 @@ class BreakpointSpec extends EventRequestSpec {
* and if the number of arguments in the method matches the * and if the number of arguments in the method matches the
* number of names passed * number of names passed
*/ */
private boolean compareArgTypes(Method method, List nameList) { private boolean compareArgTypes(Method method, List<String> nameList) {
List argTypeNames = method.argumentTypeNames(); List<String> argTypeNames = method.argumentTypeNames();
// If argument counts differ, we can stop here // If argument counts differ, we can stop here
if (argTypeNames.size() != nameList.size()) { if (argTypeNames.size() != nameList.size()) {
...@@ -213,8 +212,8 @@ class BreakpointSpec extends EventRequestSpec { ...@@ -213,8 +212,8 @@ class BreakpointSpec extends EventRequestSpec {
// Compare each argument type's name // Compare each argument type's name
int nTypes = argTypeNames.size(); int nTypes = argTypeNames.size();
for (int i = 0; i < nTypes; ++i) { for (int i = 0; i < nTypes; ++i) {
String comp1 = (String)argTypeNames.get(i); String comp1 = argTypeNames.get(i);
String comp2 = (String)nameList.get(i); String comp2 = nameList.get(i);
if (! comp1.equals(comp2)) { if (! comp1.equals(comp2)) {
/* /*
* We have to handle varargs. EG, the * We have to handle varargs. EG, the
...@@ -331,22 +330,17 @@ class BreakpointSpec extends EventRequestSpec { ...@@ -331,22 +330,17 @@ class BreakpointSpec extends EventRequestSpec {
List<String> argTypeNames = null; List<String> argTypeNames = null;
if (methodArgs() != null) { if (methodArgs() != null) {
argTypeNames = new ArrayList<String>(methodArgs().size()); argTypeNames = new ArrayList<String>(methodArgs().size());
Iterator iter = methodArgs().iterator(); for (String name : methodArgs()) {
while (iter.hasNext()) {
String name = (String)iter.next();
name = normalizeArgTypeName(name); name = normalizeArgTypeName(name);
argTypeNames.add(name); argTypeNames.add(name);
} }
} }
// Check each method in the class for matches // Check each method in the class for matches
Iterator iter = refType.methods().iterator();
Method firstMatch = null; // first method with matching name Method firstMatch = null; // first method with matching name
Method exactMatch = null; // (only) method with same name & sig Method exactMatch = null; // (only) method with same name & sig
int matchCount = 0; // > 1 implies overload int matchCount = 0; // > 1 implies overload
while (iter.hasNext()) { for (Method candidate : refType.methods()) {
Method candidate = (Method)iter.next();
if (candidate.name().equals(methodName())) { if (candidate.name().equals(methodName())) {
matchCount++; matchCount++;
......
...@@ -89,7 +89,7 @@ class Env { ...@@ -89,7 +89,7 @@ class Env {
sourceCache.clear(); sourceCache.clear();
} }
static void setSourcePath(List srcList) { static void setSourcePath(List<String> srcList) {
sourceMapper = new SourceMapper(srcList); sourceMapper = new SourceMapper(srcList);
sourceCache.clear(); sourceCache.clear();
} }
...@@ -106,10 +106,8 @@ class Env { ...@@ -106,10 +106,8 @@ class Env {
} }
static String excludesString() { static String excludesString() {
Iterator iter = excludes().iterator();
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
while (iter.hasNext()) { for (String pattern : excludes()) {
String pattern = (String)iter.next();
buffer.append(pattern); buffer.append(pattern);
buffer.append(","); buffer.append(",");
} }
...@@ -117,25 +115,19 @@ class Env { ...@@ -117,25 +115,19 @@ class Env {
} }
static void addExcludes(StepRequest request) { static void addExcludes(StepRequest request) {
Iterator iter = excludes().iterator(); for (String pattern : excludes()) {
while (iter.hasNext()) {
String pattern = (String)iter.next();
request.addClassExclusionFilter(pattern); request.addClassExclusionFilter(pattern);
} }
} }
static void addExcludes(MethodEntryRequest request) { static void addExcludes(MethodEntryRequest request) {
Iterator iter = excludes().iterator(); for (String pattern : excludes()) {
while (iter.hasNext()) {
String pattern = (String)iter.next();
request.addClassExclusionFilter(pattern); request.addClassExclusionFilter(pattern);
} }
} }
static void addExcludes(MethodExitRequest request) { static void addExcludes(MethodExitRequest request) {
Iterator iter = excludes().iterator(); for (String pattern : excludes()) {
while (iter.hasNext()) {
String pattern = (String)iter.next();
request.addClassExclusionFilter(pattern); request.addClassExclusionFilter(pattern);
} }
} }
...@@ -175,10 +167,10 @@ class Env { ...@@ -175,10 +167,10 @@ class Env {
try { try {
String fileName = location.sourceName(); String fileName = location.sourceName();
Iterator iter = sourceCache.iterator(); Iterator<SourceCode> iter = sourceCache.iterator();
SourceCode code = null; SourceCode code = null;
while (iter.hasNext()) { while (iter.hasNext()) {
SourceCode candidate = (SourceCode)iter.next(); SourceCode candidate = iter.next();
if (candidate.fileName().equals(fileName)) { if (candidate.fileName().equals(fileName)) {
code = candidate; code = candidate;
iter.remove(); iter.remove();
...@@ -269,10 +261,7 @@ class Env { ...@@ -269,10 +261,7 @@ class Env {
// loaded class whose name matches this limited regular // loaded class whose name matches this limited regular
// expression is selected. // expression is selected.
idToken = idToken.substring(1); idToken = idToken.substring(1);
List classes = Env.vm().allClasses(); for (ReferenceType type : Env.vm().allClasses()) {
Iterator iter = classes.iterator();
while (iter.hasNext()) {
ReferenceType type = ((ReferenceType)iter.next());
if (type.name().endsWith(idToken)) { if (type.name().endsWith(idToken)) {
cls = type; cls = type;
break; break;
...@@ -280,21 +269,21 @@ class Env { ...@@ -280,21 +269,21 @@ class Env {
} }
} else { } else {
// It's a class name // It's a class name
List classes = Env.vm().classesByName(idToken); List<ReferenceType> classes = Env.vm().classesByName(idToken);
if (classes.size() > 0) { if (classes.size() > 0) {
// TO DO: handle multiples // TO DO: handle multiples
cls = (ReferenceType)classes.get(0); cls = classes.get(0);
} }
} }
return cls; return cls;
} }
static Set getSaveKeys() { static Set<String> getSaveKeys() {
return savedValues.keySet(); return savedValues.keySet();
} }
static Value getSavedValue(String key) { static Value getSavedValue(String key) {
return (Value)savedValues.get(key); return savedValues.get(key);
} }
static void setSavedValue(String key, Value value) { static void setSavedValue(String key, Value value) {
...@@ -327,7 +316,7 @@ class Env { ...@@ -327,7 +316,7 @@ class Env {
if (index >= sourceLines.size()) { if (index >= sourceLines.size()) {
return null; return null;
} else { } else {
return (String)sourceLines.get(index); return sourceLines.get(index);
} }
} }
} }
......
...@@ -150,7 +150,7 @@ public class EventHandler implements Runnable { ...@@ -150,7 +150,7 @@ public class EventHandler implements Runnable {
EventSet eventSet = queue.remove(); EventSet eventSet = queue.remove();
EventIterator iter = eventSet.eventIterator(); EventIterator iter = eventSet.eventIterator();
while (iter.hasNext()) { while (iter.hasNext()) {
handleExitEvent((Event)iter.next()); handleExitEvent(iter.next());
} }
} catch (InterruptedException exc) { } catch (InterruptedException exc) {
// ignore // ignore
...@@ -183,7 +183,7 @@ public class EventHandler implements Runnable { ...@@ -183,7 +183,7 @@ public class EventHandler implements Runnable {
* If any event in the set has a thread associated with it, * If any event in the set has a thread associated with it,
* they all will, so just grab the first one. * they all will, so just grab the first one.
*/ */
Event event = (Event)set.iterator().next(); // Is there a better way? Event event = set.iterator().next(); // Is there a better way?
thread = eventThread(event); thread = eventThread(event);
} else { } else {
thread = null; thread = null;
......
...@@ -101,10 +101,8 @@ abstract class EventRequestSpec { ...@@ -101,10 +101,8 @@ abstract class EventRequestSpec {
* so that is all we need to examine. * so that is all we need to examine.
*/ */
ArrayList<ExceptionRequest> deleteList = new ArrayList<ExceptionRequest>(); ArrayList<ExceptionRequest> deleteList = new ArrayList<ExceptionRequest>();
Iterator iter = for (ExceptionRequest er :
Env.vm().eventRequestManager().exceptionRequests().iterator(); Env.vm().eventRequestManager().exceptionRequests()) {
while (iter.hasNext()) {
ExceptionRequest er = (ExceptionRequest)iter.next();
if (prs.matches(er.exception())) { if (prs.matches(er.exception())) {
deleteList.add (er); deleteList.add (er);
} }
...@@ -115,9 +113,7 @@ abstract class EventRequestSpec { ...@@ -115,9 +113,7 @@ abstract class EventRequestSpec {
} }
private EventRequest resolveAgainstPreparedClasses() throws Exception { private EventRequest resolveAgainstPreparedClasses() throws Exception {
Iterator iter = Env.vm().allClasses().iterator(); for (ReferenceType refType : Env.vm().allClasses()) {
while (iter.hasNext()) {
ReferenceType refType = (ReferenceType)iter.next();
if (refType.isPrepared() && refSpec.matches(refType)) { if (refType.isPrepared() && refSpec.matches(refType)) {
resolved = resolveEventRequest(refType); resolved = resolveEventRequest(refType);
} }
......
...@@ -55,9 +55,7 @@ class EventRequestSpecList { ...@@ -55,9 +55,7 @@ class EventRequestSpecList {
boolean resolve(ClassPrepareEvent event) { boolean resolve(ClassPrepareEvent event) {
boolean failure = false; boolean failure = false;
synchronized(eventRequestSpecs) { synchronized(eventRequestSpecs) {
Iterator iter = eventRequestSpecs.iterator(); for (EventRequestSpec spec : eventRequestSpecs) {
while (iter.hasNext()) {
EventRequestSpec spec = (EventRequestSpec)iter.next();
if (!spec.isResolved()) { if (!spec.isResolved()) {
try { try {
EventRequest eventRequest = spec.resolve(event); EventRequest eventRequest = spec.resolve(event);
...@@ -77,9 +75,7 @@ class EventRequestSpecList { ...@@ -77,9 +75,7 @@ class EventRequestSpecList {
} }
void resolveAll() { void resolveAll() {
Iterator iter = eventRequestSpecs.iterator(); for (EventRequestSpec spec : eventRequestSpecs) {
while (iter.hasNext()) {
EventRequestSpec spec = (EventRequestSpec)iter.next();
try { try {
EventRequest eventRequest = spec.resolveEagerly(); EventRequest eventRequest = spec.resolveEagerly();
if (eventRequest != null) { if (eventRequest != null) {
...@@ -106,16 +102,16 @@ class EventRequestSpecList { ...@@ -106,16 +102,16 @@ class EventRequestSpecList {
} }
} }
EventRequestSpec createBreakpoint(String classPattern, BreakpointSpec createBreakpoint(String classPattern, int line)
int line) throws ClassNotFoundException { throws ClassNotFoundException {
ReferenceTypeSpec refSpec = ReferenceTypeSpec refSpec =
new PatternReferenceTypeSpec(classPattern); new PatternReferenceTypeSpec(classPattern);
return new BreakpointSpec(refSpec, line); return new BreakpointSpec(refSpec, line);
} }
EventRequestSpec createBreakpoint(String classPattern, BreakpointSpec createBreakpoint(String classPattern,
String methodId, String methodId,
List methodArgs) List<String> methodArgs)
throws MalformedMemberNameException, throws MalformedMemberNameException,
ClassNotFoundException { ClassNotFoundException {
ReferenceTypeSpec refSpec = ReferenceTypeSpec refSpec =
...@@ -132,7 +128,7 @@ class EventRequestSpecList { ...@@ -132,7 +128,7 @@ class EventRequestSpecList {
return new ExceptionSpec(refSpec, notifyCaught, notifyUncaught); return new ExceptionSpec(refSpec, notifyCaught, notifyUncaught);
} }
EventRequestSpec createAccessWatchpoint(String classPattern, WatchpointSpec createAccessWatchpoint(String classPattern,
String fieldId) String fieldId)
throws MalformedMemberNameException, throws MalformedMemberNameException,
ClassNotFoundException { ClassNotFoundException {
...@@ -141,7 +137,7 @@ class EventRequestSpecList { ...@@ -141,7 +137,7 @@ class EventRequestSpecList {
return new AccessWatchpointSpec(refSpec, fieldId); return new AccessWatchpointSpec(refSpec, fieldId);
} }
EventRequestSpec createModificationWatchpoint(String classPattern, WatchpointSpec createModificationWatchpoint(String classPattern,
String fieldId) String fieldId)
throws MalformedMemberNameException, throws MalformedMemberNameException,
ClassNotFoundException { ClassNotFoundException {
...@@ -154,7 +150,7 @@ class EventRequestSpecList { ...@@ -154,7 +150,7 @@ class EventRequestSpecList {
synchronized (eventRequestSpecs) { synchronized (eventRequestSpecs) {
int inx = eventRequestSpecs.indexOf(proto); int inx = eventRequestSpecs.indexOf(proto);
if (inx != -1) { if (inx != -1) {
EventRequestSpec spec = (EventRequestSpec)eventRequestSpecs.get(inx); EventRequestSpec spec = eventRequestSpecs.get(inx);
spec.remove(); spec.remove();
eventRequestSpecs.remove(inx); eventRequestSpecs.remove(inx);
return true; return true;
......
...@@ -39,15 +39,13 @@ class SourceMapper { ...@@ -39,15 +39,13 @@ class SourceMapper {
private final String[] dirs; private final String[] dirs;
SourceMapper(List sourcepath) { SourceMapper(List<String> sourcepath) {
/* /*
* sourcepath can arrive from the debugee as a List. * sourcepath can arrive from the debugee as a List.
* (via PathSearchingVirtualMachine.classPath()) * (via PathSearchingVirtualMachine.classPath())
*/ */
List<String> dirList = new ArrayList<String>(); List<String> dirList = new ArrayList<String>();
Iterator iter = sourcepath.iterator(); for (String element : sourcepath) {
while (iter.hasNext()) {
String element = (String)iter.next();
//XXX remove .jar and .zip files; we want only directories on //XXX remove .jar and .zip files; we want only directories on
//the source path. (Bug ID 4186582) //the source path. (Bug ID 4186582)
if ( ! (element.endsWith(".jar") || if ( ! (element.endsWith(".jar") ||
...@@ -55,7 +53,7 @@ class SourceMapper { ...@@ -55,7 +53,7 @@ class SourceMapper {
dirList.add(element); dirList.add(element);
} }
} }
dirs = (String[])dirList.toArray(new String[0]); dirs = dirList.toArray(new String[0]);
} }
SourceMapper(String sourcepath) { SourceMapper(String sourcepath) {
...@@ -79,7 +77,7 @@ class SourceMapper { ...@@ -79,7 +77,7 @@ class SourceMapper {
dirList.add(s); dirList.add(s);
} }
} }
dirs = (String[])dirList.toArray(new String[0]); dirs = dirList.toArray(new String[0]);
} }
/* /*
......
...@@ -160,9 +160,7 @@ public class TTY implements EventNotifier { ...@@ -160,9 +160,7 @@ public class TTY implements EventNotifier {
// here the next time. // here the next time.
Env.setAtExitMethod(null); Env.setAtExitMethod(null);
EventRequestManager erm = Env.vm().eventRequestManager(); EventRequestManager erm = Env.vm().eventRequestManager();
Iterator it = erm.methodExitRequests().iterator(); for (EventRequest eReq : erm.methodExitRequests()) {
while (it.hasNext()) {
EventRequest eReq = (EventRequest)it.next();
if (eReq.equals(me.request())) { if (eReq.equals(me.request())) {
eReq.disable(); eReq.disable();
} }
...@@ -178,9 +176,8 @@ public class TTY implements EventNotifier { ...@@ -178,9 +176,8 @@ public class TTY implements EventNotifier {
public void vmInterrupted() { public void vmInterrupted() {
Thread.yield(); // fetch output Thread.yield(); // fetch output
printCurrentLocation(); printCurrentLocation();
Iterator it = monitorCommands.iterator(); for (String cmd : monitorCommands) {
while (it.hasNext()) { StringTokenizer t = new StringTokenizer(cmd);
StringTokenizer t = new StringTokenizer((String)it.next());
t.nextToken(); // get rid of monitor number t.nextToken(); // get rid of monitor number
executeCommand(t); executeCommand(t);
} }
...@@ -563,9 +560,8 @@ public class TTY implements EventNotifier { ...@@ -563,9 +560,8 @@ public class TTY implements EventNotifier {
++monitorCount; ++monitorCount;
monitorCommands.add(monitorCount + ": " + t.nextToken("")); monitorCommands.add(monitorCount + ": " + t.nextToken(""));
} else { } else {
Iterator it = monitorCommands.iterator(); for (String cmd : monitorCommands) {
while (it.hasNext()) { MessageOutput.printDirectln(cmd);// Special case: use printDirectln()
MessageOutput.printDirectln((String)it.next());// Special case: use printDirectln()
} }
} }
} }
...@@ -581,9 +577,7 @@ public class TTY implements EventNotifier { ...@@ -581,9 +577,7 @@ public class TTY implements EventNotifier {
return; return;
} }
String monStr = monTok + ":"; String monStr = monTok + ":";
Iterator it = monitorCommands.iterator(); for (String cmd : monitorCommands) {
while (it.hasNext()) {
String cmd = (String)it.next();
StringTokenizer ct = new StringTokenizer(cmd); StringTokenizer ct = new StringTokenizer(cmd);
if (ct.nextToken().equals(monStr)) { if (ct.nextToken().equals(monStr)) {
monitorCommands.remove(cmd); monitorCommands.remove(cmd);
...@@ -768,10 +762,8 @@ public class TTY implements EventNotifier { ...@@ -768,10 +762,8 @@ public class TTY implements EventNotifier {
} }
private static boolean supportsSharedMemory() { private static boolean supportsSharedMemory() {
List connectors = Bootstrap.virtualMachineManager().allConnectors(); for (Connector connector :
Iterator iter = connectors.iterator(); Bootstrap.virtualMachineManager().allConnectors()) {
while (iter.hasNext()) {
Connector connector = (Connector)iter.next();
if (connector.transport() == null) { if (connector.transport() == null) {
continue; continue;
} }
......
...@@ -36,7 +36,7 @@ import java.util.Iterator; ...@@ -36,7 +36,7 @@ import java.util.Iterator;
* Descend the tree of thread groups. * Descend the tree of thread groups.
* @author Robert G. Field * @author Robert G. Field
*/ */
class ThreadGroupIterator implements Iterator { class ThreadGroupIterator implements Iterator<ThreadGroupReference> {
private final Stack<Iterator<ThreadGroupReference>> stack = new Stack<Iterator<ThreadGroupReference>>(); private final Stack<Iterator<ThreadGroupReference>> stack = new Stack<Iterator<ThreadGroupReference>>();
ThreadGroupIterator(List<ThreadGroupReference> tgl) { ThreadGroupIterator(List<ThreadGroupReference> tgl) {
...@@ -53,8 +53,8 @@ class ThreadGroupIterator implements Iterator { ...@@ -53,8 +53,8 @@ class ThreadGroupIterator implements Iterator {
this(Env.vm().topLevelThreadGroups()); this(Env.vm().topLevelThreadGroups());
} }
private Iterator top() { private Iterator<ThreadGroupReference> top() {
return (Iterator)stack.peek(); return stack.peek();
} }
/** /**
...@@ -74,12 +74,12 @@ class ThreadGroupIterator implements Iterator { ...@@ -74,12 +74,12 @@ class ThreadGroupIterator implements Iterator {
return !stack.isEmpty(); return !stack.isEmpty();
} }
public Object next() { public ThreadGroupReference next() {
return nextThreadGroup(); return nextThreadGroup();
} }
public ThreadGroupReference nextThreadGroup() { public ThreadGroupReference nextThreadGroup() {
ThreadGroupReference tg = (ThreadGroupReference)top().next(); ThreadGroupReference tg = top().next();
push(tg.threadGroups()); push(tg.threadGroups());
return tg; return tg;
} }
......
...@@ -56,9 +56,7 @@ class ThreadInfo { ...@@ -56,9 +56,7 @@ class ThreadInfo {
private static void initThreads() { private static void initThreads() {
if (!gotInitialThreads) { if (!gotInitialThreads) {
Iterator iter = Env.vm().allThreads().iterator(); for (ThreadReference thread : Env.vm().allThreads()) {
while (iter.hasNext()) {
ThreadReference thread = (ThreadReference)iter.next();
threads.add(new ThreadInfo(thread)); threads.add(new ThreadInfo(thread));
} }
gotInitialThreads = true; gotInitialThreads = true;
...@@ -113,9 +111,7 @@ class ThreadInfo { ...@@ -113,9 +111,7 @@ class ThreadInfo {
current = null; current = null;
group = null; group = null;
synchronized (threads) { synchronized (threads) {
Iterator iter = threads().iterator(); for (ThreadInfo ti : threads()) {
while (iter.hasNext()) {
ThreadInfo ti = (ThreadInfo)iter.next();
ti.invalidate(); ti.invalidate();
} }
} }
...@@ -163,8 +159,7 @@ class ThreadInfo { ...@@ -163,8 +159,7 @@ class ThreadInfo {
if (group == null) { if (group == null) {
// Current thread group defaults to the first top level // Current thread group defaults to the first top level
// thread group. // thread group.
setThreadGroup((ThreadGroupReference) setThreadGroup(Env.vm().topLevelThreadGroups().get(0));
Env.vm().topLevelThreadGroups().get(0));
} }
return group; return group;
} }
...@@ -173,9 +168,7 @@ class ThreadInfo { ...@@ -173,9 +168,7 @@ class ThreadInfo {
ThreadInfo retInfo = null; ThreadInfo retInfo = null;
synchronized (threads) { synchronized (threads) {
Iterator iter = threads().iterator(); for (ThreadInfo ti : threads()) {
while (iter.hasNext()) {
ThreadInfo ti = (ThreadInfo)iter.next();
if (ti.thread.uniqueID() == id) { if (ti.thread.uniqueID() == id) {
retInfo = ti; retInfo = ti;
break; break;
...@@ -208,7 +201,7 @@ class ThreadInfo { ...@@ -208,7 +201,7 @@ class ThreadInfo {
* *
* @return a <code>List</code> of the stack frames. * @return a <code>List</code> of the stack frames.
*/ */
List getStack() throws IncompatibleThreadStateException { List<StackFrame> getStack() throws IncompatibleThreadStateException {
return thread.frames(); return thread.frames();
} }
......
...@@ -30,8 +30,8 @@ import com.sun.jdi.ThreadReference; ...@@ -30,8 +30,8 @@ import com.sun.jdi.ThreadReference;
import java.util.List; import java.util.List;
import java.util.Iterator; import java.util.Iterator;
class ThreadIterator implements Iterator { class ThreadIterator implements Iterator<ThreadReference> {
Iterator it = null; Iterator<ThreadReference> it = null;
ThreadGroupIterator tgi; ThreadGroupIterator tgi;
ThreadIterator(ThreadGroupReference tg) { ThreadIterator(ThreadGroupReference tg) {
...@@ -56,12 +56,12 @@ class ThreadIterator implements Iterator { ...@@ -56,12 +56,12 @@ class ThreadIterator implements Iterator {
return true; return true;
} }
public Object next() { public ThreadReference next() {
return it.next(); return it.next();
} }
public ThreadReference nextThread() { public ThreadReference nextThread() {
return (ThreadReference)next(); return next();
} }
public void remove() { public void remove() {
......
...@@ -61,10 +61,8 @@ class VMConnection { ...@@ -61,10 +61,8 @@ class VMConnection {
} }
private Connector findConnector(String name) { private Connector findConnector(String name) {
List connectors = Bootstrap.virtualMachineManager().allConnectors(); for (Connector connector :
Iterator iter = connectors.iterator(); Bootstrap.virtualMachineManager().allConnectors()) {
while (iter.hasNext()) {
Connector connector = (Connector)iter.next();
if (connector.name().equals(name)) { if (connector.name().equals(name)) {
return connector; return connector;
} }
...@@ -108,7 +106,7 @@ class VMConnection { ...@@ -108,7 +106,7 @@ class VMConnection {
String value = token.substring(index + 1, String value = token.substring(index + 1,
token.length() - 1); // Remove comma delimiter token.length() - 1); // Remove comma delimiter
Connector.Argument argument = (Connector.Argument)arguments.get(name); Connector.Argument argument = arguments.get(name);
if (argument == null) { if (argument == null) {
throw new IllegalArgumentException throw new IllegalArgumentException
(MessageOutput.format("Argument is not defined for connector:", (MessageOutput.format("Argument is not defined for connector:",
...@@ -195,7 +193,7 @@ class VMConnection { ...@@ -195,7 +193,7 @@ class VMConnection {
return false; return false;
} }
Connector.Argument argument = (Connector.Argument)connectorArgs.get(name); Connector.Argument argument = connectorArgs.get(name);
if (argument == null) { if (argument == null) {
return false; return false;
} }
...@@ -204,7 +202,7 @@ class VMConnection { ...@@ -204,7 +202,7 @@ class VMConnection {
} }
String connectorArg(String name) { String connectorArg(String name) {
Connector.Argument argument = (Connector.Argument)connectorArgs.get(name); Connector.Argument argument = connectorArgs.get(name);
if (argument == null) { if (argument == null) {
return ""; return "";
} }
......
...@@ -99,8 +99,7 @@ class ClassQuery extends QueryHandler { ...@@ -99,8 +99,7 @@ class ClassQuery extends QueryHandler {
} }
out.println("<h2>Instance Data Members:</h2>"); out.println("<h2>Instance Data Members:</h2>");
JavaField[] ff = clazz.getFields(); JavaField[] ff = clazz.getFields().clone();
ff = (JavaField[]) ff.clone();
ArraySorter.sort(ff, new Comparer() { ArraySorter.sort(ff, new Comparer() {
public int compare(Object lhs, Object rhs) { public int compare(Object lhs, Object rhs) {
JavaField left = (JavaField) lhs; JavaField left = (JavaField) lhs;
......
...@@ -90,9 +90,7 @@ public class PlatformClasses { ...@@ -90,9 +90,7 @@ public class PlatformClasses {
// is the right thing to do anyway. // is the right thing to do anyway.
} }
} }
int num = list.size(); names = list.toArray(new String[list.size()]);
names = new String[num];
names = (String[]) list.toArray(names);
} }
return names; return names;
} }
......
...@@ -119,7 +119,7 @@ abstract class AbstractLauncher extends ConnectorImpl implements LaunchingConnec ...@@ -119,7 +119,7 @@ abstract class AbstractLauncher extends ConnectorImpl implements LaunchingConnec
String[] tokenArray = new String[tokenList.size()]; String[] tokenArray = new String[tokenList.size()];
for (int i = 0; i < tokenList.size(); i++) { for (int i = 0; i < tokenList.size(); i++) {
tokenArray[i] = (String)tokenList.get(i); tokenArray[i] = tokenList.get(i);
} }
return tokenArray; return tokenArray;
} }
......
...@@ -95,11 +95,8 @@ public class ClassTypeImpl extends ReferenceTypeImpl ...@@ -95,11 +95,8 @@ public class ClassTypeImpl extends ReferenceTypeImpl
} }
public List<ClassType> subclasses() { public List<ClassType> subclasses() {
List<ReferenceType> all = vm.allClasses();
List<ClassType> subs = new ArrayList<ClassType>(); List<ClassType> subs = new ArrayList<ClassType>();
Iterator iter = all.iterator(); for (ReferenceType refType : vm.allClasses()) {
while (iter.hasNext()) {
ReferenceType refType = (ReferenceType)iter.next();
if (refType instanceof ClassType) { if (refType instanceof ClassType) {
ClassType clazz = (ClassType)refType; ClassType clazz = (ClassType)refType;
ClassType superclass = clazz.superclass(); ClassType superclass = clazz.superclass();
...@@ -223,7 +220,7 @@ public class ClassTypeImpl extends ReferenceTypeImpl ...@@ -223,7 +220,7 @@ public class ClassTypeImpl extends ReferenceTypeImpl
List<? extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments); List<? extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments);
ValueImpl[] args = (ValueImpl[])arguments.toArray(new ValueImpl[0]); ValueImpl[] args = arguments.toArray(new ValueImpl[0]);
JDWP.ClassType.InvokeMethod ret; JDWP.ClassType.InvokeMethod ret;
try { try {
PacketStream stream = PacketStream stream =
...@@ -271,7 +268,7 @@ public class ClassTypeImpl extends ReferenceTypeImpl ...@@ -271,7 +268,7 @@ public class ClassTypeImpl extends ReferenceTypeImpl
List<Value> arguments = method.validateAndPrepareArgumentsForInvoke( List<Value> arguments = method.validateAndPrepareArgumentsForInvoke(
origArguments); origArguments);
ValueImpl[] args = (ValueImpl[])arguments.toArray(new ValueImpl[0]); ValueImpl[] args = arguments.toArray(new ValueImpl[0]);
JDWP.ClassType.NewInstance ret = null; JDWP.ClassType.NewInstance ret = null;
try { try {
PacketStream stream = PacketStream stream =
...@@ -301,11 +298,8 @@ public class ClassTypeImpl extends ReferenceTypeImpl ...@@ -301,11 +298,8 @@ public class ClassTypeImpl extends ReferenceTypeImpl
} }
public Method concreteMethodByName(String name, String signature) { public Method concreteMethodByName(String name, String signature) {
List methods = visibleMethods();
Method method = null; Method method = null;
Iterator iter = methods.iterator(); for (Method candidate : visibleMethods()) {
while (iter.hasNext()) {
Method candidate = (Method)iter.next();
if (candidate.name().equals(name) && if (candidate.name().equals(name) &&
candidate.signature().equals(signature) && candidate.signature().equals(signature) &&
!candidate.isAbstract()) { !candidate.isAbstract()) {
...@@ -330,9 +324,7 @@ public class ClassTypeImpl extends ReferenceTypeImpl ...@@ -330,9 +324,7 @@ public class ClassTypeImpl extends ReferenceTypeImpl
* Avoid duplicate checking on each method by iterating through * Avoid duplicate checking on each method by iterating through
* duplicate-free allInterfaces() rather than recursing * duplicate-free allInterfaces() rather than recursing
*/ */
Iterator iter = allInterfaces().iterator(); for (InterfaceType interfaze : allInterfaces()) {
while (iter.hasNext()) {
InterfaceType interfaze = (InterfaceType)iter.next();
list.addAll(interfaze.methods()); list.addAll(interfaze.methods());
} }
......
...@@ -247,7 +247,7 @@ public class ConcreteMethodImpl extends MethodImpl { ...@@ -247,7 +247,7 @@ public class ConcreteMethodImpl extends MethodImpl {
public byte[] bytecodes() { public byte[] bytecodes() {
byte[] bytecodes = (bytecodesRef == null) ? null : byte[] bytecodes = (bytecodesRef == null) ? null :
(byte[])bytecodesRef.get(); bytecodesRef.get();
if (bytecodes == null) { if (bytecodes == null) {
try { try {
bytecodes = JDWP.Method.Bytecodes. bytecodes = JDWP.Method.Bytecodes.
...@@ -262,7 +262,7 @@ public class ConcreteMethodImpl extends MethodImpl { ...@@ -262,7 +262,7 @@ public class ConcreteMethodImpl extends MethodImpl {
* to return the cached bytecodes directly; instead, we * to return the cached bytecodes directly; instead, we
* make a clone at the cost of using more memory. * make a clone at the cost of using more memory.
*/ */
return (byte[])bytecodes.clone(); return bytecodes.clone();
} }
int argSlotCount() throws AbsentInformationException { int argSlotCount() throws AbsentInformationException {
...@@ -279,7 +279,7 @@ public class ConcreteMethodImpl extends MethodImpl { ...@@ -279,7 +279,7 @@ public class ConcreteMethodImpl extends MethodImpl {
String stratumID = stratum.id(); String stratumID = stratum.id();
SoftLocationXRefs info = SoftLocationXRefs info =
(softOtherLocationXRefsRef == null) ? null : (softOtherLocationXRefsRef == null) ? null :
(SoftLocationXRefs)softOtherLocationXRefsRef.get(); softOtherLocationXRefsRef.get();
if (info != null && info.stratumID.equals(stratumID)) { if (info != null && info.stratumID.equals(stratumID)) {
return info; return info;
} }
...@@ -348,7 +348,7 @@ public class ConcreteMethodImpl extends MethodImpl { ...@@ -348,7 +348,7 @@ public class ConcreteMethodImpl extends MethodImpl {
private SoftLocationXRefs getBaseLocations() { private SoftLocationXRefs getBaseLocations() {
SoftLocationXRefs info = (softBaseLocationXRefsRef == null) ? null : SoftLocationXRefs info = (softBaseLocationXRefsRef == null) ? null :
(SoftLocationXRefs)softBaseLocationXRefsRef.get(); softBaseLocationXRefsRef.get();
if (info != null) { if (info != null) {
return info; return info;
} }
......
...@@ -56,10 +56,8 @@ public class EventSetImpl extends ArrayList<Event> implements EventSet { ...@@ -56,10 +56,8 @@ public class EventSetImpl extends ArrayList<Event> implements EventSet {
public String toString() { public String toString() {
String string = "event set, policy:" + suspendPolicy + String string = "event set, policy:" + suspendPolicy +
", count:" + this.size() + " = {"; ", count:" + this.size() + " = {";
Iterator iter = this.iterator();
boolean first = true; boolean first = true;
while (iter.hasNext()) { for (Event event : this) {
Event event = (Event)iter.next();
if (!first) { if (!first) {
string += ", "; string += ", ";
} }
...@@ -787,9 +785,7 @@ public class EventSetImpl extends ArrayList<Event> implements EventSet { ...@@ -787,9 +785,7 @@ public class EventSetImpl extends ArrayList<Event> implements EventSet {
} }
private ThreadReference eventThread() { private ThreadReference eventThread() {
Iterator iter = this.iterator(); for (Event event : this) {
while (iter.hasNext()) {
Event event = (Event)iter.next();
if (event instanceof ThreadedEventImpl) { if (event instanceof ThreadedEventImpl) {
return ((ThreadedEventImpl)event).thread(); return ((ThreadedEventImpl)event).thread();
} }
...@@ -846,7 +842,7 @@ public class EventSetImpl extends ArrayList<Event> implements EventSet { ...@@ -846,7 +842,7 @@ public class EventSetImpl extends ArrayList<Event> implements EventSet {
} }
public Event nextEvent() { public Event nextEvent() {
return (Event)next(); return next();
} }
public void remove() { public void remove() {
......
...@@ -82,7 +82,7 @@ public class JNITypeParser { ...@@ -82,7 +82,7 @@ public class JNITypeParser {
} }
String typeName() { String typeName() {
return (String)typeNameList().get(typeNameList().size()-1); return typeNameList().get(typeNameList().size()-1);
} }
List<String> argumentTypeNames() { List<String> argumentTypeNames() {
...@@ -90,7 +90,7 @@ public class JNITypeParser { ...@@ -90,7 +90,7 @@ public class JNITypeParser {
} }
String signature() { String signature() {
return (String)signatureList().get(signatureList().size()-1); return signatureList().get(signatureList().size()-1);
} }
List<String> argumentSignatures() { List<String> argumentSignatures() {
......
...@@ -158,7 +158,7 @@ public abstract class MethodImpl extends TypeComponentImpl ...@@ -158,7 +158,7 @@ public abstract class MethodImpl extends TypeComponentImpl
Type argumentType(int index) throws ClassNotLoadedException { Type argumentType(int index) throws ClassNotLoadedException {
ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType(); ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType();
String signature = (String)argumentSignatures().get(index); String signature = argumentSignatures().get(index);
return enclosing.findType(signature); return enclosing.findType(signature);
} }
...@@ -263,10 +263,10 @@ public abstract class MethodImpl extends TypeComponentImpl ...@@ -263,10 +263,10 @@ public abstract class MethodImpl extends TypeComponentImpl
return argumentType(index); return argumentType(index);
} }
public String typeName(){ public String typeName(){
return (String)argumentTypeNames().get(index); return argumentTypeNames().get(index);
} }
public String signature() { public String signature() {
return (String)argumentSignatures().get(index); return argumentSignatures().get(index);
} }
public Type findType(String signature) throws ClassNotLoadedException { public Type findType(String signature) throws ClassNotLoadedException {
return MethodImpl.this.findType(signature); return MethodImpl.this.findType(signature);
...@@ -307,7 +307,7 @@ public abstract class MethodImpl extends TypeComponentImpl ...@@ -307,7 +307,7 @@ public abstract class MethodImpl extends TypeComponentImpl
arguments.add(argArray); arguments.add(argArray);
return; return;
} }
Value nthArgValue = (Value)arguments.get(paramCount - 1); Value nthArgValue = arguments.get(paramCount - 1);
if (nthArgValue == null) { if (nthArgValue == null) {
return; return;
} }
...@@ -371,7 +371,7 @@ public abstract class MethodImpl extends TypeComponentImpl ...@@ -371,7 +371,7 @@ public abstract class MethodImpl extends TypeComponentImpl
} }
for (int i = 0; i < argSize; i++) { for (int i = 0; i < argSize; i++) {
Value value = (Value)arguments.get(i); Value value = arguments.get(i);
value = ValueImpl.prepareForAssignment(value, value = ValueImpl.prepareForAssignment(value,
new ArgumentContainer(i)); new ArgumentContainer(i));
arguments.set(i, value); arguments.set(i, value);
...@@ -386,11 +386,11 @@ public abstract class MethodImpl extends TypeComponentImpl ...@@ -386,11 +386,11 @@ public abstract class MethodImpl extends TypeComponentImpl
sb.append(name()); sb.append(name());
sb.append("("); sb.append("(");
boolean first = true; boolean first = true;
for (Iterator it = argumentTypeNames().iterator(); it.hasNext();) { for (String name : argumentTypeNames()) {
if (!first) { if (!first) {
sb.append(", "); sb.append(", ");
} }
sb.append((String)it.next()); sb.append(name);
first = false; first = false;
} }
sb.append(")"); sb.append(")");
......
...@@ -383,7 +383,7 @@ public class ObjectReferenceImpl extends ValueImpl ...@@ -383,7 +383,7 @@ public class ObjectReferenceImpl extends ValueImpl
List<Value> arguments = method.validateAndPrepareArgumentsForInvoke( List<Value> arguments = method.validateAndPrepareArgumentsForInvoke(
origArguments); origArguments);
ValueImpl[] args = (ValueImpl[])arguments.toArray(new ValueImpl[0]); ValueImpl[] args = arguments.toArray(new ValueImpl[0]);
JDWP.ObjectReference.InvokeMethod ret; JDWP.ObjectReference.InvokeMethod ret;
try { try {
PacketStream stream = PacketStream stream =
...@@ -583,7 +583,7 @@ public class ObjectReferenceImpl extends ValueImpl ...@@ -583,7 +583,7 @@ public class ObjectReferenceImpl extends ValueImpl
// Validate assignment // Validate assignment
ReferenceType destType = (ReferenceTypeImpl)destination.type(); ReferenceType destType = (ReferenceTypeImpl)destination.type();
ReferenceTypeImpl myType = (ReferenceTypeImpl)referenceType(); ReferenceTypeImpl myType = (ReferenceTypeImpl)referenceType();
if (!myType.isAssignableTo((ReferenceType)destType)) { if (!myType.isAssignableTo(destType)) {
JNITypeParser parser = new JNITypeParser(destType.signature()); JNITypeParser parser = new JNITypeParser(destType.signature());
String destTypeName = parser.typeName(); String destTypeName = parser.typeName();
throw new InvalidTypeException("Can't assign " + throw new InvalidTypeException("Can't assign " +
......
...@@ -485,7 +485,7 @@ class PacketStream { ...@@ -485,7 +485,7 @@ class PacketStream {
* Read field represented as vm specific byte sequence. * Read field represented as vm specific byte sequence.
*/ */
Field readField() { Field readField() {
ReferenceTypeImpl refType = (ReferenceTypeImpl)readReferenceType(); ReferenceTypeImpl refType = readReferenceType();
long fieldRef = readFieldRef(); long fieldRef = readFieldRef();
return refType.getFieldMirror(fieldRef); return refType.getFieldMirror(fieldRef);
} }
......
...@@ -59,7 +59,7 @@ implements ReferenceType { ...@@ -59,7 +59,7 @@ implements ReferenceType {
private boolean constantPoolInfoGotten = false; private boolean constantPoolInfoGotten = false;
private int constanPoolCount; private int constanPoolCount;
private byte[] constantPoolBytes; private byte[] constantPoolBytes;
private SoftReference constantPoolBytesRef = null; private SoftReference<byte[]> constantPoolBytesRef = null;
/* to mark a SourceFile request that returned a genuine JDWP.Error.ABSENT_INFORMATION */ /* to mark a SourceFile request that returned a genuine JDWP.Error.ABSENT_INFORMATION */
private static final String ABSENT_BASE_SOURCE_NAME = "**ABSENT_BASE_SOURCE_NAME**"; private static final String ABSENT_BASE_SOURCE_NAME = "**ABSENT_BASE_SOURCE_NAME**";
...@@ -352,13 +352,10 @@ implements ReferenceType { ...@@ -352,13 +352,10 @@ implements ReferenceType {
abstract List<? extends ReferenceType> inheritedTypes(); abstract List<? extends ReferenceType> inheritedTypes();
void addVisibleFields(List<Field> visibleList, Map<String, Field> visibleTable, List<String> ambiguousNames) { void addVisibleFields(List<Field> visibleList, Map<String, Field> visibleTable, List<String> ambiguousNames) {
List<Field> list = visibleFields(); for (Field field : visibleFields()) {
Iterator iter = list.iterator();
while (iter.hasNext()) {
Field field = (Field)iter.next();
String name = field.name(); String name = field.name();
if (!ambiguousNames.contains(name)) { if (!ambiguousNames.contains(name)) {
Field duplicate = (Field)visibleTable.get(name); Field duplicate = visibleTable.get(name);
if (duplicate == null) { if (duplicate == null) {
visibleList.add(field); visibleList.add(field);
visibleTable.put(name, field); visibleTable.put(name, field);
...@@ -402,10 +399,8 @@ implements ReferenceType { ...@@ -402,10 +399,8 @@ implements ReferenceType {
* hide. * hide.
*/ */
List<Field> retList = new ArrayList<Field>(fields()); List<Field> retList = new ArrayList<Field>(fields());
iter = retList.iterator(); for (Field field : retList) {
while (iter.hasNext()) { Field hidden = visibleTable.get(field.name());
Field field = (Field)iter.next();
Field hidden = (Field)visibleTable.get(field.name());
if (hidden != null) { if (hidden != null) {
visibleList.remove(hidden); visibleList.remove(hidden);
} }
...@@ -515,12 +510,9 @@ implements ReferenceType { ...@@ -515,12 +510,9 @@ implements ReferenceType {
* methods. * methods.
*/ */
void addToMethodMap(Map<String, Method> methodMap, List<Method> methodList) { void addToMethodMap(Map<String, Method> methodMap, List<Method> methodList) {
Iterator iter = methodList.iterator(); for (Method method : methodList)
while (iter.hasNext()) {
Method method = (Method)iter.next();
methodMap.put(method.name().concat(method.signature()), method); methodMap.put(method.name().concat(method.signature()), method);
} }
}
abstract void addVisibleMethods(Map<String, Method> methodMap); abstract void addVisibleMethods(Map<String, Method> methodMap);
...@@ -549,9 +541,7 @@ implements ReferenceType { ...@@ -549,9 +541,7 @@ implements ReferenceType {
public List<Method> methodsByName(String name) { public List<Method> methodsByName(String name) {
List<Method> methods = visibleMethods(); List<Method> methods = visibleMethods();
ArrayList<Method> retList = new ArrayList<Method>(methods.size()); ArrayList<Method> retList = new ArrayList<Method>(methods.size());
Iterator iter = methods.iterator(); for (Method candidate : methods) {
while (iter.hasNext()) {
Method candidate = (Method)iter.next();
if (candidate.name().equals(name)) { if (candidate.name().equals(name)) {
retList.add(candidate); retList.add(candidate);
} }
...@@ -563,9 +553,7 @@ implements ReferenceType { ...@@ -563,9 +553,7 @@ implements ReferenceType {
public List<Method> methodsByName(String name, String signature) { public List<Method> methodsByName(String name, String signature) {
List<Method> methods = visibleMethods(); List<Method> methods = visibleMethods();
ArrayList<Method> retList = new ArrayList<Method>(methods.size()); ArrayList<Method> retList = new ArrayList<Method>(methods.size());
Iterator iter = methods.iterator(); for (Method candidate : methods) {
while (iter.hasNext()) {
Method candidate = (Method)iter.next();
if (candidate.name().equals(name) && if (candidate.name().equals(name) &&
candidate.signature().equals(signature)) { candidate.signature().equals(signature)) {
retList.add(candidate); retList.add(candidate);
...@@ -706,7 +694,7 @@ implements ReferenceType { ...@@ -706,7 +694,7 @@ implements ReferenceType {
} }
public String sourceName() throws AbsentInformationException { public String sourceName() throws AbsentInformationException {
return (String)(sourceNames(vm.getDefaultStratum()).get(0)); return sourceNames(vm.getDefaultStratum()).get(0);
} }
public List<String> sourceNames(String stratumID) public List<String> sourceNames(String stratumID)
...@@ -796,7 +784,7 @@ implements ReferenceType { ...@@ -796,7 +784,7 @@ implements ReferenceType {
if (!vm.canGetSourceDebugExtension()) { if (!vm.canGetSourceDebugExtension()) {
return NO_SDE_INFO_MARK; return NO_SDE_INFO_MARK;
} }
SDE sde = (sdeRef == null) ? null : (SDE)sdeRef.get(); SDE sde = (sdeRef == null) ? null : sdeRef.get();
if (sde == null) { if (sde == null) {
String extension = null; String extension = null;
try { try {
...@@ -1034,13 +1022,13 @@ implements ReferenceType { ...@@ -1034,13 +1022,13 @@ implements ReferenceType {
throw exc; throw exc;
} }
if (constantPoolBytesRef != null) { if (constantPoolBytesRef != null) {
byte[] cpbytes = (byte[])constantPoolBytesRef.get(); byte[] cpbytes = constantPoolBytesRef.get();
/* /*
* Arrays are always modifiable, so it is a little unsafe * Arrays are always modifiable, so it is a little unsafe
* to return the cached bytecodes directly; instead, we * to return the cached bytecodes directly; instead, we
* make a clone at the cost of using more memory. * make a clone at the cost of using more memory.
*/ */
return (byte[])cpbytes.clone(); return cpbytes.clone();
} else { } else {
return null; return null;
} }
......
...@@ -327,7 +327,7 @@ class SDE { ...@@ -327,7 +327,7 @@ class SDE {
ignoreWhite(); ignoreWhite();
while (((ch = sdeRead()) != '\n') && (ch != '\r')) { while (((ch = sdeRead()) != '\n') && (ch != '\r')) {
sb.append((char)ch); sb.append(ch);
} }
// check for CR LF // check for CR LF
if ((ch == '\r') && (sdePeek() == '\n')) { if ((ch == '\r') && (sdePeek() == '\n')) {
......
...@@ -162,7 +162,7 @@ public class StackFrameImpl extends MirrorImpl ...@@ -162,7 +162,7 @@ public class StackFrameImpl extends MirrorImpl
for (LocalVariable variable : allVariables) { for (LocalVariable variable : allVariables) {
String name = variable.name(); String name = variable.name();
if (variable.isVisible(this)) { if (variable.isVisible(this)) {
LocalVariable existing = (LocalVariable)map.get(name); LocalVariable existing = map.get(name);
if ((existing == null) || if ((existing == null) ||
((LocalVariableImpl)variable).hides(existing)) { ((LocalVariableImpl)variable).hides(existing)) {
map.put(name, variable); map.put(name, variable);
...@@ -330,7 +330,7 @@ public class StackFrameImpl extends MirrorImpl ...@@ -330,7 +330,7 @@ public class StackFrameImpl extends MirrorImpl
slot = 1; slot = 1;
} }
for (int ii = 0; ii < count; ++ii) { for (int ii = 0; ii < count; ++ii) {
char sigChar = (char)argSigs.get(ii).charAt(0); char sigChar = argSigs.get(ii).charAt(0);
slots[ii] = new JDWP.StackFrame.GetValues.SlotInfo(slot++,(byte)sigChar); slots[ii] = new JDWP.StackFrame.GetValues.SlotInfo(slot++,(byte)sigChar);
if (sigChar == 'J' || sigChar == 'D') { if (sigChar == 'J' || sigChar == 'D') {
slot++; slot++;
......
...@@ -148,7 +148,7 @@ public class TargetVM implements Runnable { ...@@ -148,7 +148,7 @@ public class TargetVM implements Runnable {
idString = String.valueOf(p.id); idString = String.valueOf(p.id);
synchronized(waitingQueue) { synchronized(waitingQueue) {
p2 = (Packet)waitingQueue.get(idString); p2 = waitingQueue.get(idString);
if (p2 != null) if (p2 != null)
waitingQueue.remove(idString); waitingQueue.remove(idString);
......
...@@ -86,30 +86,22 @@ public class ThreadGroupReferenceImpl extends ObjectReferenceImpl ...@@ -86,30 +86,22 @@ public class ThreadGroupReferenceImpl extends ObjectReferenceImpl
} }
public void suspend() { public void suspend() {
List threads = threads(); for (ThreadReference thread : threads()) {
Iterator iter = threads.iterator(); thread.suspend();
while (iter.hasNext()) {
((ThreadReference)iter.next()).suspend();
} }
List groups = threadGroups(); for (ThreadGroupReference threadGroup : threadGroups()) {
iter = groups.iterator(); threadGroup.suspend();
while (iter.hasNext()) {
((ThreadGroupReference)iter.next()).suspend();
} }
} }
public void resume() { public void resume() {
List threads = threads(); for (ThreadReference thread : threads()) {
Iterator iter = threads.iterator(); thread.resume();
while (iter.hasNext()) {
((ThreadReference)iter.next()).resume();
} }
List groups = threadGroups(); for (ThreadGroupReference threadGroup : threadGroups()) {
iter = groups.iterator(); threadGroup.resume();
while (iter.hasNext()) {
((ThreadGroupReference)iter.next()).resume();
} }
} }
......
...@@ -1191,8 +1191,7 @@ class VirtualMachineImpl extends MirrorImpl ...@@ -1191,8 +1191,7 @@ class VirtualMachineImpl extends MirrorImpl
} }
requests = new JDWP.VirtualMachine.DisposeObjects.Request[size]; requests = new JDWP.VirtualMachine.DisposeObjects.Request[size];
for (int i = 0; i < requests.length; i++) { for (int i = 0; i < requests.length; i++) {
SoftObjectReference ref = SoftObjectReference ref = batchedDisposeRequests.get(i);
(SoftObjectReference)batchedDisposeRequests.get(i);
if ((traceFlags & TRACE_OBJREFS) != 0) { if ((traceFlags & TRACE_OBJREFS) != 0) {
printTrace("Disposing object " + ref.key().longValue() + printTrace("Disposing object " + ref.key().longValue() +
" (ref count = " + ref.count() + ")"); " (ref count = " + ref.count() + ")");
...@@ -1436,7 +1435,7 @@ class VirtualMachineImpl extends MirrorImpl ...@@ -1436,7 +1435,7 @@ class VirtualMachineImpl extends MirrorImpl
} }
ObjectReferenceImpl object() { ObjectReferenceImpl object() {
return (ObjectReferenceImpl)get(); return get();
} }
} }
} }
...@@ -92,7 +92,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManagerService { ...@@ -92,7 +92,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManagerService {
Connector connector; Connector connector;
try { try {
connector = (Connector)connectors.next(); connector = connectors.next();
} catch (ThreadDeath x) { } catch (ThreadDeath x) {
throw x; throw x;
} catch (Exception x) { } catch (Exception x) {
...@@ -121,7 +121,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManagerService { ...@@ -121,7 +121,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManagerService {
TransportService transportService; TransportService transportService;
try { try {
transportService = (TransportService)transportServices.next(); transportService = transportServices.next();
} catch (ThreadDeath x) { } catch (ThreadDeath x) {
throw x; throw x;
} catch (Exception x) { } catch (Exception x) {
......
...@@ -212,7 +212,8 @@ public class ObjectInputStream ...@@ -212,7 +212,8 @@ public class ObjectInputStream
private static final Object unsharedMarker = new Object(); private static final Object unsharedMarker = new Object();
/** table mapping primitive type names to corresponding class objects */ /** table mapping primitive type names to corresponding class objects */
private static final HashMap primClasses = new HashMap(8, 1.0F); private static final HashMap<String, Class<?>> primClasses
= new HashMap<String, Class<?>>(8, 1.0F);
static { static {
primClasses.put("boolean", boolean.class); primClasses.put("boolean", boolean.class);
primClasses.put("byte", byte.class); primClasses.put("byte", byte.class);
...@@ -620,7 +621,7 @@ public class ObjectInputStream ...@@ -620,7 +621,7 @@ public class ObjectInputStream
try { try {
return Class.forName(name, false, latestUserDefinedLoader()); return Class.forName(name, false, latestUserDefinedLoader());
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
Class cl = (Class) primClasses.get(name); Class<?> cl = primClasses.get(name);
if (cl != null) { if (cl != null) {
return cl; return cl;
} else { } else {
...@@ -1254,11 +1255,11 @@ public class ObjectInputStream ...@@ -1254,11 +1255,11 @@ public class ObjectInputStream
* override security-sensitive non-final methods. Returns true if subclass * override security-sensitive non-final methods. Returns true if subclass
* is "safe", false otherwise. * is "safe", false otherwise.
*/ */
private static boolean auditSubclass(final Class subcl) { private static boolean auditSubclass(final Class<?> subcl) {
Boolean result = AccessController.doPrivileged( Boolean result = AccessController.doPrivileged(
new PrivilegedAction<Boolean>() { new PrivilegedAction<Boolean>() {
public Boolean run() { public Boolean run() {
for (Class cl = subcl; for (Class<?> cl = subcl;
cl != ObjectInputStream.class; cl != ObjectInputStream.class;
cl = cl.getSuperclass()) cl = cl.getSuperclass())
{ {
...@@ -2217,9 +2218,9 @@ public class ObjectInputStream ...@@ -2217,9 +2218,9 @@ public class ObjectInputStream
try { try {
while (list != null) { while (list != null) {
AccessController.doPrivileged( AccessController.doPrivileged(
new PrivilegedExceptionAction() new PrivilegedExceptionAction<Void>()
{ {
public Object run() throws InvalidObjectException { public Void run() throws InvalidObjectException {
list.obj.validateObject(); list.obj.validateObject();
return null; return null;
} }
......
...@@ -77,7 +77,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -77,7 +77,7 @@ public class ObjectStreamClass implements Serializable {
NO_FIELDS; NO_FIELDS;
/** reflection factory for obtaining serialization constructors */ /** reflection factory for obtaining serialization constructors */
private static final ReflectionFactory reflFactory = (ReflectionFactory) private static final ReflectionFactory reflFactory =
AccessController.doPrivileged( AccessController.doPrivileged(
new ReflectionFactory.GetReflectionFactoryAction()); new ReflectionFactory.GetReflectionFactoryAction());
...@@ -216,10 +216,10 @@ public class ObjectStreamClass implements Serializable { ...@@ -216,10 +216,10 @@ public class ObjectStreamClass implements Serializable {
public long getSerialVersionUID() { public long getSerialVersionUID() {
// REMIND: synchronize instead of relying on volatile? // REMIND: synchronize instead of relying on volatile?
if (suid == null) { if (suid == null) {
suid = (Long) AccessController.doPrivileged( suid = AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction<Long>() {
public Object run() { public Long run() {
return Long.valueOf(computeDefaultSUID(cl)); return computeDefaultSUID(cl);
} }
} }
); );
...@@ -392,8 +392,8 @@ public class ObjectStreamClass implements Serializable { ...@@ -392,8 +392,8 @@ public class ObjectStreamClass implements Serializable {
} }
if (interrupted) { if (interrupted) {
AccessController.doPrivileged( AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction<Void>() {
public Object run() { public Void run() {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
return null; return null;
} }
...@@ -427,8 +427,8 @@ public class ObjectStreamClass implements Serializable { ...@@ -427,8 +427,8 @@ public class ObjectStreamClass implements Serializable {
localDesc = this; localDesc = this;
if (serializable) { if (serializable) {
AccessController.doPrivileged(new PrivilegedAction() { AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Object run() { public Void run() {
if (isEnum) { if (isEnum) {
suid = Long.valueOf(0); suid = Long.valueOf(0);
fields = NO_FIELDS; fields = NO_FIELDS;
...@@ -802,7 +802,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -802,7 +802,7 @@ public class ObjectStreamClass implements Serializable {
* non-primitive types, and any other non-null type matches assignable * non-primitive types, and any other non-null type matches assignable
* types only. Returns matching field, or null if no match found. * types only. Returns matching field, or null if no match found.
*/ */
ObjectStreamField getField(String name, Class type) { ObjectStreamField getField(String name, Class<?> type) {
for (int i = 0; i < fields.length; i++) { for (int i = 0; i < fields.length; i++) {
ObjectStreamField f = fields[i]; ObjectStreamField f = fields[i];
if (f.getName().equals(name)) { if (f.getName().equals(name)) {
...@@ -811,7 +811,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -811,7 +811,7 @@ public class ObjectStreamClass implements Serializable {
{ {
return f; return f;
} }
Class ftype = f.getType(); Class<?> ftype = f.getType();
if (ftype != null && type.isAssignableFrom(ftype)) { if (ftype != null && type.isAssignableFrom(ftype)) {
return f; return f;
} }
...@@ -1130,7 +1130,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -1130,7 +1130,7 @@ public class ObjectStreamClass implements Serializable {
private ClassDataSlot[] getClassDataLayout0() private ClassDataSlot[] getClassDataLayout0()
throws InvalidClassException throws InvalidClassException
{ {
ArrayList slots = new ArrayList(); ArrayList<ClassDataSlot> slots = new ArrayList<ClassDataSlot>();
Class start = cl, end = cl; Class start = cl, end = cl;
// locate closest non-serializable superclass // locate closest non-serializable superclass
...@@ -1171,8 +1171,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -1171,8 +1171,7 @@ public class ObjectStreamClass implements Serializable {
// order slots from superclass -> subclass // order slots from superclass -> subclass
Collections.reverse(slots); Collections.reverse(slots);
return (ClassDataSlot[]) return slots.toArray(new ClassDataSlot[slots.size()]);
slots.toArray(new ClassDataSlot[slots.size()]);
} }
/** /**
...@@ -1309,9 +1308,9 @@ public class ObjectStreamClass implements Serializable { ...@@ -1309,9 +1308,9 @@ public class ObjectStreamClass implements Serializable {
* Access checks are disabled on the returned constructor (if any), since * Access checks are disabled on the returned constructor (if any), since
* the defining class may still be non-public. * the defining class may still be non-public.
*/ */
private static Constructor getExternalizableConstructor(Class cl) { private static Constructor getExternalizableConstructor(Class<?> cl) {
try { try {
Constructor cons = cl.getDeclaredConstructor((Class[]) null); Constructor cons = cl.getDeclaredConstructor((Class<?>[]) null);
cons.setAccessible(true); cons.setAccessible(true);
return ((cons.getModifiers() & Modifier.PUBLIC) != 0) ? return ((cons.getModifiers() & Modifier.PUBLIC) != 0) ?
cons : null; cons : null;
...@@ -1325,15 +1324,15 @@ public class ObjectStreamClass implements Serializable { ...@@ -1325,15 +1324,15 @@ public class ObjectStreamClass implements Serializable {
* superclass, or null if none found. Access checks are disabled on the * superclass, or null if none found. Access checks are disabled on the
* returned constructor (if any). * returned constructor (if any).
*/ */
private static Constructor getSerializableConstructor(Class cl) { private static Constructor getSerializableConstructor(Class<?> cl) {
Class initCl = cl; Class<?> initCl = cl;
while (Serializable.class.isAssignableFrom(initCl)) { while (Serializable.class.isAssignableFrom(initCl)) {
if ((initCl = initCl.getSuperclass()) == null) { if ((initCl = initCl.getSuperclass()) == null) {
return null; return null;
} }
} }
try { try {
Constructor cons = initCl.getDeclaredConstructor((Class[]) null); Constructor cons = initCl.getDeclaredConstructor((Class<?>[]) null);
int mods = cons.getModifiers(); int mods = cons.getModifiers();
if ((mods & Modifier.PRIVATE) != 0 || if ((mods & Modifier.PRIVATE) != 0 ||
((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) == 0 && ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) == 0 &&
...@@ -1355,12 +1354,12 @@ public class ObjectStreamClass implements Serializable { ...@@ -1355,12 +1354,12 @@ public class ObjectStreamClass implements Serializable {
* null if no match found. Access checks are disabled on the returned * null if no match found. Access checks are disabled on the returned
* method (if any). * method (if any).
*/ */
private static Method getInheritableMethod(Class cl, String name, private static Method getInheritableMethod(Class<?> cl, String name,
Class[] argTypes, Class[] argTypes,
Class returnType) Class returnType)
{ {
Method meth = null; Method meth = null;
Class defCl = cl; Class<?> defCl = cl;
while (defCl != null) { while (defCl != null) {
try { try {
meth = defCl.getDeclaredMethod(name, argTypes); meth = defCl.getDeclaredMethod(name, argTypes);
...@@ -1391,9 +1390,9 @@ public class ObjectStreamClass implements Serializable { ...@@ -1391,9 +1390,9 @@ public class ObjectStreamClass implements Serializable {
* class, or null if none found. Access checks are disabled on the * class, or null if none found. Access checks are disabled on the
* returned method (if any). * returned method (if any).
*/ */
private static Method getPrivateMethod(Class cl, String name, private static Method getPrivateMethod(Class<?> cl, String name,
Class[] argTypes, Class<?>[] argTypes,
Class returnType) Class<?> returnType)
{ {
try { try {
Method meth = cl.getDeclaredMethod(name, argTypes); Method meth = cl.getDeclaredMethod(name, argTypes);
...@@ -1567,7 +1566,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -1567,7 +1566,7 @@ public class ObjectStreamClass implements Serializable {
ObjectStreamField[] boundFields = ObjectStreamField[] boundFields =
new ObjectStreamField[serialPersistentFields.length]; new ObjectStreamField[serialPersistentFields.length];
Set fieldNames = new HashSet(serialPersistentFields.length); Set<String> fieldNames = new HashSet<String>(serialPersistentFields.length);
for (int i = 0; i < serialPersistentFields.length; i++) { for (int i = 0; i < serialPersistentFields.length; i++) {
ObjectStreamField spf = serialPersistentFields[i]; ObjectStreamField spf = serialPersistentFields[i];
...@@ -1605,7 +1604,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -1605,7 +1604,7 @@ public class ObjectStreamClass implements Serializable {
*/ */
private static ObjectStreamField[] getDefaultSerialFields(Class cl) { private static ObjectStreamField[] getDefaultSerialFields(Class cl) {
Field[] clFields = cl.getDeclaredFields(); Field[] clFields = cl.getDeclaredFields();
ArrayList list = new ArrayList(); ArrayList<ObjectStreamField> list = new ArrayList<ObjectStreamField>();
int mask = Modifier.STATIC | Modifier.TRANSIENT; int mask = Modifier.STATIC | Modifier.TRANSIENT;
for (int i = 0; i < clFields.length; i++) { for (int i = 0; i < clFields.length; i++) {
...@@ -1615,7 +1614,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -1615,7 +1614,7 @@ public class ObjectStreamClass implements Serializable {
} }
int size = list.size(); int size = list.size();
return (size == 0) ? NO_FIELDS : return (size == 0) ? NO_FIELDS :
(ObjectStreamField[]) list.toArray(new ObjectStreamField[size]); list.toArray(new ObjectStreamField[size]);
} }
/** /**
...@@ -1688,11 +1687,9 @@ public class ObjectStreamClass implements Serializable { ...@@ -1688,11 +1687,9 @@ public class ObjectStreamClass implements Serializable {
for (int i = 0; i < fields.length; i++) { for (int i = 0; i < fields.length; i++) {
fieldSigs[i] = new MemberSignature(fields[i]); fieldSigs[i] = new MemberSignature(fields[i]);
} }
Arrays.sort(fieldSigs, new Comparator() { Arrays.sort(fieldSigs, new Comparator<MemberSignature>() {
public int compare(Object o1, Object o2) { public int compare(MemberSignature ms1, MemberSignature ms2) {
String name1 = ((MemberSignature) o1).name; return ms1.name.compareTo(ms2.name);
String name2 = ((MemberSignature) o2).name;
return name1.compareTo(name2);
} }
}); });
for (int i = 0; i < fieldSigs.length; i++) { for (int i = 0; i < fieldSigs.length; i++) {
...@@ -1721,11 +1718,9 @@ public class ObjectStreamClass implements Serializable { ...@@ -1721,11 +1718,9 @@ public class ObjectStreamClass implements Serializable {
for (int i = 0; i < cons.length; i++) { for (int i = 0; i < cons.length; i++) {
consSigs[i] = new MemberSignature(cons[i]); consSigs[i] = new MemberSignature(cons[i]);
} }
Arrays.sort(consSigs, new Comparator() { Arrays.sort(consSigs, new Comparator<MemberSignature>() {
public int compare(Object o1, Object o2) { public int compare(MemberSignature ms1, MemberSignature ms2) {
String sig1 = ((MemberSignature) o1).signature; return ms1.signature.compareTo(ms2.signature);
String sig2 = ((MemberSignature) o2).signature;
return sig1.compareTo(sig2);
} }
}); });
for (int i = 0; i < consSigs.length; i++) { for (int i = 0; i < consSigs.length; i++) {
...@@ -1746,10 +1741,8 @@ public class ObjectStreamClass implements Serializable { ...@@ -1746,10 +1741,8 @@ public class ObjectStreamClass implements Serializable {
for (int i = 0; i < methods.length; i++) { for (int i = 0; i < methods.length; i++) {
methSigs[i] = new MemberSignature(methods[i]); methSigs[i] = new MemberSignature(methods[i]);
} }
Arrays.sort(methSigs, new Comparator() { Arrays.sort(methSigs, new Comparator<MemberSignature>() {
public int compare(Object o1, Object o2) { public int compare(MemberSignature ms1, MemberSignature ms2) {
MemberSignature ms1 = (MemberSignature) o1;
MemberSignature ms2 = (MemberSignature) o2;
int comp = ms1.name.compareTo(ms2.name); int comp = ms1.name.compareTo(ms2.name);
if (comp == 0) { if (comp == 0) {
comp = ms1.signature.compareTo(ms2.signature); comp = ms1.signature.compareTo(ms2.signature);
...@@ -1859,7 +1852,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -1859,7 +1852,7 @@ public class ObjectStreamClass implements Serializable {
keys = new long[nfields]; keys = new long[nfields];
offsets = new int[nfields]; offsets = new int[nfields];
typeCodes = new char[nfields]; typeCodes = new char[nfields];
ArrayList typeList = new ArrayList(); ArrayList<Class<?>> typeList = new ArrayList<Class<?>>();
for (int i = 0; i < nfields; i++) { for (int i = 0; i < nfields; i++) {
ObjectStreamField f = fields[i]; ObjectStreamField f = fields[i];
...@@ -1873,7 +1866,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -1873,7 +1866,7 @@ public class ObjectStreamClass implements Serializable {
} }
} }
types = (Class[]) typeList.toArray(new Class[typeList.size()]); types = typeList.toArray(new Class<?>[typeList.size()]);
numPrimFields = nfields - types.length; numPrimFields = nfields - types.length;
} }
......
...@@ -345,9 +345,9 @@ public final ...@@ -345,9 +345,9 @@ public final
// since we have to do the security check here anyway // since we have to do the security check here anyway
// (the stack depth is wrong for the Constructor's // (the stack depth is wrong for the Constructor's
// security check to work) // security check to work)
java.security.AccessController.doPrivileged java.security.AccessController.doPrivileged(
(new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Void>() {
public Object run() { public Void run() {
c.setAccessible(true); c.setAccessible(true);
return null; return null;
} }
...@@ -1302,10 +1302,10 @@ public final ...@@ -1302,10 +1302,10 @@ public final
// out anything other than public members and (2) public member access // out anything other than public members and (2) public member access
// has already been ok'd by the SecurityManager. // has already been ok'd by the SecurityManager.
Class[] result = (Class[]) java.security.AccessController.doPrivileged return java.security.AccessController.doPrivileged(
(new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Class[]>() {
public Object run() { public Class[] run() {
java.util.List<Class> list = new java.util.ArrayList(); List<Class> list = new ArrayList<Class>();
Class currentClass = Class.this; Class currentClass = Class.this;
while (currentClass != null) { while (currentClass != null) {
Class[] members = currentClass.getDeclaredClasses(); Class[] members = currentClass.getDeclaredClasses();
...@@ -1316,12 +1316,9 @@ public final ...@@ -1316,12 +1316,9 @@ public final
} }
currentClass = currentClass.getSuperclass(); currentClass = currentClass.getSuperclass();
} }
Class[] empty = {}; return list.toArray(new Class[0]);
return list.toArray(empty);
} }
}); });
return result;
} }
...@@ -2215,15 +2212,15 @@ public final ...@@ -2215,15 +2212,15 @@ public final
// Caches for certain reflective results // Caches for certain reflective results
private static boolean useCaches = true; private static boolean useCaches = true;
private volatile transient SoftReference declaredFields; private volatile transient SoftReference<Field[]> declaredFields;
private volatile transient SoftReference publicFields; private volatile transient SoftReference<Field[]> publicFields;
private volatile transient SoftReference declaredMethods; private volatile transient SoftReference<Method[]> declaredMethods;
private volatile transient SoftReference publicMethods; private volatile transient SoftReference<Method[]> publicMethods;
private volatile transient SoftReference declaredConstructors; private volatile transient SoftReference<Constructor<T>[]> declaredConstructors;
private volatile transient SoftReference publicConstructors; private volatile transient SoftReference<Constructor<T>[]> publicConstructors;
// Intermediate results for getFields and getMethods // Intermediate results for getFields and getMethods
private volatile transient SoftReference declaredPublicFields; private volatile transient SoftReference<Field[]> declaredPublicFields;
private volatile transient SoftReference declaredPublicMethods; private volatile transient SoftReference<Method[]> declaredPublicMethods;
// Incremented by the VM on each call to JVM TI RedefineClasses() // Incremented by the VM on each call to JVM TI RedefineClasses()
// that redefines this class or a superclass. // that redefines this class or a superclass.
...@@ -2295,11 +2292,11 @@ public final ...@@ -2295,11 +2292,11 @@ public final
clearCachesOnClassRedefinition(); clearCachesOnClassRedefinition();
if (publicOnly) { if (publicOnly) {
if (declaredPublicFields != null) { if (declaredPublicFields != null) {
res = (Field[]) declaredPublicFields.get(); res = declaredPublicFields.get();
} }
} else { } else {
if (declaredFields != null) { if (declaredFields != null) {
res = (Field[]) declaredFields.get(); res = declaredFields.get();
} }
} }
if (res != null) return res; if (res != null) return res;
...@@ -2308,9 +2305,9 @@ public final ...@@ -2308,9 +2305,9 @@ public final
res = Reflection.filterFields(this, getDeclaredFields0(publicOnly)); res = Reflection.filterFields(this, getDeclaredFields0(publicOnly));
if (useCaches) { if (useCaches) {
if (publicOnly) { if (publicOnly) {
declaredPublicFields = new SoftReference(res); declaredPublicFields = new SoftReference<Field[]>(res);
} else { } else {
declaredFields = new SoftReference(res); declaredFields = new SoftReference<Field[]>(res);
} }
} }
return res; return res;
...@@ -2319,22 +2316,22 @@ public final ...@@ -2319,22 +2316,22 @@ public final
// Returns an array of "root" fields. These Field objects must NOT // Returns an array of "root" fields. These Field objects must NOT
// be propagated to the outside world, but must instead be copied // be propagated to the outside world, but must instead be copied
// via ReflectionFactory.copyField. // via ReflectionFactory.copyField.
private Field[] privateGetPublicFields(Set traversedInterfaces) { private Field[] privateGetPublicFields(Set<Class<?>> traversedInterfaces) {
checkInitted(); checkInitted();
Field[] res = null; Field[] res = null;
if (useCaches) { if (useCaches) {
clearCachesOnClassRedefinition(); clearCachesOnClassRedefinition();
if (publicFields != null) { if (publicFields != null) {
res = (Field[]) publicFields.get(); res = publicFields.get();
} }
if (res != null) return res; if (res != null) return res;
} }
// No cached value available; compute value recursively. // No cached value available; compute value recursively.
// Traverse in correct order for getField(). // Traverse in correct order for getField().
List fields = new ArrayList(); List<Field> fields = new ArrayList<Field>();
if (traversedInterfaces == null) { if (traversedInterfaces == null) {
traversedInterfaces = new HashSet(); traversedInterfaces = new HashSet<Class<?>>();
} }
// Local fields // Local fields
...@@ -2342,9 +2339,7 @@ public final ...@@ -2342,9 +2339,7 @@ public final
addAll(fields, tmp); addAll(fields, tmp);
// Direct superinterfaces, recursively // Direct superinterfaces, recursively
Class[] interfaces = getInterfaces(); for (Class<?> c : getInterfaces()) {
for (int i = 0; i < interfaces.length; i++) {
Class c = interfaces[i];
if (!traversedInterfaces.contains(c)) { if (!traversedInterfaces.contains(c)) {
traversedInterfaces.add(c); traversedInterfaces.add(c);
addAll(fields, c.privateGetPublicFields(traversedInterfaces)); addAll(fields, c.privateGetPublicFields(traversedInterfaces));
...@@ -2353,7 +2348,7 @@ public final ...@@ -2353,7 +2348,7 @@ public final
// Direct superclass, recursively // Direct superclass, recursively
if (!isInterface()) { if (!isInterface()) {
Class c = getSuperclass(); Class<?> c = getSuperclass();
if (c != null) { if (c != null) {
addAll(fields, c.privateGetPublicFields(traversedInterfaces)); addAll(fields, c.privateGetPublicFields(traversedInterfaces));
} }
...@@ -2362,12 +2357,12 @@ public final ...@@ -2362,12 +2357,12 @@ public final
res = new Field[fields.size()]; res = new Field[fields.size()];
fields.toArray(res); fields.toArray(res);
if (useCaches) { if (useCaches) {
publicFields = new SoftReference(res); publicFields = new SoftReference<Field[]>(res);
} }
return res; return res;
} }
private static void addAll(Collection c, Field[] o) { private static void addAll(Collection<Field> c, Field[] o) {
for (int i = 0; i < o.length; i++) { for (int i = 0; i < o.length; i++) {
c.add(o[i]); c.add(o[i]);
} }
...@@ -2383,18 +2378,18 @@ public final ...@@ -2383,18 +2378,18 @@ public final
// Returns an array of "root" constructors. These Constructor // Returns an array of "root" constructors. These Constructor
// objects must NOT be propagated to the outside world, but must // objects must NOT be propagated to the outside world, but must
// instead be copied via ReflectionFactory.copyConstructor. // instead be copied via ReflectionFactory.copyConstructor.
private Constructor[] privateGetDeclaredConstructors(boolean publicOnly) { private Constructor<T>[] privateGetDeclaredConstructors(boolean publicOnly) {
checkInitted(); checkInitted();
Constructor[] res = null; Constructor<T>[] res = null;
if (useCaches) { if (useCaches) {
clearCachesOnClassRedefinition(); clearCachesOnClassRedefinition();
if (publicOnly) { if (publicOnly) {
if (publicConstructors != null) { if (publicConstructors != null) {
res = (Constructor[]) publicConstructors.get(); res = publicConstructors.get();
} }
} else { } else {
if (declaredConstructors != null) { if (declaredConstructors != null) {
res = (Constructor[]) declaredConstructors.get(); res = declaredConstructors.get();
} }
} }
if (res != null) return res; if (res != null) return res;
...@@ -2407,9 +2402,9 @@ public final ...@@ -2407,9 +2402,9 @@ public final
} }
if (useCaches) { if (useCaches) {
if (publicOnly) { if (publicOnly) {
publicConstructors = new SoftReference(res); publicConstructors = new SoftReference<Constructor<T>[]>(res);
} else { } else {
declaredConstructors = new SoftReference(res); declaredConstructors = new SoftReference<Constructor<T>[]>(res);
} }
} }
return res; return res;
...@@ -2431,11 +2426,11 @@ public final ...@@ -2431,11 +2426,11 @@ public final
clearCachesOnClassRedefinition(); clearCachesOnClassRedefinition();
if (publicOnly) { if (publicOnly) {
if (declaredPublicMethods != null) { if (declaredPublicMethods != null) {
res = (Method[]) declaredPublicMethods.get(); res = declaredPublicMethods.get();
} }
} else { } else {
if (declaredMethods != null) { if (declaredMethods != null) {
res = (Method[]) declaredMethods.get(); res = declaredMethods.get();
} }
} }
if (res != null) return res; if (res != null) return res;
...@@ -2444,9 +2439,9 @@ public final ...@@ -2444,9 +2439,9 @@ public final
res = Reflection.filterMethods(this, getDeclaredMethods0(publicOnly)); res = Reflection.filterMethods(this, getDeclaredMethods0(publicOnly));
if (useCaches) { if (useCaches) {
if (publicOnly) { if (publicOnly) {
declaredPublicMethods = new SoftReference(res); declaredPublicMethods = new SoftReference<Method[]>(res);
} else { } else {
declaredMethods = new SoftReference(res); declaredMethods = new SoftReference<Method[]>(res);
} }
} }
return res; return res;
...@@ -2552,7 +2547,7 @@ public final ...@@ -2552,7 +2547,7 @@ public final
if (useCaches) { if (useCaches) {
clearCachesOnClassRedefinition(); clearCachesOnClassRedefinition();
if (publicMethods != null) { if (publicMethods != null) {
res = (Method[]) publicMethods.get(); res = publicMethods.get();
} }
if (res != null) return res; if (res != null) return res;
} }
...@@ -2602,7 +2597,7 @@ public final ...@@ -2602,7 +2597,7 @@ public final
methods.compactAndTrim(); methods.compactAndTrim();
res = methods.getArray(); res = methods.getArray();
if (useCaches) { if (useCaches) {
publicMethods = new SoftReference(res); publicMethods = new SoftReference<Method[]>(res);
} }
return res; return res;
} }
...@@ -2713,11 +2708,11 @@ public final ...@@ -2713,11 +2708,11 @@ public final
private Constructor<T> getConstructor0(Class[] parameterTypes, private Constructor<T> getConstructor0(Class[] parameterTypes,
int which) throws NoSuchMethodException int which) throws NoSuchMethodException
{ {
Constructor[] constructors = privateGetDeclaredConstructors((which == Member.PUBLIC)); Constructor<T>[] constructors = privateGetDeclaredConstructors((which == Member.PUBLIC));
for (int i = 0; i < constructors.length; i++) { for (Constructor<T> constructor : constructors) {
if (arrayContentsEq(parameterTypes, if (arrayContentsEq(parameterTypes,
constructors[i].getParameterTypes())) { constructor.getParameterTypes())) {
return getReflectionFactory().copyConstructor(constructors[i]); return getReflectionFactory().copyConstructor(constructor);
} }
} }
throw new NoSuchMethodException(getName() + ".<init>" + argumentTypesToString(parameterTypes)); throw new NoSuchMethodException(getName() + ".<init>" + argumentTypesToString(parameterTypes));
...@@ -2767,18 +2762,18 @@ public final ...@@ -2767,18 +2762,18 @@ public final
return out; return out;
} }
private static Constructor[] copyConstructors(Constructor[] arg) { private static <U> Constructor<U>[] copyConstructors(Constructor<U>[] arg) {
Constructor[] out = new Constructor[arg.length]; Constructor<U>[] out = arg.clone();
ReflectionFactory fact = getReflectionFactory(); ReflectionFactory fact = getReflectionFactory();
for (int i = 0; i < arg.length; i++) { for (int i = 0; i < out.length; i++) {
out[i] = fact.copyConstructor(arg[i]); out[i] = fact.copyConstructor(out[i]);
} }
return out; return out;
} }
private native Field[] getDeclaredFields0(boolean publicOnly); private native Field[] getDeclaredFields0(boolean publicOnly);
private native Method[] getDeclaredMethods0(boolean publicOnly); private native Method[] getDeclaredMethods0(boolean publicOnly);
private native Constructor[] getDeclaredConstructors0(boolean publicOnly); private native Constructor<T>[] getDeclaredConstructors0(boolean publicOnly);
private native Class[] getDeclaredClasses0(); private native Class[] getDeclaredClasses0();
private static String argumentTypesToString(Class[] argTypes) { private static String argumentTypesToString(Class[] argTypes) {
...@@ -2883,7 +2878,7 @@ public final ...@@ -2883,7 +2878,7 @@ public final
// Fetches the factory for reflective objects // Fetches the factory for reflective objects
private static ReflectionFactory getReflectionFactory() { private static ReflectionFactory getReflectionFactory() {
if (reflectionFactory == null) { if (reflectionFactory == null) {
reflectionFactory = (ReflectionFactory) reflectionFactory =
java.security.AccessController.doPrivileged java.security.AccessController.doPrivileged
(new sun.reflect.ReflectionFactory.GetReflectionFactoryAction()); (new sun.reflect.ReflectionFactory.GetReflectionFactoryAction());
} }
...@@ -2895,8 +2890,8 @@ public final ...@@ -2895,8 +2890,8 @@ public final
private static boolean initted = false; private static boolean initted = false;
private static void checkInitted() { private static void checkInitted() {
if (initted) return; if (initted) return;
AccessController.doPrivileged(new PrivilegedAction() { AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Object run() { public Void run() {
// Tests to ensure the system properties table is fully // Tests to ensure the system properties table is fully
// initialized. This is needed because reflection code is // initialized. This is needed because reflection code is
// called very early in the initialization process (before // called very early in the initialization process (before
...@@ -2941,17 +2936,17 @@ public final ...@@ -2941,17 +2936,17 @@ public final
/** /**
* Returns the elements of this enum class or null if this * Returns the elements of this enum class or null if this
* Class object does not represent an enum type; * Class object does not represent an enum type;
* identical to getEnumConstantsShared except that * identical to getEnumConstants except that the result is
* the result is uncloned, cached, and shared by all callers. * uncloned, cached, and shared by all callers.
*/ */
T[] getEnumConstantsShared() { T[] getEnumConstantsShared() {
if (enumConstants == null) { if (enumConstants == null) {
if (!isEnum()) return null; if (!isEnum()) return null;
try { try {
final Method values = getMethod("values"); final Method values = getMethod("values");
java.security.AccessController.doPrivileged java.security.AccessController.doPrivileged(
(new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Void>() {
public Object run() { public Void run() {
values.setAccessible(true); values.setAccessible(true);
return null; return null;
} }
......
...@@ -39,6 +39,7 @@ import java.security.PrivilegedAction; ...@@ -39,6 +39,7 @@ import java.security.PrivilegedAction;
import java.security.PrivilegedActionException; import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
import java.security.ProtectionDomain; import java.security.ProtectionDomain;
import java.security.cert.Certificate;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.HashMap; import java.util.HashMap;
...@@ -172,17 +173,18 @@ public abstract class ClassLoader { ...@@ -172,17 +173,18 @@ public abstract class ClassLoader {
private ClassLoader parent; private ClassLoader parent;
// Hashtable that maps packages to certs // Hashtable that maps packages to certs
private Hashtable package2certs = new Hashtable(11); private Hashtable<String, Certificate[]> package2certs
= new Hashtable<String, Certificate[]>(11);
// Shared among all packages with unsigned classes // Shared among all packages with unsigned classes
java.security.cert.Certificate[] nocerts; Certificate[] nocerts;
// The classes loaded by this class loader. The only purpose of this table // The classes loaded by this class loader. The only purpose of this table
// is to keep the classes from being GC'ed until the loader is GC'ed. // is to keep the classes from being GC'ed until the loader is GC'ed.
private Vector classes = new Vector(); private Vector<Class<?>> classes = new Vector<Class<?>>();
// The initiating protection domains for all classes loaded by this loader // The initiating protection domains for all classes loaded by this loader
private Set domains = new HashSet(); private Set<ProtectionDomain> domains = new HashSet<ProtectionDomain>();
// Invoked by the VM to record every loaded class with this loader. // Invoked by the VM to record every loaded class with this loader.
void addClass(Class c) { void addClass(Class c) {
...@@ -191,7 +193,7 @@ public abstract class ClassLoader { ...@@ -191,7 +193,7 @@ public abstract class ClassLoader {
// The packages defined in this class loader. Each package name is mapped // The packages defined in this class loader. Each package name is mapped
// to its corresponding Package object. // to its corresponding Package object.
private HashMap packages = new HashMap(); private HashMap<String, Package> packages = new HashMap<String, Package>();
/** /**
* Creates a new class loader using the specified parent class loader for * Creates a new class loader using the specified parent class loader for
...@@ -342,8 +344,8 @@ public abstract class ClassLoader { ...@@ -342,8 +344,8 @@ public abstract class ClassLoader {
final String name = cls.getName(); final String name = cls.getName();
final int i = name.lastIndexOf('.'); final int i = name.lastIndexOf('.');
if (i != -1) { if (i != -1) {
AccessController.doPrivileged(new PrivilegedAction() { AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Object run() { public Void run() {
sm.checkPackageAccess(name.substring(0, i)); sm.checkPackageAccess(name.substring(0, i));
return null; return null;
} }
...@@ -524,19 +526,22 @@ public abstract class ClassLoader { ...@@ -524,19 +526,22 @@ public abstract class ClassLoader {
// Class format error - try to transform the bytecode and // Class format error - try to transform the bytecode and
// define the class again // define the class again
// //
Object[] transformers = ClassFileTransformer.getTransformers(); ClassFileTransformer[] transformers = ClassFileTransformer.getTransformers();
Class c = null; Class c = null;
for (int i = 0; transformers != null && i < transformers.length; i++) { if (transformers != null) {
for (ClassFileTransformer transformer : transformers) {
try { try {
// Transform byte code using transformer // Transform byte code using transformer
byte[] tb = ((ClassFileTransformer) transformers[i]).transform(b, off, len); byte[] tb = transformer.transform(b, off, len);
c = defineClass1(name, tb, 0, tb.length, protectionDomain, source); c = defineClass1(name, tb, 0, tb.length,
protectionDomain, source);
break; break;
} catch (ClassFormatError cfe2) { } catch (ClassFormatError cfe2) {
// If ClassFormatError occurs, try next transformer // If ClassFormatError occurs, try next transformer
} }
} }
}
// Rethrow original ClassFormatError if unable to transform // Rethrow original ClassFormatError if unable to transform
// bytecode to well-formed // bytecode to well-formed
...@@ -550,7 +555,7 @@ public abstract class ClassLoader { ...@@ -550,7 +555,7 @@ public abstract class ClassLoader {
private void postDefineClass(Class c, ProtectionDomain protectionDomain) private void postDefineClass(Class c, ProtectionDomain protectionDomain)
{ {
if (protectionDomain.getCodeSource() != null) { if (protectionDomain.getCodeSource() != null) {
java.security.cert.Certificate certs[] = Certificate certs[] =
protectionDomain.getCodeSource().getCertificates(); protectionDomain.getCodeSource().getCertificates();
if (certs != null) if (certs != null)
setSigners(c, certs); setSigners(c, certs);
...@@ -767,8 +772,7 @@ public abstract class ClassLoader { ...@@ -767,8 +772,7 @@ public abstract class ClassLoader {
private synchronized void checkCerts(String name, CodeSource cs) { private synchronized void checkCerts(String name, CodeSource cs) {
int i = name.lastIndexOf('.'); int i = name.lastIndexOf('.');
String pname = (i == -1) ? "" : name.substring(0, i); String pname = (i == -1) ? "" : name.substring(0, i);
java.security.cert.Certificate[] pcerts = Certificate[] pcerts = package2certs.get(pname);
(java.security.cert.Certificate[]) package2certs.get(pname);
if (pcerts == null) { if (pcerts == null) {
// first class in this package gets to define which // first class in this package gets to define which
// certificates must be the same for all other classes // certificates must be the same for all other classes
...@@ -778,12 +782,12 @@ public abstract class ClassLoader { ...@@ -778,12 +782,12 @@ public abstract class ClassLoader {
} }
if (pcerts == null) { if (pcerts == null) {
if (nocerts == null) if (nocerts == null)
nocerts = new java.security.cert.Certificate[0]; nocerts = new Certificate[0];
pcerts = nocerts; pcerts = nocerts;
} }
package2certs.put(pname, pcerts); package2certs.put(pname, pcerts);
} else { } else {
java.security.cert.Certificate[] certs = null; Certificate[] certs = null;
if (cs != null) { if (cs != null) {
certs = cs.getCertificates(); certs = cs.getCertificates();
} }
...@@ -799,8 +803,8 @@ public abstract class ClassLoader { ...@@ -799,8 +803,8 @@ public abstract class ClassLoader {
* check to make sure the certs for the new class (certs) are the same as * check to make sure the certs for the new class (certs) are the same as
* the certs for the first class inserted in the package (pcerts) * the certs for the first class inserted in the package (pcerts)
*/ */
private boolean compareCerts(java.security.cert.Certificate[] pcerts, private boolean compareCerts(Certificate[] pcerts,
java.security.cert.Certificate[] certs) Certificate[] certs)
{ {
// certs can be null, indicating no certs. // certs can be null, indicating no certs.
if ((certs == null) || (certs.length == 0)) { if ((certs == null) || (certs.length == 0)) {
...@@ -1031,7 +1035,7 @@ public abstract class ClassLoader { ...@@ -1031,7 +1035,7 @@ public abstract class ClassLoader {
} }
tmp[1] = findResources(name); tmp[1] = findResources(name);
return new CompoundEnumeration(tmp); return new CompoundEnumeration<URL>(tmp);
} }
/** /**
...@@ -1068,7 +1072,7 @@ public abstract class ClassLoader { ...@@ -1068,7 +1072,7 @@ public abstract class ClassLoader {
* @since 1.2 * @since 1.2
*/ */
protected Enumeration<URL> findResources(String name) throws IOException { protected Enumeration<URL> findResources(String name) throws IOException {
return new CompoundEnumeration(new Enumeration[0]); return java.util.Collections.emptyEnumeration();
} }
/** /**
...@@ -1134,13 +1138,13 @@ public abstract class ClassLoader { ...@@ -1134,13 +1138,13 @@ public abstract class ClassLoader {
/** /**
* Find resources from the VM's built-in classloader. * Find resources from the VM's built-in classloader.
*/ */
private static Enumeration getBootstrapResources(String name) private static Enumeration<URL> getBootstrapResources(String name)
throws IOException throws IOException
{ {
final Enumeration e = getBootstrapClassPath().getResources(name); final Enumeration<Resource> e = getBootstrapClassPath().getResources(name);
return new Enumeration () { return new Enumeration<URL> () {
public Object nextElement() { public URL nextElement() {
return ((Resource)e.nextElement()).getURL(); return e.nextElement().getURL();
} }
public boolean hasMoreElements() { public boolean hasMoreElements() {
return e.hasMoreElements(); return e.hasMoreElements();
...@@ -1323,9 +1327,8 @@ public abstract class ClassLoader { ...@@ -1323,9 +1327,8 @@ public abstract class ClassLoader {
Throwable oops = null; Throwable oops = null;
scl = l.getClassLoader(); scl = l.getClassLoader();
try { try {
PrivilegedExceptionAction a; scl = AccessController.doPrivileged(
a = new SystemClassLoaderAction(scl); new SystemClassLoaderAction(scl));
scl = (ClassLoader) AccessController.doPrivileged(a);
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {
oops = pae.getCause(); oops = pae.getCause();
if (oops instanceof InvocationTargetException) { if (oops instanceof InvocationTargetException) {
...@@ -1456,7 +1459,7 @@ public abstract class ClassLoader { ...@@ -1456,7 +1459,7 @@ public abstract class ClassLoader {
*/ */
protected Package getPackage(String name) { protected Package getPackage(String name) {
synchronized (packages) { synchronized (packages) {
Package pkg = (Package)packages.get(name); Package pkg = packages.get(name);
if (pkg == null) { if (pkg == null) {
if (parent != null) { if (parent != null) {
pkg = parent.getPackage(name); pkg = parent.getPackage(name);
...@@ -1481,9 +1484,9 @@ public abstract class ClassLoader { ...@@ -1481,9 +1484,9 @@ public abstract class ClassLoader {
* @since 1.2 * @since 1.2
*/ */
protected Package[] getPackages() { protected Package[] getPackages() {
Map map; Map<String, Package> map;
synchronized (packages) { synchronized (packages) {
map = (Map)packages.clone(); map = new HashMap<String, Package>(packages);
} }
Package[] pkgs; Package[] pkgs;
if (parent != null) { if (parent != null) {
...@@ -1499,7 +1502,7 @@ public abstract class ClassLoader { ...@@ -1499,7 +1502,7 @@ public abstract class ClassLoader {
} }
} }
} }
return (Package[])map.values().toArray(new Package[map.size()]); return map.values().toArray(new Package[map.size()]);
} }
...@@ -1585,8 +1588,7 @@ public abstract class ClassLoader { ...@@ -1585,8 +1588,7 @@ public abstract class ClassLoader {
// Invoked in the VM to determine the context class in // Invoked in the VM to determine the context class in
// JNI_Load/JNI_Unload // JNI_Load/JNI_Unload
static Class getFromClass() { static Class getFromClass() {
return ((NativeLibrary) return ClassLoader.nativeLibraryContext.peek().fromClass;
(ClassLoader.nativeLibraryContext.peek())).fromClass;
} }
} }
...@@ -1597,22 +1599,27 @@ public abstract class ClassLoader { ...@@ -1597,22 +1599,27 @@ public abstract class ClassLoader {
// Returns (and initializes) the default domain. // Returns (and initializes) the default domain.
private synchronized ProtectionDomain getDefaultDomain() { private synchronized ProtectionDomain getDefaultDomain() {
if (defaultDomain == null) { if (defaultDomain == null) {
CodeSource cs = CodeSource cs = new CodeSource(null, (Certificate[]) null);
new CodeSource(null, (java.security.cert.Certificate[]) null);
defaultDomain = new ProtectionDomain(cs, null, this, null); defaultDomain = new ProtectionDomain(cs, null, this, null);
} }
return defaultDomain; return defaultDomain;
} }
// All native library names we've loaded. // All native library names we've loaded.
private static Vector loadedLibraryNames = new Vector(); private static Vector<String> loadedLibraryNames
= new Vector<String>();
// Native libraries belonging to system classes. // Native libraries belonging to system classes.
private static Vector systemNativeLibraries = new Vector(); private static Vector<NativeLibrary> systemNativeLibraries
= new Vector<NativeLibrary>();
// Native libraries associated with the class loader. // Native libraries associated with the class loader.
private Vector nativeLibraries = new Vector(); private Vector<NativeLibrary> nativeLibraries
= new Vector<NativeLibrary>();
// native libraries being loaded/unloaded. // native libraries being loaded/unloaded.
private static Stack nativeLibraryContext = new Stack(); private static Stack<NativeLibrary> nativeLibraryContext
= new Stack<NativeLibrary>();
// The paths searched for libraries // The paths searched for libraries
static private String usr_paths[]; static private String usr_paths[];
...@@ -1699,13 +1706,13 @@ public abstract class ClassLoader { ...@@ -1699,13 +1706,13 @@ public abstract class ClassLoader {
} }
private static boolean loadLibrary0(Class fromClass, final File file) { private static boolean loadLibrary0(Class fromClass, final File file) {
Boolean exists = (Boolean) boolean exists = AccessController.doPrivileged(
AccessController.doPrivileged(new PrivilegedAction() { new PrivilegedAction<Object>() {
public Object run() { public Object run() {
return new Boolean(file.exists()); return file.exists() ? Boolean.TRUE : null;
} }})
}); != null;
if (!exists.booleanValue()) { if (!exists) {
return false; return false;
} }
String name; String name;
...@@ -1716,12 +1723,12 @@ public abstract class ClassLoader { ...@@ -1716,12 +1723,12 @@ public abstract class ClassLoader {
} }
ClassLoader loader = ClassLoader loader =
(fromClass == null) ? null : fromClass.getClassLoader(); (fromClass == null) ? null : fromClass.getClassLoader();
Vector libs = Vector<NativeLibrary> libs =
loader != null ? loader.nativeLibraries : systemNativeLibraries; loader != null ? loader.nativeLibraries : systemNativeLibraries;
synchronized (libs) { synchronized (libs) {
int size = libs.size(); int size = libs.size();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
NativeLibrary lib = (NativeLibrary)libs.elementAt(i); NativeLibrary lib = libs.elementAt(i);
if (name.equals(lib.name)) { if (name.equals(lib.name)) {
return true; return true;
} }
...@@ -1748,8 +1755,7 @@ public abstract class ClassLoader { ...@@ -1748,8 +1755,7 @@ public abstract class ClassLoader {
*/ */
int n = nativeLibraryContext.size(); int n = nativeLibraryContext.size();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
NativeLibrary lib = (NativeLibrary) NativeLibrary lib = nativeLibraryContext.elementAt(i);
nativeLibraryContext.elementAt(i);
if (name.equals(lib.name)) { if (name.equals(lib.name)) {
if (loader == lib.fromClass.getClassLoader()) { if (loader == lib.fromClass.getClassLoader()) {
return true; return true;
...@@ -1780,12 +1786,12 @@ public abstract class ClassLoader { ...@@ -1780,12 +1786,12 @@ public abstract class ClassLoader {
// Invoked in the VM class linking code. // Invoked in the VM class linking code.
static long findNative(ClassLoader loader, String name) { static long findNative(ClassLoader loader, String name) {
Vector libs = Vector<NativeLibrary> libs =
loader != null ? loader.nativeLibraries : systemNativeLibraries; loader != null ? loader.nativeLibraries : systemNativeLibraries;
synchronized (libs) { synchronized (libs) {
int size = libs.size(); int size = libs.size();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
NativeLibrary lib = (NativeLibrary)libs.elementAt(i); NativeLibrary lib = libs.elementAt(i);
long entry = lib.find(name); long entry = lib.find(name);
if (entry != 0) if (entry != 0)
return entry; return entry;
...@@ -1805,13 +1811,13 @@ public abstract class ClassLoader { ...@@ -1805,13 +1811,13 @@ public abstract class ClassLoader {
// is null then we are delegating assertion status queries to the VM, i.e., // is null then we are delegating assertion status queries to the VM, i.e.,
// none of this ClassLoader's assertion status modification methods have // none of this ClassLoader's assertion status modification methods have
// been invoked. // been invoked.
private Map packageAssertionStatus = null; private Map<String, Boolean> packageAssertionStatus = null;
// Maps String fullyQualifiedClassName to Boolean assertionStatus If this // Maps String fullyQualifiedClassName to Boolean assertionStatus If this
// field is null then we are delegating assertion status queries to the VM, // field is null then we are delegating assertion status queries to the VM,
// i.e., none of this ClassLoader's assertion status modification methods // i.e., none of this ClassLoader's assertion status modification methods
// have been invoked. // have been invoked.
Map classAssertionStatus = null; Map<String, Boolean> classAssertionStatus = null;
/** /**
* Sets the default assertion status for this class loader. This setting * Sets the default assertion status for this class loader. This setting
...@@ -1878,7 +1884,7 @@ public abstract class ClassLoader { ...@@ -1878,7 +1884,7 @@ public abstract class ClassLoader {
if (packageAssertionStatus == null) if (packageAssertionStatus == null)
initializeJavaAssertionMaps(); initializeJavaAssertionMaps();
packageAssertionStatus.put(packageName, Boolean.valueOf(enabled)); packageAssertionStatus.put(packageName, enabled);
} }
/** /**
...@@ -1909,7 +1915,7 @@ public abstract class ClassLoader { ...@@ -1909,7 +1915,7 @@ public abstract class ClassLoader {
if (classAssertionStatus == null) if (classAssertionStatus == null)
initializeJavaAssertionMaps(); initializeJavaAssertionMaps();
classAssertionStatus.put(className, Boolean.valueOf(enabled)); classAssertionStatus.put(className, enabled);
} }
/** /**
...@@ -1927,8 +1933,8 @@ public abstract class ClassLoader { ...@@ -1927,8 +1933,8 @@ public abstract class ClassLoader {
* Whether or not "Java assertion maps" are initialized, set * Whether or not "Java assertion maps" are initialized, set
* them to empty maps, effectively ignoring any present settings. * them to empty maps, effectively ignoring any present settings.
*/ */
classAssertionStatus = new HashMap(); classAssertionStatus = new HashMap<String, Boolean>();
packageAssertionStatus = new HashMap(); packageAssertionStatus = new HashMap<String, Boolean>();
defaultAssertionStatus = false; defaultAssertionStatus = false;
} }
...@@ -1962,20 +1968,20 @@ public abstract class ClassLoader { ...@@ -1962,20 +1968,20 @@ public abstract class ClassLoader {
// assert packageAssertionStatus != null; // assert packageAssertionStatus != null;
// Check for a class entry // Check for a class entry
result = (Boolean)classAssertionStatus.get(className); result = classAssertionStatus.get(className);
if (result != null) if (result != null)
return result.booleanValue(); return result.booleanValue();
// Check for most specific package entry // Check for most specific package entry
int dotIndex = className.lastIndexOf("."); int dotIndex = className.lastIndexOf(".");
if (dotIndex < 0) { // default package if (dotIndex < 0) { // default package
result = (Boolean)packageAssertionStatus.get(null); result = packageAssertionStatus.get(null);
if (result != null) if (result != null)
return result.booleanValue(); return result.booleanValue();
} }
while(dotIndex > 0) { while(dotIndex > 0) {
className = className.substring(0, dotIndex); className = className.substring(0, dotIndex);
result = (Boolean)packageAssertionStatus.get(className); result = packageAssertionStatus.get(className);
if (result != null) if (result != null)
return result.booleanValue(); return result.booleanValue();
dotIndex = className.lastIndexOf(".", dotIndex-1); dotIndex = className.lastIndexOf(".", dotIndex-1);
...@@ -1989,17 +1995,17 @@ public abstract class ClassLoader { ...@@ -1989,17 +1995,17 @@ public abstract class ClassLoader {
private void initializeJavaAssertionMaps() { private void initializeJavaAssertionMaps() {
// assert Thread.holdsLock(this); // assert Thread.holdsLock(this);
classAssertionStatus = new HashMap(); classAssertionStatus = new HashMap<String, Boolean>();
packageAssertionStatus = new HashMap(); packageAssertionStatus = new HashMap<String, Boolean>();
AssertionStatusDirectives directives = retrieveDirectives(); AssertionStatusDirectives directives = retrieveDirectives();
for(int i = 0; i < directives.classes.length; i++) for(int i = 0; i < directives.classes.length; i++)
classAssertionStatus.put(directives.classes[i], classAssertionStatus.put(directives.classes[i],
Boolean.valueOf(directives.classEnabled[i])); directives.classEnabled[i]);
for(int i = 0; i < directives.packages.length; i++) for(int i = 0; i < directives.packages.length; i++)
packageAssertionStatus.put(directives.packages[i], packageAssertionStatus.put(directives.packages[i],
Boolean.valueOf(directives.packageEnabled[i])); directives.packageEnabled[i]);
defaultAssertionStatus = directives.deflt; defaultAssertionStatus = directives.deflt;
} }
...@@ -2009,28 +2015,24 @@ public abstract class ClassLoader { ...@@ -2009,28 +2015,24 @@ public abstract class ClassLoader {
} }
class SystemClassLoaderAction implements PrivilegedExceptionAction { class SystemClassLoaderAction
implements PrivilegedExceptionAction<ClassLoader> {
private ClassLoader parent; private ClassLoader parent;
SystemClassLoaderAction(ClassLoader parent) { SystemClassLoaderAction(ClassLoader parent) {
this.parent = parent; this.parent = parent;
} }
public Object run() throws Exception { public ClassLoader run() throws Exception {
ClassLoader sys;
Constructor ctor;
Class c;
Class cp[] = { ClassLoader.class };
Object params[] = { parent };
String cls = System.getProperty("java.system.class.loader"); String cls = System.getProperty("java.system.class.loader");
if (cls == null) { if (cls == null) {
return parent; return parent;
} }
c = Class.forName(cls, true, parent); Constructor ctor = Class.forName(cls, true, parent)
ctor = c.getDeclaredConstructor(cp); .getDeclaredConstructor(new Class[] { ClassLoader.class });
sys = (ClassLoader) ctor.newInstance(params); ClassLoader sys = (ClassLoader) ctor.newInstance(
new Object[] { parent });
Thread.currentThread().setContextClassLoader(sys); Thread.currentThread().setContextClassLoader(sys);
return sys; return sys;
} }
......
...@@ -53,9 +53,9 @@ public final class Compiler { ...@@ -53,9 +53,9 @@ public final class Compiler {
static { static {
registerNatives(); registerNatives();
java.security.AccessController.doPrivileged java.security.AccessController.doPrivileged(
(new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Void>() {
public Object run() { public Void run() {
boolean loaded = false; boolean loaded = false;
String jit = System.getProperty("java.compiler"); String jit = System.getProperty("java.compiler");
if ((jit != null) && (!jit.equals("NONE")) && if ((jit != null) && (!jit.equals("NONE")) &&
......
...@@ -650,7 +650,7 @@ public final class Long extends Number implements Comparable<Long> { ...@@ -650,7 +650,7 @@ public final class Long extends Number implements Comparable<Long> {
try { try {
result = Long.valueOf(nm.substring(index), radix); result = Long.valueOf(nm.substring(index), radix);
result = negative ? new Long((long)-result.longValue()) : result; result = negative ? new Long(-result.longValue()) : result;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
// If number is Long.MIN_VALUE, we'll end up here. The next line // If number is Long.MIN_VALUE, we'll end up here. The next line
// handles this case, and causes any genuine format error to be // handles this case, and causes any genuine format error to be
......
...@@ -507,7 +507,7 @@ public class Package implements java.lang.reflect.AnnotatedElement { ...@@ -507,7 +507,7 @@ public class Package implements java.lang.reflect.AnnotatedElement {
*/ */
static Package getSystemPackage(String name) { static Package getSystemPackage(String name) {
synchronized (pkgs) { synchronized (pkgs) {
Package pkg = (Package)pkgs.get(name); Package pkg = pkgs.get(name);
if (pkg == null) { if (pkg == null) {
name = name.replace('.', '/').concat("/"); name = name.replace('.', '/').concat("/");
String fn = getSystemPackage0(name); String fn = getSystemPackage0(name);
...@@ -529,18 +529,18 @@ public class Package implements java.lang.reflect.AnnotatedElement { ...@@ -529,18 +529,18 @@ public class Package implements java.lang.reflect.AnnotatedElement {
for (int i = 0; i < names.length; i++) { for (int i = 0; i < names.length; i++) {
defineSystemPackage(names[i], getSystemPackage0(names[i])); defineSystemPackage(names[i], getSystemPackage0(names[i]));
} }
return (Package[])pkgs.values().toArray(new Package[pkgs.size()]); return pkgs.values().toArray(new Package[pkgs.size()]);
} }
} }
private static Package defineSystemPackage(final String iname, private static Package defineSystemPackage(final String iname,
final String fn) final String fn)
{ {
return (Package) AccessController.doPrivileged(new PrivilegedAction() { return AccessController.doPrivileged(new PrivilegedAction<Package>() {
public Object run() { public Package run() {
String name = iname; String name = iname;
// Get the cached code source url for the file name // Get the cached code source url for the file name
URL url = (URL)urls.get(fn); URL url = urls.get(fn);
if (url == null) { if (url == null) {
// URL not found, so create one // URL not found, so create one
File file = new File(fn); File file = new File(fn);
...@@ -559,7 +559,7 @@ public class Package implements java.lang.reflect.AnnotatedElement { ...@@ -559,7 +559,7 @@ public class Package implements java.lang.reflect.AnnotatedElement {
// Convert to "."-separated package name // Convert to "."-separated package name
name = name.substring(0, name.length() - 1).replace('/', '.'); name = name.substring(0, name.length() - 1).replace('/', '.');
Package pkg; Package pkg;
Manifest man = (Manifest)mans.get(fn); Manifest man = mans.get(fn);
if (man != null) { if (man != null) {
pkg = new Package(name, man, url, null); pkg = new Package(name, man, url, null);
} else { } else {
...@@ -588,13 +588,16 @@ public class Package implements java.lang.reflect.AnnotatedElement { ...@@ -588,13 +588,16 @@ public class Package implements java.lang.reflect.AnnotatedElement {
} }
// The map of loaded system packages // The map of loaded system packages
private static Map pkgs = new HashMap(31); private static Map<String, Package> pkgs
= new HashMap<String, Package>(31);
// Maps each directory or zip file name to its corresponding url // Maps each directory or zip file name to its corresponding url
private static Map urls = new HashMap(10); private static Map<String, URL> urls
= new HashMap<String, URL>(10);
// Maps each code source url for a jar file to its manifest // Maps each code source url for a jar file to its manifest
private static Map mans = new HashMap(10); private static Map<String, Manifest> mans
= new HashMap<String, Manifest>(10);
private static native String getSystemPackage0(String name); private static native String getSystemPackage0(String name);
private static native String[] getSystemPackages0(); private static native String[] getSystemPackages0();
......
...@@ -121,8 +121,9 @@ final class Finalizer extends FinalReference { /* Package-private; must be in ...@@ -121,8 +121,9 @@ final class Finalizer extends FinalReference { /* Package-private; must be in
invokers of these methods from a stalled or deadlocked finalizer thread. invokers of these methods from a stalled or deadlocked finalizer thread.
*/ */
private static void forkSecondaryFinalizer(final Runnable proc) { private static void forkSecondaryFinalizer(final Runnable proc) {
PrivilegedAction pa = new PrivilegedAction() { AccessController.doPrivileged(
public Object run() { new PrivilegedAction<Void>() {
public Void run() {
ThreadGroup tg = Thread.currentThread().getThreadGroup(); ThreadGroup tg = Thread.currentThread().getThreadGroup();
for (ThreadGroup tgn = tg; for (ThreadGroup tgn = tg;
tgn != null; tgn != null;
...@@ -135,8 +136,7 @@ final class Finalizer extends FinalReference { /* Package-private; must be in ...@@ -135,8 +136,7 @@ final class Finalizer extends FinalReference { /* Package-private; must be in
/* Ignore */ /* Ignore */
} }
return null; return null;
}}; }});
AccessController.doPrivileged(pa);
} }
/* Called by Runtime.runFinalization() */ /* Called by Runtime.runFinalization() */
......
...@@ -165,9 +165,9 @@ public class AccessibleObject implements AnnotatedElement { ...@@ -165,9 +165,9 @@ public class AccessibleObject implements AnnotatedElement {
// Reflection factory used by subclasses for creating field, // Reflection factory used by subclasses for creating field,
// method, and constructor accessors. Note that this is called // method, and constructor accessors. Note that this is called
// very early in the bootstrapping process. // very early in the bootstrapping process.
static final ReflectionFactory reflectionFactory = (ReflectionFactory) static final ReflectionFactory reflectionFactory =
AccessController.doPrivileged AccessController.doPrivileged(
(new sun.reflect.ReflectionFactory.GetReflectionFactoryAction()); new sun.reflect.ReflectionFactory.GetReflectionFactoryAction());
/** /**
* @throws NullPointerException {@inheritDoc} * @throws NullPointerException {@inheritDoc}
......
...@@ -58,9 +58,8 @@ class Modifier { ...@@ -58,9 +58,8 @@ class Modifier {
*/ */
static { static {
sun.reflect.ReflectionFactory factory = sun.reflect.ReflectionFactory factory =
(sun.reflect.ReflectionFactory) AccessController.doPrivileged( AccessController.doPrivileged(
new ReflectionFactory.GetReflectionFactoryAction() new ReflectionFactory.GetReflectionFactoryAction());
);
factory.setLangReflectAccess(new java.lang.reflect.ReflectAccess()); factory.setLangReflectAccess(new java.lang.reflect.ReflectAccess());
} }
......
...@@ -33,6 +33,7 @@ import java.util.HashMap; ...@@ -33,6 +33,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.List;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import sun.misc.ProxyGenerator; import sun.misc.ProxyGenerator;
...@@ -230,7 +231,8 @@ public class Proxy implements java.io.Serializable { ...@@ -230,7 +231,8 @@ public class Proxy implements java.io.Serializable {
{ InvocationHandler.class }; { InvocationHandler.class };
/** maps a class loader to the proxy class cache for that loader */ /** maps a class loader to the proxy class cache for that loader */
private static Map loaderToCache = new WeakHashMap(); private static Map<ClassLoader, Map<List<String>, Object>> loaderToCache
= new WeakHashMap<ClassLoader, Map<List<String>, Object>>();
/** marks that a particular proxy class is currently being generated */ /** marks that a particular proxy class is currently being generated */
private static Object pendingGenerationMarker = new Object(); private static Object pendingGenerationMarker = new Object();
...@@ -240,8 +242,8 @@ public class Proxy implements java.io.Serializable { ...@@ -240,8 +242,8 @@ public class Proxy implements java.io.Serializable {
private static Object nextUniqueNumberLock = new Object(); private static Object nextUniqueNumberLock = new Object();
/** set of all generated proxy classes, for isProxyClass implementation */ /** set of all generated proxy classes, for isProxyClass implementation */
private static Map proxyClasses = private static Map<Class<?>, Void> proxyClasses =
Collections.synchronizedMap(new WeakHashMap()); Collections.synchronizedMap(new WeakHashMap<Class<?>, Void>());
/** /**
* the invocation handler for this proxy instance. * the invocation handler for this proxy instance.
...@@ -353,7 +355,8 @@ public class Proxy implements java.io.Serializable { ...@@ -353,7 +355,8 @@ public class Proxy implements java.io.Serializable {
/* collect interface names to use as key for proxy class cache */ /* collect interface names to use as key for proxy class cache */
String[] interfaceNames = new String[interfaces.length]; String[] interfaceNames = new String[interfaces.length];
Set interfaceSet = new HashSet(); // for detecting duplicates // for detecting duplicates
Set<Class<?>> interfaceSet = new HashSet<Class<?>>();
for (int i = 0; i < interfaces.length; i++) { for (int i = 0; i < interfaces.length; i++) {
/* /*
...@@ -401,16 +404,16 @@ public class Proxy implements java.io.Serializable { ...@@ -401,16 +404,16 @@ public class Proxy implements java.io.Serializable {
* representation of a class makes for an implicit weak * representation of a class makes for an implicit weak
* reference to the class. * reference to the class.
*/ */
Object key = Arrays.asList(interfaceNames); List<String> key = Arrays.asList(interfaceNames);
/* /*
* Find or create the proxy class cache for the class loader. * Find or create the proxy class cache for the class loader.
*/ */
Map cache; Map<List<String>, Object> cache;
synchronized (loaderToCache) { synchronized (loaderToCache) {
cache = (Map) loaderToCache.get(loader); cache = loaderToCache.get(loader);
if (cache == null) { if (cache == null) {
cache = new HashMap(); cache = new HashMap<List<String>, Object>();
loaderToCache.put(loader, cache); loaderToCache.put(loader, cache);
} }
/* /*
...@@ -442,7 +445,7 @@ public class Proxy implements java.io.Serializable { ...@@ -442,7 +445,7 @@ public class Proxy implements java.io.Serializable {
do { do {
Object value = cache.get(key); Object value = cache.get(key);
if (value instanceof Reference) { if (value instanceof Reference) {
proxyClass = (Class) ((Reference) value).get(); proxyClass = (Class<?>) ((Reference) value).get();
} }
if (proxyClass != null) { if (proxyClass != null) {
// proxy class already generated: return it // proxy class already generated: return it
...@@ -544,7 +547,7 @@ public class Proxy implements java.io.Serializable { ...@@ -544,7 +547,7 @@ public class Proxy implements java.io.Serializable {
*/ */
synchronized (cache) { synchronized (cache) {
if (proxyClass != null) { if (proxyClass != null) {
cache.put(key, new WeakReference(proxyClass)); cache.put(key, new WeakReference<Class<?>>(proxyClass));
} else { } else {
cache.remove(key); cache.remove(key);
} }
...@@ -595,14 +598,14 @@ public class Proxy implements java.io.Serializable { ...@@ -595,14 +598,14 @@ public class Proxy implements java.io.Serializable {
/* /*
* Look up or generate the designated proxy class. * Look up or generate the designated proxy class.
*/ */
Class cl = getProxyClass(loader, interfaces); Class<?> cl = getProxyClass(loader, interfaces);
/* /*
* Invoke its constructor with the designated invocation handler. * Invoke its constructor with the designated invocation handler.
*/ */
try { try {
Constructor cons = cl.getConstructor(constructorParams); Constructor cons = cl.getConstructor(constructorParams);
return (Object) cons.newInstance(new Object[] { h }); return cons.newInstance(new Object[] { h });
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
throw new InternalError(e.toString()); throw new InternalError(e.toString());
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
......
...@@ -287,8 +287,9 @@ class DatagramSocket implements java.io.Closeable { ...@@ -287,8 +287,9 @@ class DatagramSocket implements java.io.Closeable {
// DatagramSocketImpl.peekdata() is a protected method, therefore we need to use // DatagramSocketImpl.peekdata() is a protected method, therefore we need to use
// getDeclaredMethod, therefore we need permission to access the member // getDeclaredMethod, therefore we need permission to access the member
try { try {
AccessController.doPrivileged(new PrivilegedExceptionAction() { AccessController.doPrivileged(
public Object run() throws NoSuchMethodException { new PrivilegedExceptionAction<Void>() {
public Void run() throws NoSuchMethodException {
Class[] cl = new Class[1]; Class[] cl = new Class[1];
cl[0] = DatagramPacket.class; cl[0] = DatagramPacket.class;
impl.getClass().getDeclaredMethod("peekData", cl); impl.getClass().getDeclaredMethod("peekData", cl);
......
...@@ -247,8 +247,9 @@ class ServerSocket implements java.io.Closeable { ...@@ -247,8 +247,9 @@ class ServerSocket implements java.io.Closeable {
// SocketImpl.connect() is a protected method, therefore we need to use // SocketImpl.connect() is a protected method, therefore we need to use
// getDeclaredMethod, therefore we need permission to access the member // getDeclaredMethod, therefore we need permission to access the member
try { try {
AccessController.doPrivileged(new PrivilegedExceptionAction() { AccessController.doPrivileged(
public Object run() throws NoSuchMethodException { new PrivilegedExceptionAction<Void>() {
public Void run() throws NoSuchMethodException {
Class[] cl = new Class[2]; Class[] cl = new Class[2];
cl[0] = SocketAddress.class; cl[0] = SocketAddress.class;
cl[1] = Integer.TYPE; cl[1] = Integer.TYPE;
......
...@@ -847,9 +847,9 @@ class Socket implements java.io.Closeable { ...@@ -847,9 +847,9 @@ class Socket implements java.io.Closeable {
final Socket s = this; final Socket s = this;
InputStream is = null; InputStream is = null;
try { try {
is = (InputStream) is = AccessController.doPrivileged(
AccessController.doPrivileged(new PrivilegedExceptionAction() { new PrivilegedExceptionAction<InputStream>() {
public Object run() throws IOException { public InputStream run() throws IOException {
return impl.getInputStream(); return impl.getInputStream();
} }
}); });
...@@ -887,9 +887,9 @@ class Socket implements java.io.Closeable { ...@@ -887,9 +887,9 @@ class Socket implements java.io.Closeable {
final Socket s = this; final Socket s = this;
OutputStream os = null; OutputStream os = null;
try { try {
os = (OutputStream) os = AccessController.doPrivileged(
AccessController.doPrivileged(new PrivilegedExceptionAction() { new PrivilegedExceptionAction<OutputStream>() {
public Object run() throws IOException { public OutputStream run() throws IOException {
return impl.getOutputStream(); return impl.getOutputStream();
} }
}); });
......
...@@ -78,8 +78,8 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { ...@@ -78,8 +78,8 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
{ {
try { try {
AccessController.doPrivileged( AccessController.doPrivileged(
new java.security.PrivilegedExceptionAction() { new java.security.PrivilegedExceptionAction<Void>() {
public Object run() throws IOException { public Void run() throws IOException {
superConnectServer(host, port, timeout); superConnectServer(host, port, timeout);
cmdIn = getInputStream(); cmdIn = getInputStream();
cmdOut = getOutputStream(); cmdOut = getOutputStream();
...@@ -129,10 +129,10 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { ...@@ -129,10 +129,10 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
String userName; String userName;
String password = null; String password = null;
final InetAddress addr = InetAddress.getByName(server); final InetAddress addr = InetAddress.getByName(server);
PasswordAuthentication pw = (PasswordAuthentication) PasswordAuthentication pw =
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<PasswordAuthentication>() {
public Object run() { public PasswordAuthentication run() {
return Authenticator.requestPasswordAuthentication( return Authenticator.requestPasswordAuthentication(
server, addr, port, "SOCKS5", "SOCKS authentication", null); server, addr, port, "SOCKS5", "SOCKS authentication", null);
} }
...@@ -339,10 +339,9 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { ...@@ -339,10 +339,9 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
// This is the general case // This is the general case
// server is not null only when the socket was created with a // server is not null only when the socket was created with a
// specified proxy in which case it does bypass the ProxySelector // specified proxy in which case it does bypass the ProxySelector
ProxySelector sel = (ProxySelector) ProxySelector sel = java.security.AccessController.doPrivileged(
java.security.AccessController.doPrivileged( new java.security.PrivilegedAction<ProxySelector>() {
new java.security.PrivilegedAction() { public ProxySelector run() {
public Object run() {
return ProxySelector.getDefault(); return ProxySelector.getDefault();
} }
}); });
...@@ -652,10 +651,9 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { ...@@ -652,10 +651,9 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
// This is the general case // This is the general case
// server is not null only when the socket was created with a // server is not null only when the socket was created with a
// specified proxy in which case it does bypass the ProxySelector // specified proxy in which case it does bypass the ProxySelector
ProxySelector sel = (ProxySelector) ProxySelector sel = java.security.AccessController.doPrivileged(
java.security.AccessController.doPrivileged( new java.security.PrivilegedAction<ProxySelector>() {
new java.security.PrivilegedAction() { public ProxySelector run() {
public Object run() {
return ProxySelector.getDefault(); return ProxySelector.getDefault();
} }
}); });
...@@ -701,8 +699,9 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { ...@@ -701,8 +699,9 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
// Connects to the SOCKS server // Connects to the SOCKS server
try { try {
AccessController.doPrivileged(new PrivilegedExceptionAction() { AccessController.doPrivileged(
public Object run() throws Exception { new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
cmdsock = new Socket(new PlainSocketImpl()); cmdsock = new Socket(new PlainSocketImpl());
cmdsock.connect(new InetSocketAddress(server, port)); cmdsock.connect(new InetSocketAddress(server, port));
cmdIn = cmdsock.getInputStream(); cmdIn = cmdsock.getInputStream();
...@@ -731,8 +730,9 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { ...@@ -731,8 +730,9 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
} }
} else { } else {
try { try {
AccessController.doPrivileged(new PrivilegedExceptionAction() { AccessController.doPrivileged(
public Object run() throws Exception { new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
cmdsock = new Socket(new PlainSocketImpl()); cmdsock = new Socket(new PlainSocketImpl());
cmdsock.connect(new InetSocketAddress(server, port)); cmdsock.connect(new InetSocketAddress(server, port));
cmdIn = cmdsock.getInputStream(); cmdIn = cmdsock.getInputStream();
......
...@@ -205,9 +205,9 @@ public class URLClassLoader extends SecureClassLoader { ...@@ -205,9 +205,9 @@ public class URLClassLoader extends SecureClassLoader {
throws ClassNotFoundException throws ClassNotFoundException
{ {
try { try {
return (Class) return AccessController.doPrivileged(
AccessController.doPrivileged(new PrivilegedExceptionAction() { new PrivilegedExceptionAction<Class>() {
public Object run() throws ClassNotFoundException { public Class run() throws ClassNotFoundException {
String path = name.replace('.', '/').concat(".class"); String path = name.replace('.', '/').concat(".class");
Resource res = ucp.getResource(path, false); Resource res = ucp.getResource(path, false);
if (res != null) { if (res != null) {
...@@ -376,9 +376,9 @@ public class URLClassLoader extends SecureClassLoader { ...@@ -376,9 +376,9 @@ public class URLClassLoader extends SecureClassLoader {
/* /*
* The same restriction to finding classes applies to resources * The same restriction to finding classes applies to resources
*/ */
URL url = URL url = AccessController.doPrivileged(
(URL) AccessController.doPrivileged(new PrivilegedAction() { new PrivilegedAction<URL>() {
public Object run() { public URL run() {
return ucp.findResource(name, true); return ucp.findResource(name, true);
} }
}, acc); }, acc);
...@@ -397,7 +397,7 @@ public class URLClassLoader extends SecureClassLoader { ...@@ -397,7 +397,7 @@ public class URLClassLoader extends SecureClassLoader {
public Enumeration<URL> findResources(final String name) public Enumeration<URL> findResources(final String name)
throws IOException throws IOException
{ {
final Enumeration e = ucp.findResources(name, true); final Enumeration<URL> e = ucp.findResources(name, true);
return new Enumeration<URL>() { return new Enumeration<URL>() {
private URL url = null; private URL url = null;
...@@ -407,9 +407,9 @@ public class URLClassLoader extends SecureClassLoader { ...@@ -407,9 +407,9 @@ public class URLClassLoader extends SecureClassLoader {
return true; return true;
} }
do { do {
URL u = (URL) URL u = AccessController.doPrivileged(
AccessController.doPrivileged(new PrivilegedAction() { new PrivilegedAction<URL>() {
public Object run() { public URL run() {
if (!e.hasMoreElements()) if (!e.hasMoreElements())
return null; return null;
return e.nextElement(); return e.nextElement();
...@@ -515,8 +515,8 @@ public class URLClassLoader extends SecureClassLoader { ...@@ -515,8 +515,8 @@ public class URLClassLoader extends SecureClassLoader {
final SecurityManager sm = System.getSecurityManager(); final SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
final Permission fp = p; final Permission fp = p;
AccessController.doPrivileged(new PrivilegedAction() { AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Object run() throws SecurityException { public Void run() throws SecurityException {
sm.checkPermission(fp); sm.checkPermission(fp);
return null; return null;
} }
...@@ -544,9 +544,9 @@ public class URLClassLoader extends SecureClassLoader { ...@@ -544,9 +544,9 @@ public class URLClassLoader extends SecureClassLoader {
// Save the caller's context // Save the caller's context
AccessControlContext acc = AccessController.getContext(); AccessControlContext acc = AccessController.getContext();
// Need a privileged block to create the class loader // Need a privileged block to create the class loader
URLClassLoader ucl = URLClassLoader ucl = AccessController.doPrivileged(
(URLClassLoader) AccessController.doPrivileged(new PrivilegedAction() { new PrivilegedAction<URLClassLoader>() {
public Object run() { public URLClassLoader run() {
return new FactoryURLClassLoader(urls, parent); return new FactoryURLClassLoader(urls, parent);
} }
}); });
...@@ -571,9 +571,9 @@ public class URLClassLoader extends SecureClassLoader { ...@@ -571,9 +571,9 @@ public class URLClassLoader extends SecureClassLoader {
// Save the caller's context // Save the caller's context
AccessControlContext acc = AccessController.getContext(); AccessControlContext acc = AccessController.getContext();
// Need a privileged block to create the class loader // Need a privileged block to create the class loader
URLClassLoader ucl = (URLClassLoader) URLClassLoader ucl = AccessController.doPrivileged(
AccessController.doPrivileged(new PrivilegedAction() { new PrivilegedAction<URLClassLoader>() {
public Object run() { public URLClassLoader run() {
return new FactoryURLClassLoader(urls); return new FactoryURLClassLoader(urls);
} }
}); });
......
...@@ -167,9 +167,9 @@ public abstract class SelectorProvider { ...@@ -167,9 +167,9 @@ public abstract class SelectorProvider {
synchronized (lock) { synchronized (lock) {
if (provider != null) if (provider != null)
return provider; return provider;
return (SelectorProvider)AccessController return AccessController.doPrivileged(
.doPrivileged(new PrivilegedAction() { new PrivilegedAction<SelectorProvider>() {
public Object run() { public SelectorProvider run() {
if (loadProviderFromProperty()) if (loadProviderFromProperty())
return provider; return provider;
if (loadProviderAsService()) if (loadProviderAsService())
......
...@@ -263,7 +263,7 @@ public final class ActivationGroupDesc implements Serializable { ...@@ -263,7 +263,7 @@ public final class ActivationGroupDesc implements Serializable {
* @since 1.2 * @since 1.2
*/ */
public String[] getCommandOptions() { public String[] getCommandOptions() {
return (String[]) options.clone(); return options.clone();
} }
/** /**
......
...@@ -136,9 +136,9 @@ public final class VMID implements java.io.Serializable { ...@@ -136,9 +136,9 @@ public final class VMID implements java.io.Serializable {
/* /*
* Get the local host's IP address. * Get the local host's IP address.
*/ */
byte[] addr = (byte[]) java.security.AccessController.doPrivileged( byte[] addr = java.security.AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction<byte[]>() {
public Object run() { public byte[] run() {
try { try {
return InetAddress.getLocalHost().getAddress(); return InetAddress.getLocalHost().getAddress();
} catch (Exception e) { } catch (Exception e) {
......
...@@ -275,7 +275,7 @@ public class TrustAnchor { ...@@ -275,7 +275,7 @@ public class TrustAnchor {
ncBytes = null; ncBytes = null;
nc = null; nc = null;
} else { } else {
ncBytes = (byte []) bytes.clone(); ncBytes = bytes.clone();
// validate DER encoding // validate DER encoding
try { try {
nc = new NameConstraintsExtension(Boolean.FALSE, bytes); nc = new NameConstraintsExtension(Boolean.FALSE, bytes);
...@@ -309,7 +309,7 @@ public class TrustAnchor { ...@@ -309,7 +309,7 @@ public class TrustAnchor {
* or <code>null</code> if not set. * or <code>null</code> if not set.
*/ */
public final byte [] getNameConstraints() { public final byte [] getNameConstraints() {
return (ncBytes == null ? null : (byte []) ncBytes.clone()); return ncBytes == null ? null : ncBytes.clone();
} }
/** /**
......
...@@ -381,7 +381,7 @@ public class X509CertSelector implements CertSelector { ...@@ -381,7 +381,7 @@ public class X509CertSelector implements CertSelector {
if (subjectKeyID == null) { if (subjectKeyID == null) {
this.subjectKeyID = null; this.subjectKeyID = null;
} else { } else {
this.subjectKeyID = (byte[])subjectKeyID.clone(); this.subjectKeyID = subjectKeyID.clone();
} }
} }
...@@ -442,7 +442,7 @@ public class X509CertSelector implements CertSelector { ...@@ -442,7 +442,7 @@ public class X509CertSelector implements CertSelector {
if (authorityKeyID == null) { if (authorityKeyID == null) {
this.authorityKeyID = null; this.authorityKeyID = null;
} else { } else {
this.authorityKeyID = (byte[])authorityKeyID.clone(); this.authorityKeyID = authorityKeyID.clone();
} }
} }
...@@ -566,7 +566,7 @@ public class X509CertSelector implements CertSelector { ...@@ -566,7 +566,7 @@ public class X509CertSelector implements CertSelector {
subjectPublicKey = null; subjectPublicKey = null;
subjectPublicKeyBytes = null; subjectPublicKeyBytes = null;
} else { } else {
subjectPublicKeyBytes = (byte[])key.clone(); subjectPublicKeyBytes = key.clone();
subjectPublicKey = X509Key.parse(new DerValue(subjectPublicKeyBytes)); subjectPublicKey = X509Key.parse(new DerValue(subjectPublicKeyBytes));
} }
} }
...@@ -590,7 +590,7 @@ public class X509CertSelector implements CertSelector { ...@@ -590,7 +590,7 @@ public class X509CertSelector implements CertSelector {
if (keyUsage == null) { if (keyUsage == null) {
this.keyUsage = null; this.keyUsage = null;
} else { } else {
this.keyUsage = (boolean[])keyUsage.clone(); this.keyUsage = keyUsage.clone();
} }
} }
...@@ -1041,7 +1041,7 @@ public class X509CertSelector implements CertSelector { ...@@ -1041,7 +1041,7 @@ public class X509CertSelector implements CertSelector {
ncBytes = null; ncBytes = null;
nc = null; nc = null;
} else { } else {
ncBytes = (byte[])bytes.clone(); ncBytes = bytes.clone();
nc = new NameConstraintsExtension(FALSE, bytes); nc = new NameConstraintsExtension(FALSE, bytes);
} }
} }
...@@ -1438,7 +1438,7 @@ public class X509CertSelector implements CertSelector { ...@@ -1438,7 +1438,7 @@ public class X509CertSelector implements CertSelector {
if (subjectKeyID == null) { if (subjectKeyID == null) {
return null; return null;
} }
return (byte[])subjectKeyID.clone(); return subjectKeyID.clone();
} }
/** /**
...@@ -1457,7 +1457,7 @@ public class X509CertSelector implements CertSelector { ...@@ -1457,7 +1457,7 @@ public class X509CertSelector implements CertSelector {
if (authorityKeyID == null) { if (authorityKeyID == null) {
return null; return null;
} }
return (byte[])authorityKeyID.clone(); return authorityKeyID.clone();
} }
/** /**
...@@ -1546,7 +1546,7 @@ public class X509CertSelector implements CertSelector { ...@@ -1546,7 +1546,7 @@ public class X509CertSelector implements CertSelector {
if (keyUsage == null) { if (keyUsage == null) {
return null; return null;
} }
return (boolean[])keyUsage.clone(); return keyUsage.clone();
} }
/** /**
...@@ -1736,7 +1736,7 @@ public class X509CertSelector implements CertSelector { ...@@ -1736,7 +1736,7 @@ public class X509CertSelector implements CertSelector {
if (ncBytes == null) { if (ncBytes == null) {
return null; return null;
} else { } else {
return (byte[]) ncBytes.clone(); return ncBytes.clone();
} }
} }
......
...@@ -892,7 +892,7 @@ public class ArrayList<E> extends AbstractList<E> ...@@ -892,7 +892,7 @@ public class ArrayList<E> extends AbstractList<E>
private final AbstractList<E> parent; private final AbstractList<E> parent;
private final int parentOffset; private final int parentOffset;
private final int offset; private final int offset;
private int size; int size;
SubList(AbstractList<E> parent, SubList(AbstractList<E> parent,
int offset, int fromIndex, int toIndex) { int offset, int fromIndex, int toIndex) {
...@@ -971,6 +971,7 @@ public class ArrayList<E> extends AbstractList<E> ...@@ -971,6 +971,7 @@ public class ArrayList<E> extends AbstractList<E>
public ListIterator<E> listIterator(final int index) { public ListIterator<E> listIterator(final int index) {
checkForComodification(); checkForComodification();
rangeCheckForAdd(index); rangeCheckForAdd(index);
final int offset = this.offset;
return new ListIterator<E>() { return new ListIterator<E>() {
int cursor = index; int cursor = index;
......
...@@ -1088,7 +1088,7 @@ public class Arrays { ...@@ -1088,7 +1088,7 @@ public class Arrays {
* <i>mutually comparable</i> (for example, strings and integers). * <i>mutually comparable</i> (for example, strings and integers).
*/ */
public static void sort(Object[] a) { public static void sort(Object[] a) {
Object[] aux = (Object[])a.clone(); Object[] aux = a.clone();
mergeSort(aux, a, 0, a.length, 0); mergeSort(aux, a, 0, a.length, 0);
} }
...@@ -1216,7 +1216,7 @@ public class Arrays { ...@@ -1216,7 +1216,7 @@ public class Arrays {
* not <i>mutually comparable</i> using the specified comparator. * not <i>mutually comparable</i> using the specified comparator.
*/ */
public static <T> void sort(T[] a, Comparator<? super T> c) { public static <T> void sort(T[] a, Comparator<? super T> c) {
T[] aux = (T[])a.clone(); T[] aux = a.clone();
if (c==null) if (c==null)
mergeSort(aux, a, 0, a.length, 0); mergeSort(aux, a, 0, a.length, 0);
else else
...@@ -1257,7 +1257,7 @@ public class Arrays { ...@@ -1257,7 +1257,7 @@ public class Arrays {
public static <T> void sort(T[] a, int fromIndex, int toIndex, public static <T> void sort(T[] a, int fromIndex, int toIndex,
Comparator<? super T> c) { Comparator<? super T> c) {
rangeCheck(a.length, fromIndex, toIndex); rangeCheck(a.length, fromIndex, toIndex);
T[] aux = (T[])copyOfRange(a, fromIndex, toIndex); T[] aux = copyOfRange(a, fromIndex, toIndex);
if (c==null) if (c==null)
mergeSort(aux, a, fromIndex, toIndex, -fromIndex); mergeSort(aux, a, fromIndex, toIndex, -fromIndex);
else else
...@@ -4128,7 +4128,7 @@ public class Arrays { ...@@ -4128,7 +4128,7 @@ public class Arrays {
if (a.length != 0 && bufLen <= 0) if (a.length != 0 && bufLen <= 0)
bufLen = Integer.MAX_VALUE; bufLen = Integer.MAX_VALUE;
StringBuilder buf = new StringBuilder(bufLen); StringBuilder buf = new StringBuilder(bufLen);
deepToString(a, buf, new HashSet()); deepToString(a, buf, new HashSet<Object[]>());
return buf.toString(); return buf.toString();
} }
......
...@@ -140,7 +140,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V> ...@@ -140,7 +140,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
public EnumMap(EnumMap<K, ? extends V> m) { public EnumMap(EnumMap<K, ? extends V> m) {
keyType = m.keyType; keyType = m.keyType;
keyUniverse = m.keyUniverse; keyUniverse = m.keyUniverse;
vals = (Object[]) m.vals.clone(); vals = m.vals.clone();
size = m.size; size = m.size;
} }
...@@ -161,7 +161,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V> ...@@ -161,7 +161,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
EnumMap<K, ? extends V> em = (EnumMap<K, ? extends V>) m; EnumMap<K, ? extends V> em = (EnumMap<K, ? extends V>) m;
keyType = em.keyType; keyType = em.keyType;
keyUniverse = em.keyUniverse; keyUniverse = em.keyUniverse;
vals = (Object[]) em.vals.clone(); vals = em.vals.clone();
size = em.size; size = em.size;
} else { } else {
if (m.isEmpty()) if (m.isEmpty())
...@@ -257,7 +257,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V> ...@@ -257,7 +257,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
public V put(K key, V value) { public V put(K key, V value) {
typeCheck(key); typeCheck(key);
int index = ((Enum)key).ordinal(); int index = key.ordinal();
Object oldValue = vals[index]; Object oldValue = vals[index];
vals[index] = maskNull(value); vals[index] = maskNull(value);
if (oldValue == null) if (oldValue == null)
...@@ -662,7 +662,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V> ...@@ -662,7 +662,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
} catch(CloneNotSupportedException e) { } catch(CloneNotSupportedException e) {
throw new AssertionError(); throw new AssertionError();
} }
result.vals = (Object[]) result.vals.clone(); result.vals = result.vals.clone();
return result; return result;
} }
......
...@@ -701,7 +701,7 @@ public class IdentityHashMap<K,V> ...@@ -701,7 +701,7 @@ public class IdentityHashMap<K,V>
try { try {
IdentityHashMap<K,V> m = (IdentityHashMap<K,V>) super.clone(); IdentityHashMap<K,V> m = (IdentityHashMap<K,V>) super.clone();
m.entrySet = null; m.entrySet = null;
m.table = (Object[])table.clone(); m.table = table.clone();
return m; return m;
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
throw new InternalError(); throw new InternalError();
...@@ -975,7 +975,7 @@ public class IdentityHashMap<K,V> ...@@ -975,7 +975,7 @@ public class IdentityHashMap<K,V>
*/ */
public boolean removeAll(Collection<?> c) { public boolean removeAll(Collection<?> c) {
boolean modified = false; boolean modified = false;
for (Iterator i = iterator(); i.hasNext(); ) { for (Iterator<K> i = iterator(); i.hasNext(); ) {
if (c.contains(i.next())) { if (c.contains(i.next())) {
i.remove(); i.remove();
modified = true; modified = true;
...@@ -1033,7 +1033,7 @@ public class IdentityHashMap<K,V> ...@@ -1033,7 +1033,7 @@ public class IdentityHashMap<K,V>
return containsValue(o); return containsValue(o);
} }
public boolean remove(Object o) { public boolean remove(Object o) {
for (Iterator i = iterator(); i.hasNext(); ) { for (Iterator<V> i = iterator(); i.hasNext(); ) {
if (i.next() == o) { if (i.next() == o) {
i.remove(); i.remove();
return true; return true;
...@@ -1121,7 +1121,7 @@ public class IdentityHashMap<K,V> ...@@ -1121,7 +1121,7 @@ public class IdentityHashMap<K,V>
*/ */
public boolean removeAll(Collection<?> c) { public boolean removeAll(Collection<?> c) {
boolean modified = false; boolean modified = false;
for (Iterator i = iterator(); i.hasNext(); ) { for (Iterator<Map.Entry<K,V>> i = iterator(); i.hasNext(); ) {
if (c.contains(i.next())) { if (c.contains(i.next())) {
i.remove(); i.remove();
modified = true; modified = true;
......
...@@ -364,7 +364,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> { ...@@ -364,7 +364,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
public EnumSet<E> clone() { public EnumSet<E> clone() {
JumboEnumSet<E> result = (JumboEnumSet<E>) super.clone(); JumboEnumSet<E> result = (JumboEnumSet<E>) super.clone();
result.elements = (long[]) result.elements.clone(); result.elements = result.elements.clone();
return result; return result;
} }
} }
...@@ -504,7 +504,7 @@ class Random implements java.io.Serializable { ...@@ -504,7 +504,7 @@ class Random implements java.io.Serializable {
// The seed is read in as {@code long} for // The seed is read in as {@code long} for
// historical reasons, but it is converted to an AtomicLong. // historical reasons, but it is converted to an AtomicLong.
long seedVal = (long) fields.get("seed", -1L); long seedVal = fields.get("seed", -1L);
if (seedVal < 0) if (seedVal < 0)
throw new java.io.StreamCorruptedException( throw new java.io.StreamCorruptedException(
"Random: invalid seed"); "Random: invalid seed");
......
...@@ -195,7 +195,7 @@ public class TreeSet<E> extends AbstractSet<E> ...@@ -195,7 +195,7 @@ public class TreeSet<E> extends AbstractSet<E>
* @since 1.6 * @since 1.6
*/ */
public NavigableSet<E> descendingSet() { public NavigableSet<E> descendingSet() {
return new TreeSet(m.descendingMap()); return new TreeSet<E>(m.descendingMap());
} }
/** /**
...@@ -505,8 +505,8 @@ public class TreeSet<E> extends AbstractSet<E> ...@@ -505,8 +505,8 @@ public class TreeSet<E> extends AbstractSet<E>
s.writeInt(m.size()); s.writeInt(m.size());
// Write out all elements in the proper order. // Write out all elements in the proper order.
for (Iterator i=m.keySet().iterator(); i.hasNext(); ) for (E e : m.keySet())
s.writeObject(i.next()); s.writeObject(e);
} }
/** /**
......
...@@ -155,7 +155,8 @@ public abstract class AbstractPreferences extends Preferences { ...@@ -155,7 +155,8 @@ public abstract class AbstractPreferences extends Preferences {
* All known unremoved children of this node. (This "cache" is consulted * All known unremoved children of this node. (This "cache" is consulted
* prior to calling childSpi() or getChild(). * prior to calling childSpi() or getChild().
*/ */
private Map kidCache = new HashMap(); private Map<String, AbstractPreferences> kidCache
= new HashMap<String, AbstractPreferences>();
/** /**
* This field is used to keep track of whether or not this node has * This field is used to keep track of whether or not this node has
...@@ -712,11 +713,10 @@ public abstract class AbstractPreferences extends Preferences { ...@@ -712,11 +713,10 @@ public abstract class AbstractPreferences extends Preferences {
if (removed) if (removed)
throw new IllegalStateException("Node has been removed."); throw new IllegalStateException("Node has been removed.");
Set s = new TreeSet(kidCache.keySet()); Set<String> s = new TreeSet<String>(kidCache.keySet());
String[] kids = childrenNamesSpi(); for (String kid : childrenNamesSpi())
for(int i=0; i<kids.length; i++) s.add(kid);
s.add(kids[i]); return s.toArray(EMPTY_STRING_ARRAY);
return (String[]) s.toArray(EMPTY_STRING_ARRAY);
} }
} }
...@@ -728,8 +728,7 @@ public abstract class AbstractPreferences extends Preferences { ...@@ -728,8 +728,7 @@ public abstract class AbstractPreferences extends Preferences {
* @return all known unremoved children of this node. * @return all known unremoved children of this node.
*/ */
protected final AbstractPreferences[] cachedChildren() { protected final AbstractPreferences[] cachedChildren() {
return (AbstractPreferences[]) kidCache.values(). return kidCache.values().toArray(EMPTY_ABSTRACT_PREFS_ARRAY);
toArray(EMPTY_ABSTRACT_PREFS_ARRAY);
} }
private static final AbstractPreferences[] EMPTY_ABSTRACT_PREFS_ARRAY private static final AbstractPreferences[] EMPTY_ABSTRACT_PREFS_ARRAY
...@@ -825,7 +824,7 @@ public abstract class AbstractPreferences extends Preferences { ...@@ -825,7 +824,7 @@ public abstract class AbstractPreferences extends Preferences {
if (token.equals("/")) // Check for consecutive slashes if (token.equals("/")) // Check for consecutive slashes
throw new IllegalArgumentException("Consecutive slashes in path"); throw new IllegalArgumentException("Consecutive slashes in path");
synchronized(lock) { synchronized(lock) {
AbstractPreferences child=(AbstractPreferences)kidCache.get(token); AbstractPreferences child = kidCache.get(token);
if (child == null) { if (child == null) {
if (token.length() > MAX_NAME_LENGTH) if (token.length() > MAX_NAME_LENGTH)
throw new IllegalArgumentException( throw new IllegalArgumentException(
...@@ -893,7 +892,7 @@ public abstract class AbstractPreferences extends Preferences { ...@@ -893,7 +892,7 @@ public abstract class AbstractPreferences extends Preferences {
if (token.equals("/")) // Check for consecutive slashes if (token.equals("/")) // Check for consecutive slashes
throw new IllegalArgumentException("Consecutive slashes in path"); throw new IllegalArgumentException("Consecutive slashes in path");
synchronized(lock) { synchronized(lock) {
AbstractPreferences child=(AbstractPreferences)kidCache.get(token); AbstractPreferences child = kidCache.get(token);
if (child == null) if (child == null)
child = getChild(token); child = getChild(token);
if (child==null) if (child==null)
...@@ -964,9 +963,10 @@ public abstract class AbstractPreferences extends Preferences { ...@@ -964,9 +963,10 @@ public abstract class AbstractPreferences extends Preferences {
kidCache.put(kidNames[i], childSpi(kidNames[i])); kidCache.put(kidNames[i], childSpi(kidNames[i]));
// Recursively remove all cached children // Recursively remove all cached children
for (Iterator i = kidCache.values().iterator(); i.hasNext();) { for (Iterator<AbstractPreferences> i = kidCache.values().iterator();
i.hasNext();) {
try { try {
((AbstractPreferences)i.next()).removeNode2(); i.next().removeNode2();
i.remove(); i.remove();
} catch (BackingStoreException x) { } } catch (BackingStoreException x) { }
} }
...@@ -1020,13 +1020,12 @@ public abstract class AbstractPreferences extends Preferences { ...@@ -1020,13 +1020,12 @@ public abstract class AbstractPreferences extends Preferences {
* preference tree. * preference tree.
*/ */
public boolean isUserNode() { public boolean isUserNode() {
Boolean result = (Boolean) return AccessController.doPrivileged(
AccessController.doPrivileged( new PrivilegedAction() { new PrivilegedAction<Boolean>() {
public Object run() { public Boolean run() {
return Boolean.valueOf(root == Preferences.userRoot()); return root == Preferences.userRoot();
} }
}); }).booleanValue();
return result.booleanValue();
} }
public void addPreferenceChangeListener(PreferenceChangeListener pcl) { public void addPreferenceChangeListener(PreferenceChangeListener pcl) {
...@@ -1443,7 +1442,8 @@ public abstract class AbstractPreferences extends Preferences { ...@@ -1443,7 +1442,8 @@ public abstract class AbstractPreferences extends Preferences {
* event delivery from preference activity, greatly simplifying * event delivery from preference activity, greatly simplifying
* locking and reducing opportunity for deadlock. * locking and reducing opportunity for deadlock.
*/ */
private static final List eventQueue = new LinkedList(); private static final List<EventObject> eventQueue
= new LinkedList<EventObject>();
/** /**
* These two classes are used to distinguish NodeChangeEvents on * These two classes are used to distinguish NodeChangeEvents on
...@@ -1476,7 +1476,7 @@ public abstract class AbstractPreferences extends Preferences { ...@@ -1476,7 +1476,7 @@ public abstract class AbstractPreferences extends Preferences {
try { try {
while (eventQueue.isEmpty()) while (eventQueue.isEmpty())
eventQueue.wait(); eventQueue.wait();
event = (EventObject) eventQueue.remove(0); event = eventQueue.remove(0);
} catch (InterruptedException e) { } catch (InterruptedException e) {
// XXX Log "Event dispatch thread interrupted. Exiting" // XXX Log "Event dispatch thread interrupted. Exiting"
return; return;
......
...@@ -249,7 +249,7 @@ public final class Matcher implements MatchResult { ...@@ -249,7 +249,7 @@ public final class Matcher implements MatchResult {
Matcher result = new Matcher(this.parentPattern, text.toString()); Matcher result = new Matcher(this.parentPattern, text.toString());
result.first = this.first; result.first = this.first;
result.last = this.last; result.last = this.last;
result.groups = (int[])(this.groups.clone()); result.groups = this.groups.clone();
return result; return result;
} }
......
...@@ -121,7 +121,7 @@ public class SslRMIClientSocketFactory ...@@ -121,7 +121,7 @@ public class SslRMIClientSocketFactory
sslSocketFactory.createSocket(host, port); sslSocketFactory.createSocket(host, port);
// Set the SSLSocket Enabled Cipher Suites // Set the SSLSocket Enabled Cipher Suites
// //
final String enabledCipherSuites = (String) final String enabledCipherSuites =
System.getProperty("javax.rmi.ssl.client.enabledCipherSuites"); System.getProperty("javax.rmi.ssl.client.enabledCipherSuites");
if (enabledCipherSuites != null) { if (enabledCipherSuites != null) {
StringTokenizer st = new StringTokenizer(enabledCipherSuites, ","); StringTokenizer st = new StringTokenizer(enabledCipherSuites, ",");
...@@ -139,7 +139,7 @@ public class SslRMIClientSocketFactory ...@@ -139,7 +139,7 @@ public class SslRMIClientSocketFactory
} }
// Set the SSLSocket Enabled Protocols // Set the SSLSocket Enabled Protocols
// //
final String enabledProtocols = (String) final String enabledProtocols =
System.getProperty("javax.rmi.ssl.client.enabledProtocols"); System.getProperty("javax.rmi.ssl.client.enabledProtocols");
if (enabledProtocols != null) { if (enabledProtocols != null) {
StringTokenizer st = new StringTokenizer(enabledProtocols, ","); StringTokenizer st = new StringTokenizer(enabledProtocols, ",");
......
...@@ -165,9 +165,9 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory { ...@@ -165,9 +165,9 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory {
// Initialize the configuration parameters. // Initialize the configuration parameters.
// //
this.enabledCipherSuites = enabledCipherSuites == null ? this.enabledCipherSuites = enabledCipherSuites == null ?
null : (String[]) enabledCipherSuites.clone(); null : enabledCipherSuites.clone();
this.enabledProtocols = enabledProtocols == null ? this.enabledProtocols = enabledProtocols == null ?
null : (String[]) enabledProtocols.clone(); null : enabledProtocols.clone();
this.needClientAuth = needClientAuth; this.needClientAuth = needClientAuth;
// Force the initialization of the default at construction time, // Force the initialization of the default at construction time,
...@@ -196,13 +196,11 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory { ...@@ -196,13 +196,11 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory {
// //
if (this.enabledCipherSuites != null) { if (this.enabledCipherSuites != null) {
sslSocket.setEnabledCipherSuites(this.enabledCipherSuites); sslSocket.setEnabledCipherSuites(this.enabledCipherSuites);
enabledCipherSuitesList = enabledCipherSuitesList = Arrays.asList(this.enabledCipherSuites);
Arrays.asList((String[]) this.enabledCipherSuites);
} }
if (this.enabledProtocols != null) { if (this.enabledProtocols != null) {
sslSocket.setEnabledProtocols(this.enabledProtocols); sslSocket.setEnabledProtocols(this.enabledProtocols);
enabledProtocolsList = enabledProtocolsList = Arrays.asList(this.enabledProtocols);
Arrays.asList((String[]) this.enabledProtocols);
} }
} }
...@@ -218,7 +216,7 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory { ...@@ -218,7 +216,7 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory {
*/ */
public final String[] getEnabledCipherSuites() { public final String[] getEnabledCipherSuites() {
return enabledCipherSuites == null ? return enabledCipherSuites == null ?
null : (String[]) enabledCipherSuites.clone(); null : enabledCipherSuites.clone();
} }
/** /**
...@@ -234,7 +232,7 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory { ...@@ -234,7 +232,7 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory {
*/ */
public final String[] getEnabledProtocols() { public final String[] getEnabledProtocols() {
return enabledProtocols == null ? return enabledProtocols == null ?
null : (String[]) enabledProtocols.clone(); null : enabledProtocols.clone();
} }
/** /**
...@@ -315,8 +313,8 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory { ...@@ -315,8 +313,8 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory {
(enabledCipherSuites != null && that.enabledCipherSuites == null)) (enabledCipherSuites != null && that.enabledCipherSuites == null))
return false; return false;
if (enabledCipherSuites != null && that.enabledCipherSuites != null) { if (enabledCipherSuites != null && that.enabledCipherSuites != null) {
List thatEnabledCipherSuitesList = List<String> thatEnabledCipherSuitesList =
Arrays.asList((String[]) that.enabledCipherSuites); Arrays.asList(that.enabledCipherSuites);
if (!enabledCipherSuitesList.equals(thatEnabledCipherSuitesList)) if (!enabledCipherSuitesList.equals(thatEnabledCipherSuitesList))
return false; return false;
} }
...@@ -327,8 +325,8 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory { ...@@ -327,8 +325,8 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory {
(enabledProtocols != null && that.enabledProtocols == null)) (enabledProtocols != null && that.enabledProtocols == null))
return false; return false;
if (enabledProtocols != null && that.enabledProtocols != null) { if (enabledProtocols != null && that.enabledProtocols != null) {
List thatEnabledProtocolsList = List<String> thatEnabledProtocolsList =
Arrays.asList((String[]) that.enabledProtocols); Arrays.asList(that.enabledProtocols);
if (!enabledProtocolsList.equals(thatEnabledProtocolsList)) if (!enabledProtocolsList.equals(thatEnabledProtocolsList))
return false; return false;
} }
...@@ -374,7 +372,7 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory { ...@@ -374,7 +372,7 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory {
private final String[] enabledCipherSuites; private final String[] enabledCipherSuites;
private final String[] enabledProtocols; private final String[] enabledProtocols;
private final boolean needClientAuth; private final boolean needClientAuth;
private List enabledCipherSuitesList; private List<String> enabledCipherSuitesList;
private List enabledProtocolsList; private List<String> enabledProtocolsList;
private SSLContext context; private SSLContext context;
} }
...@@ -276,7 +276,7 @@ public class KerberosTicket implements Destroyable, Refreshable, ...@@ -276,7 +276,7 @@ public class KerberosTicket implements Destroyable, Refreshable,
if (flags != null) { if (flags != null) {
if (flags.length >= NUM_FLAGS) if (flags.length >= NUM_FLAGS)
this.flags = (boolean[]) flags.clone(); this.flags = flags.clone();
else { else {
this.flags = new boolean[NUM_FLAGS]; this.flags = new boolean[NUM_FLAGS];
// Fill in whatever we have // Fill in whatever we have
...@@ -304,7 +304,7 @@ public class KerberosTicket implements Destroyable, Refreshable, ...@@ -304,7 +304,7 @@ public class KerberosTicket implements Destroyable, Refreshable,
this.endTime = endTime; this.endTime = endTime;
if (clientAddresses != null) if (clientAddresses != null)
this.clientAddresses = (InetAddress[]) clientAddresses.clone(); this.clientAddresses = clientAddresses.clone();
} }
/** /**
...@@ -430,7 +430,7 @@ public class KerberosTicket implements Destroyable, Refreshable, ...@@ -430,7 +430,7 @@ public class KerberosTicket implements Destroyable, Refreshable,
* @return the flags associated with this ticket. * @return the flags associated with this ticket.
*/ */
public final boolean[] getFlags() { public final boolean[] getFlags() {
return (flags == null? null: (boolean[]) flags.clone()); return (flags == null? null: flags.clone());
} }
/** /**
...@@ -479,8 +479,7 @@ public class KerberosTicket implements Destroyable, Refreshable, ...@@ -479,8 +479,7 @@ public class KerberosTicket implements Destroyable, Refreshable,
* provided. * provided.
*/ */
public final java.net.InetAddress[] getClientAddresses() { public final java.net.InetAddress[] getClientAddresses() {
return (clientAddresses == null? return (clientAddresses == null) ? null: clientAddresses.clone();
null: (InetAddress[]) clientAddresses.clone());
} }
/** /**
...@@ -491,7 +490,7 @@ public class KerberosTicket implements Destroyable, Refreshable, ...@@ -491,7 +490,7 @@ public class KerberosTicket implements Destroyable, Refreshable,
public final byte[] getEncoded() { public final byte[] getEncoded() {
if (destroyed) if (destroyed)
throw new IllegalStateException("This ticket is no longer valid"); throw new IllegalStateException("This ticket is no longer valid");
return (byte[]) asn1Encoding.clone(); return asn1Encoding.clone();
} }
/** Determines if this ticket is still current. */ /** Determines if this ticket is still current. */
......
...@@ -66,7 +66,7 @@ class KeyImpl implements SecretKey, Destroyable, Serializable { ...@@ -66,7 +66,7 @@ class KeyImpl implements SecretKey, Destroyable, Serializable {
*/ */
public KeyImpl(byte[] keyBytes, public KeyImpl(byte[] keyBytes,
int keyType) { int keyType) {
this.keyBytes = (byte[]) keyBytes.clone(); this.keyBytes = keyBytes.clone();
this.keyType = keyType; this.keyType = keyType;
} }
...@@ -151,7 +151,7 @@ class KeyImpl implements SecretKey, Destroyable, Serializable { ...@@ -151,7 +151,7 @@ class KeyImpl implements SecretKey, Destroyable, Serializable {
public final byte[] getEncoded() { public final byte[] getEncoded() {
if (destroyed) if (destroyed)
throw new IllegalStateException("This key is no longer valid"); throw new IllegalStateException("This key is no longer valid");
return (byte[])keyBytes.clone(); return keyBytes.clone();
} }
public void destroy() throws DestroyFailedException { public void destroy() throws DestroyFailedException {
......
...@@ -46,8 +46,10 @@ public abstract class ClassFileTransformer ...@@ -46,8 +46,10 @@ public abstract class ClassFileTransformer
{ {
// Singleton of ClassFileTransformer // Singleton of ClassFileTransformer
// //
private static ArrayList transformerList = new ArrayList(); private static ArrayList<ClassFileTransformer> transformerList
private static Object[] transformers = new Object[0]; = new ArrayList<ClassFileTransformer>();
private static ClassFileTransformer[] transformers
= new ClassFileTransformer[0];
/** /**
* Add the class file transformer object. * Add the class file transformer object.
...@@ -59,7 +61,7 @@ public abstract class ClassFileTransformer ...@@ -59,7 +61,7 @@ public abstract class ClassFileTransformer
synchronized(transformerList) synchronized(transformerList)
{ {
transformerList.add(t); transformerList.add(t);
transformers = transformerList.toArray(); transformers = transformerList.toArray(new ClassFileTransformer[0]);
} }
} }
...@@ -68,7 +70,7 @@ public abstract class ClassFileTransformer ...@@ -68,7 +70,7 @@ public abstract class ClassFileTransformer
* *
* @return ClassFileTransformer object array * @return ClassFileTransformer object array
*/ */
public static Object[] getTransformers() public static ClassFileTransformer[] getTransformers()
{ {
// transformers is not intended to be changed frequently, // transformers is not intended to be changed frequently,
// so it is okay to not put synchronized block here // so it is okay to not put synchronized block here
......
...@@ -141,8 +141,8 @@ public class Cleaner ...@@ -141,8 +141,8 @@ public class Cleaner
try { try {
thunk.run(); thunk.run();
} catch (final Throwable x) { } catch (final Throwable x) {
AccessController.doPrivileged(new PrivilegedAction() { AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Object run() { public Void run() {
if (System.err != null) if (System.err != null)
new Error("Cleaner terminated abnormally", x) new Error("Cleaner terminated abnormally", x)
.printStackTrace(); .printStackTrace();
......
...@@ -284,10 +284,9 @@ public class ExtensionDependency { ...@@ -284,10 +284,9 @@ public class ExtensionDependency {
// Load the jar file ... // Load the jar file ...
Manifest man; Manifest man;
try { try {
man = (Manifest) AccessController.doPrivileged man = AccessController.doPrivileged(
( new PrivilegedExceptionAction<Manifest>() {
new PrivilegedExceptionAction() { public Manifest run()
public Object run()
throws IOException, FileNotFoundException { throws IOException, FileNotFoundException {
if (!file.exists()) if (!file.exists())
throw new FileNotFoundException(file.getName()); throw new FileNotFoundException(file.getName());
...@@ -391,9 +390,9 @@ public class ExtensionDependency { ...@@ -391,9 +390,9 @@ public class ExtensionDependency {
final String extName = extensionName; final String extName = extensionName;
final String[] fileExt = {".jar", ".zip"}; final String[] fileExt = {".jar", ".zip"};
return (File) AccessController.doPrivileged return AccessController.doPrivileged(
(new PrivilegedAction() { new PrivilegedAction<File>() {
public Object run() { public File run() {
try { try {
File fExtension; File fExtension;
File[] dirs = getExtDirs(); File[] dirs = getExtDirs();
...@@ -460,7 +459,7 @@ public class ExtensionDependency { ...@@ -460,7 +459,7 @@ public class ExtensionDependency {
* @return the list of files installed in all the directories * @return the list of files installed in all the directories
*/ */
private static File[] getExtFiles(File[] dirs) throws IOException { private static File[] getExtFiles(File[] dirs) throws IOException {
Vector urls = new Vector(); Vector<File> urls = new Vector<File>();
for (int i = 0; i < dirs.length; i++) { for (int i = 0; i < dirs.length; i++) {
String[] files = dirs[i].list(new JarFilter()); String[] files = dirs[i].list(new JarFilter());
if (files != null) { if (files != null) {
...@@ -484,16 +483,15 @@ public class ExtensionDependency { ...@@ -484,16 +483,15 @@ public class ExtensionDependency {
* </p> * </p>
*/ */
private File[] getInstalledExtensions() throws IOException { private File[] getInstalledExtensions() throws IOException {
return (File[]) AccessController.doPrivileged return AccessController.doPrivileged(
( new PrivilegedAction<File[]>() {
new PrivilegedAction() { public File[] run() {
public Object run() {
try { try {
return getExtFiles(getExtDirs()); return getExtFiles(getExtDirs());
} catch(IOException e) { } catch(IOException e) {
debug("Cannot get list of installed extensions"); debug("Cannot get list of installed extensions");
debugException(e); debugException(e);
return new URL[0]; return new File[0];
} }
} }
}); });
......
...@@ -128,8 +128,8 @@ public class GC { ...@@ -128,8 +128,8 @@ public class GC {
/* Create a new daemon thread in the root thread group */ /* Create a new daemon thread in the root thread group */
public static void create() { public static void create() {
PrivilegedAction pa = new PrivilegedAction() { PrivilegedAction<Void> pa = new PrivilegedAction<Void>() {
public Object run() { public Void run() {
ThreadGroup tg = Thread.currentThread().getThreadGroup(); ThreadGroup tg = Thread.currentThread().getThreadGroup();
for (ThreadGroup tgn = tg; for (ThreadGroup tgn = tg;
tgn != null; tgn != null;
...@@ -170,13 +170,14 @@ public class GC { ...@@ -170,13 +170,14 @@ public class GC {
* method. Given a request, the only interesting operation is that of * method. Given a request, the only interesting operation is that of
* cancellation. * cancellation.
*/ */
public static class LatencyRequest implements Comparable { public static class LatencyRequest
implements Comparable<LatencyRequest> {
/* Instance counter, used to generate unique identifers */ /* Instance counter, used to generate unique identifers */
private static long counter = 0; private static long counter = 0;
/* Sorted set of active latency requests */ /* Sorted set of active latency requests */
private static SortedSet requests = null; private static SortedSet<LatencyRequest> requests = null;
/* Examine the request set and reset the latency target if necessary. /* Examine the request set and reset the latency target if necessary.
* Must be invoked while holding the lock. * Must be invoked while holding the lock.
...@@ -187,7 +188,7 @@ public class GC { ...@@ -187,7 +188,7 @@ public class GC {
setLatencyTarget(NO_TARGET); setLatencyTarget(NO_TARGET);
} }
} else { } else {
LatencyRequest r = (LatencyRequest)requests.first(); LatencyRequest r = requests.first();
if (r.latency != latencyTarget) { if (r.latency != latencyTarget) {
setLatencyTarget(r.latency); setLatencyTarget(r.latency);
} }
...@@ -211,7 +212,7 @@ public class GC { ...@@ -211,7 +212,7 @@ public class GC {
synchronized (lock) { synchronized (lock) {
this.id = ++counter; this.id = ++counter;
if (requests == null) { if (requests == null) {
requests = new TreeSet(); requests = new TreeSet<LatencyRequest>();
} }
requests.add(this); requests.add(this);
adjustLatencyIfNeeded(); adjustLatencyIfNeeded();
...@@ -240,8 +241,7 @@ public class GC { ...@@ -240,8 +241,7 @@ public class GC {
} }
} }
public int compareTo(Object o) { public int compareTo(LatencyRequest r) {
LatencyRequest r = (LatencyRequest)o;
long d = this.latency - r.latency; long d = this.latency - r.latency;
if (d == 0) d = this.id - r.id; if (d == 0) d = this.id - r.id;
return (d < 0) ? -1 : ((d > 0) ? +1 : 0); return (d < 0) ? -1 : ((d > 0) ? +1 : 0);
......
...@@ -135,9 +135,9 @@ public class Launcher { ...@@ -135,9 +135,9 @@ public class Launcher {
// aa synthesized ACC via a call to the private method // aa synthesized ACC via a call to the private method
// ExtClassLoader.getContext(). // ExtClassLoader.getContext().
return (ExtClassLoader) AccessController.doPrivileged( return AccessController.doPrivileged(
new PrivilegedExceptionAction() { new PrivilegedExceptionAction<ExtClassLoader>() {
public Object run() throws IOException { public ExtClassLoader run() throws IOException {
int len = dirs.length; int len = dirs.length;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
MetaIndex.registerDirectory(dirs[i]); MetaIndex.registerDirectory(dirs[i]);
...@@ -180,7 +180,7 @@ public class Launcher { ...@@ -180,7 +180,7 @@ public class Launcher {
} }
private static URL[] getExtURLs(File[] dirs) throws IOException { private static URL[] getExtURLs(File[] dirs) throws IOException {
Vector urls = new Vector(); Vector<URL> urls = new Vector<URL>();
for (int i = 0; i < dirs.length; i++) { for (int i = 0; i < dirs.length; i++) {
String[] files = dirs[i].list(); String[] files = dirs[i].list();
if (files != null) { if (files != null) {
...@@ -261,9 +261,9 @@ public class Launcher { ...@@ -261,9 +261,9 @@ public class Launcher {
// when loading classes. Specifically it prevent // when loading classes. Specifically it prevent
// accessClassInPackage.sun.* grants from being honored. // accessClassInPackage.sun.* grants from being honored.
// //
return (AppClassLoader) return AccessController.doPrivileged(
AccessController.doPrivileged(new PrivilegedAction() { new PrivilegedAction<AppClassLoader>() {
public Object run() { public AppClassLoader run() {
URL[] urls = URL[] urls =
(s == null) ? new URL[0] : pathToURLs(path); (s == null) ? new URL[0] : pathToURLs(path);
return new AppClassLoader(urls, extcl); return new AppClassLoader(urls, extcl);
...@@ -348,12 +348,12 @@ public class Launcher { ...@@ -348,12 +348,12 @@ public class Launcher {
URL[] urls; URL[] urls;
if (prop != null) { if (prop != null) {
final String path = prop; final String path = prop;
urls = (URL[])AccessController.doPrivileged( urls = AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction<URL[]>() {
public Object run() { public URL[] run() {
File[] classPath = getClassPath(path); File[] classPath = getClassPath(path);
int len = classPath.length; int len = classPath.length;
Set seenDirs = new HashSet(); Set<File> seenDirs = new HashSet<File>();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
File curEntry = classPath[i]; File curEntry = classPath[i];
// Negative test used to properly handle // Negative test used to properly handle
...@@ -509,8 +509,8 @@ class PathPermissions extends PermissionCollection { ...@@ -509,8 +509,8 @@ class PathPermissions extends PermissionCollection {
perms.add(new java.util.PropertyPermission("java.*", perms.add(new java.util.PropertyPermission("java.*",
SecurityConstants.PROPERTY_READ_ACTION)); SecurityConstants.PROPERTY_READ_ACTION));
AccessController.doPrivileged(new PrivilegedAction() { AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Object run() { public Void run() {
for (int i=0; i < path.length; i++) { for (int i=0; i < path.length; i++) {
File f = path[i]; File f = path[i];
String path; String path;
...@@ -553,7 +553,7 @@ class PathPermissions extends PermissionCollection { ...@@ -553,7 +553,7 @@ class PathPermissions extends PermissionCollection {
return perms.implies(permission); return perms.implies(permission);
} }
public java.util.Enumeration elements() { public java.util.Enumeration<Permission> elements() {
if (perms == null) if (perms == null)
init(); init();
synchronized (perms) { synchronized (perms) {
......
...@@ -78,7 +78,7 @@ public class PerformanceLogger { ...@@ -78,7 +78,7 @@ public class PerformanceLogger {
private static boolean perfLoggingOn = false; private static boolean perfLoggingOn = false;
private static boolean useNanoTime = false; private static boolean useNanoTime = false;
private static Vector times; private static Vector<TimeData> times;
private static String logFileName = null; private static String logFileName = null;
private static Writer logWriter = null; private static Writer logWriter = null;
...@@ -104,8 +104,8 @@ public class PerformanceLogger { ...@@ -104,8 +104,8 @@ public class PerformanceLogger {
if (logFileName != null) { if (logFileName != null) {
if (logWriter == null) { if (logWriter == null) {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Void>() {
public Object run() { public Void run() {
try { try {
File logFile = new File(logFileName); File logFile = new File(logFileName);
logFile.createNewFile(); logFile.createNewFile();
...@@ -124,7 +124,7 @@ public class PerformanceLogger { ...@@ -124,7 +124,7 @@ public class PerformanceLogger {
logWriter = new OutputStreamWriter(System.out); logWriter = new OutputStreamWriter(System.out);
} }
} }
times = new Vector(10); times = new Vector<TimeData>(10);
// Reserve predefined slots // Reserve predefined slots
for (int i = 0; i <= LAST_RESERVED; ++i) { for (int i = 0; i <= LAST_RESERVED; ++i) {
times.add(new TimeData("Time " + i + " not set", 0)); times.add(new TimeData("Time " + i + " not set", 0));
...@@ -207,7 +207,7 @@ public class PerformanceLogger { ...@@ -207,7 +207,7 @@ public class PerformanceLogger {
*/ */
public static long getStartTime() { public static long getStartTime() {
if (loggingEnabled()) { if (loggingEnabled()) {
return ((TimeData)times.get(START_INDEX)).getTime(); return times.get(START_INDEX).getTime();
} else { } else {
return 0; return 0;
} }
...@@ -253,7 +253,7 @@ public class PerformanceLogger { ...@@ -253,7 +253,7 @@ public class PerformanceLogger {
*/ */
public static long getTimeAtIndex(int index) { public static long getTimeAtIndex(int index) {
if (loggingEnabled()) { if (loggingEnabled()) {
return ((TimeData)times.get(index)).getTime(); return times.get(index).getTime();
} else { } else {
return 0; return 0;
} }
...@@ -264,7 +264,7 @@ public class PerformanceLogger { ...@@ -264,7 +264,7 @@ public class PerformanceLogger {
*/ */
public static String getMessageAtIndex(int index) { public static String getMessageAtIndex(int index) {
if (loggingEnabled()) { if (loggingEnabled()) {
return ((TimeData)times.get(index)).getMessage(); return times.get(index).getMessage();
} else { } else {
return null; return null;
} }
...@@ -278,7 +278,7 @@ public class PerformanceLogger { ...@@ -278,7 +278,7 @@ public class PerformanceLogger {
try { try {
synchronized(times) { synchronized(times) {
for (int i = 0; i < times.size(); ++i) { for (int i = 0; i < times.size(); ++i) {
TimeData td = (TimeData)times.get(i); TimeData td = times.get(i);
if (td != null) { if (td != null) {
writer.write(i + " " + td.getMessage() + ": " + writer.write(i + " " + td.getMessage() + ": " +
td.getTime() + "\n"); td.getTime() + "\n");
......
...@@ -324,8 +324,8 @@ public class ProxyGenerator { ...@@ -324,8 +324,8 @@ public class ProxyGenerator {
if (saveGeneratedFiles) { if (saveGeneratedFiles) {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Void>() {
public Object run() { public Void run() {
try { try {
FileOutputStream file = FileOutputStream file =
new FileOutputStream(dotToSlash(name) + ".class"); new FileOutputStream(dotToSlash(name) + ".class");
...@@ -576,7 +576,7 @@ public class ProxyGenerator { ...@@ -576,7 +576,7 @@ public class ProxyGenerator {
* compatibly with the throws clauses of both * compatibly with the throws clauses of both
* overridden methods. * overridden methods.
*/ */
List<Class> legalExceptions = new ArrayList<Class>(); List<Class<?>> legalExceptions = new ArrayList<Class<?>>();
collectCompatibleTypes( collectCompatibleTypes(
exceptionTypes, pm.exceptionTypes, legalExceptions); exceptionTypes, pm.exceptionTypes, legalExceptions);
collectCompatibleTypes( collectCompatibleTypes(
...@@ -618,11 +618,11 @@ public class ProxyGenerator { ...@@ -618,11 +618,11 @@ public class ProxyGenerator {
* List of return types that are not yet known to be * List of return types that are not yet known to be
* assignable from ("covered" by) any of the others. * assignable from ("covered" by) any of the others.
*/ */
LinkedList<Class> uncoveredReturnTypes = new LinkedList<Class>(); LinkedList<Class<?>> uncoveredReturnTypes = new LinkedList<Class<?>>();
nextNewReturnType: nextNewReturnType:
for (ProxyMethod pm : methods) { for (ProxyMethod pm : methods) {
Class newReturnType = pm.returnType; Class<?> newReturnType = pm.returnType;
if (newReturnType.isPrimitive()) { if (newReturnType.isPrimitive()) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"methods with same signature " + "methods with same signature " +
...@@ -637,9 +637,9 @@ public class ProxyGenerator { ...@@ -637,9 +637,9 @@ public class ProxyGenerator {
* Compare the new return type to the existing uncovered * Compare the new return type to the existing uncovered
* return types. * return types.
*/ */
ListIterator<Class> liter = uncoveredReturnTypes.listIterator(); ListIterator<Class<?>> liter = uncoveredReturnTypes.listIterator();
while (liter.hasNext()) { while (liter.hasNext()) {
Class uncoveredReturnType = liter.next(); Class<?> uncoveredReturnType = liter.next();
/* /*
* If an existing uncovered return type is assignable * If an existing uncovered return type is assignable
...@@ -944,10 +944,10 @@ public class ProxyGenerator { ...@@ -944,10 +944,10 @@ public class ProxyGenerator {
tryEnd = pc = (short) minfo.code.size(); tryEnd = pc = (short) minfo.code.size();
List<Class> catchList = computeUniqueCatchList(exceptionTypes); List<Class<?>> catchList = computeUniqueCatchList(exceptionTypes);
if (catchList.size() > 0) { if (catchList.size() > 0) {
for (Class ex : catchList) { for (Class<?> ex : catchList) {
minfo.exceptionTable.add(new ExceptionTableEntry( minfo.exceptionTable.add(new ExceptionTableEntry(
tryBegin, tryEnd, pc, tryBegin, tryEnd, pc,
cp.getClass(dotToSlash(ex.getName())))); cp.getClass(dotToSlash(ex.getName()))));
...@@ -1521,8 +1521,9 @@ public class ProxyGenerator { ...@@ -1521,8 +1521,9 @@ public class ProxyGenerator {
* declared exceptions from duplicate methods inherited from * declared exceptions from duplicate methods inherited from
* different interfaces. * different interfaces.
*/ */
private static void collectCompatibleTypes(Class[] from, Class[] with, private static void collectCompatibleTypes(Class<?>[] from,
List<Class> list) Class<?>[] with,
List<Class<?>> list)
{ {
for (int i = 0; i < from.length; i++) { for (int i = 0; i < from.length; i++) {
if (!list.contains(from[i])) { if (!list.contains(from[i])) {
...@@ -1557,8 +1558,8 @@ public class ProxyGenerator { ...@@ -1557,8 +1558,8 @@ public class ProxyGenerator {
* given list of declared exceptions, indicating that no exceptions * given list of declared exceptions, indicating that no exceptions
* need to be caught. * need to be caught.
*/ */
private static List<Class> computeUniqueCatchList(Class[] exceptions) { private static List<Class<?>> computeUniqueCatchList(Class<?>[] exceptions) {
List<Class> uniqueList = new ArrayList<Class>(); List<Class<?>> uniqueList = new ArrayList<Class<?>>();
// unique exceptions to catch // unique exceptions to catch
uniqueList.add(Error.class); // always catch/rethrow these uniqueList.add(Error.class); // always catch/rethrow these
...@@ -1566,7 +1567,7 @@ public class ProxyGenerator { ...@@ -1566,7 +1567,7 @@ public class ProxyGenerator {
nextException: nextException:
for (int i = 0; i < exceptions.length; i++) { for (int i = 0; i < exceptions.length; i++) {
Class ex = exceptions[i]; Class<?> ex = exceptions[i];
if (ex.isAssignableFrom(Throwable.class)) { if (ex.isAssignableFrom(Throwable.class)) {
/* /*
* If Throwable is declared to be thrown by the proxy method, * If Throwable is declared to be thrown by the proxy method,
...@@ -1586,7 +1587,7 @@ public class ProxyGenerator { ...@@ -1586,7 +1587,7 @@ public class ProxyGenerator {
* 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();) {
Class ex2 = uniqueList.get(j); Class<?> ex2 = uniqueList.get(j);
if (ex2.isAssignableFrom(ex)) { if (ex2.isAssignableFrom(ex)) {
/* /*
* if a superclass of this exception is already on * if a superclass of this exception is already on
......
...@@ -86,16 +86,16 @@ public class URLClassPath { ...@@ -86,16 +86,16 @@ public class URLClassPath {
} }
/* The original search path of URLs. */ /* The original search path of URLs. */
private ArrayList path = new ArrayList(); private ArrayList<URL> path = new ArrayList<URL>();
/* The stack of unopened URLs */ /* The stack of unopened URLs */
Stack urls = new Stack(); Stack<URL> urls = new Stack<URL>();
/* The resulting search path of Loaders */ /* The resulting search path of Loaders */
ArrayList loaders = new ArrayList(); ArrayList<Loader> loaders = new ArrayList<Loader>();
/* Map of each URL opened to its corresponding Loader */ /* Map of each URL opened to its corresponding Loader */
HashMap lmap = new HashMap(); HashMap<URL, Loader> lmap = new HashMap<URL, Loader>();
/* The jar protocol handler to use when creating new URLs */ /* The jar protocol handler to use when creating new URLs */
private URLStreamHandler jarHandler; private URLStreamHandler jarHandler;
...@@ -146,7 +146,7 @@ public class URLClassPath { ...@@ -146,7 +146,7 @@ public class URLClassPath {
*/ */
public URL[] getURLs() { public URL[] getURLs() {
synchronized (urls) { synchronized (urls) {
return (URL[])path.toArray(new URL[path.size()]); return path.toArray(new URL[path.size()]);
} }
} }
...@@ -200,9 +200,9 @@ public class URLClassPath { ...@@ -200,9 +200,9 @@ public class URLClassPath {
* @param name the resource name * @param name the resource name
* @return an Enumeration of all the urls having the specified name * @return an Enumeration of all the urls having the specified name
*/ */
public Enumeration findResources(final String name, public Enumeration<URL> findResources(final String name,
final boolean check) { final boolean check) {
return new Enumeration() { return new Enumeration<URL>() {
private int index = 0; private int index = 0;
private URL url = null; private URL url = null;
...@@ -225,7 +225,7 @@ public class URLClassPath { ...@@ -225,7 +225,7 @@ public class URLClassPath {
return next(); return next();
} }
public Object nextElement() { public URL nextElement() {
if (!next()) { if (!next()) {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
...@@ -247,9 +247,9 @@ public class URLClassPath { ...@@ -247,9 +247,9 @@ public class URLClassPath {
* @param name the resource name * @param name the resource name
* @return an Enumeration of all the resources having the specified name * @return an Enumeration of all the resources having the specified name
*/ */
public Enumeration getResources(final String name, public Enumeration<Resource> getResources(final String name,
final boolean check) { final boolean check) {
return new Enumeration() { return new Enumeration<Resource>() {
private int index = 0; private int index = 0;
private Resource res = null; private Resource res = null;
...@@ -272,7 +272,7 @@ public class URLClassPath { ...@@ -272,7 +272,7 @@ public class URLClassPath {
return next(); return next();
} }
public Object nextElement() { public Resource nextElement() {
if (!next()) { if (!next()) {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
...@@ -283,7 +283,7 @@ public class URLClassPath { ...@@ -283,7 +283,7 @@ public class URLClassPath {
}; };
} }
public Enumeration getResources(final String name) { public Enumeration<Resource> getResources(final String name) {
return getResources(name, true); return getResources(name, true);
} }
...@@ -302,7 +302,7 @@ public class URLClassPath { ...@@ -302,7 +302,7 @@ public class URLClassPath {
if (urls.empty()) { if (urls.empty()) {
return null; return null;
} else { } else {
url = (URL)urls.pop(); url = urls.pop();
} }
} }
// Skip this URL if it already has a Loader. (Loader // Skip this URL if it already has a Loader. (Loader
...@@ -329,7 +329,7 @@ public class URLClassPath { ...@@ -329,7 +329,7 @@ public class URLClassPath {
loaders.add(loader); loaders.add(loader);
lmap.put(url, loader); lmap.put(url, loader);
} }
return (Loader)loaders.get(index); return loaders.get(index);
} }
/* /*
...@@ -337,9 +337,9 @@ public class URLClassPath { ...@@ -337,9 +337,9 @@ public class URLClassPath {
*/ */
private Loader getLoader(final URL url) throws IOException { private Loader getLoader(final URL url) throws IOException {
try { try {
return (Loader)java.security.AccessController.doPrivileged return java.security.AccessController.doPrivileged(
(new java.security.PrivilegedExceptionAction() { new java.security.PrivilegedExceptionAction<Loader>() {
public Object run() throws IOException { public Loader run() throws IOException {
String file = url.getFile(); String file = url.getFile();
if (file != null && file.endsWith("/")) { if (file != null && file.endsWith("/")) {
if ("file".equals(url.getProtocol())) { if ("file".equals(url.getProtocol())) {
...@@ -561,13 +561,14 @@ public class URLClassPath { ...@@ -561,13 +561,14 @@ public class URLClassPath {
private JarIndex index; private JarIndex index;
private MetaIndex metaIndex; private MetaIndex metaIndex;
private URLStreamHandler handler; private URLStreamHandler handler;
private HashMap lmap; private HashMap<URL, Loader> lmap;
/* /*
* Creates a new JarLoader for the specified URL referring to * Creates a new JarLoader for the specified URL referring to
* a JAR file. * a JAR file.
*/ */
JarLoader(URL url, URLStreamHandler jarHandler, HashMap loaderMap) JarLoader(URL url, URLStreamHandler jarHandler,
HashMap<URL, Loader> loaderMap)
throws IOException throws IOException
{ {
super(new URL("jar", "", -1, url + "!/", jarHandler)); super(new URL("jar", "", -1, url + "!/", jarHandler));
...@@ -615,8 +616,8 @@ public class URLClassPath { ...@@ -615,8 +616,8 @@ public class URLClassPath {
if (jar == null) { if (jar == null) {
try { try {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedExceptionAction() { new java.security.PrivilegedExceptionAction<Void>() {
public Object run() throws IOException { public Void run() throws IOException {
if (DEBUG) { if (DEBUG) {
System.err.println("Opening " + csu); System.err.println("Opening " + csu);
Thread.dumpStack(); Thread.dumpStack();
...@@ -732,9 +733,9 @@ public class URLClassPath { ...@@ -732,9 +733,9 @@ public class URLClassPath {
String entryName; String entryName;
ZipEntry entry; ZipEntry entry;
Enumeration enum_ = jar.entries(); Enumeration<JarEntry> enum_ = jar.entries();
while (enum_.hasMoreElements()) { while (enum_.hasMoreElements()) {
entry = (ZipEntry)enum_.nextElement(); entry = enum_.nextElement();
entryName = entry.getName(); entryName = entry.getName();
if((pos = entryName.lastIndexOf("/")) != -1) if((pos = entryName.lastIndexOf("/")) != -1)
entryName = entryName.substring(0, pos); entryName = entryName.substring(0, pos);
...@@ -778,7 +779,7 @@ public class URLClassPath { ...@@ -778,7 +779,7 @@ public class URLClassPath {
if (index == null) if (index == null)
return null; return null;
HashSet visited = new HashSet(); HashSet<URL> visited = new HashSet<URL>();
return getResource(name, check, visited); return getResource(name, check, visited);
} }
...@@ -790,7 +791,7 @@ public class URLClassPath { ...@@ -790,7 +791,7 @@ public class URLClassPath {
* non-existent resource * non-existent resource
*/ */
Resource getResource(final String name, boolean check, Resource getResource(final String name, boolean check,
Set visited) { Set<URL> visited) {
Resource res; Resource res;
Object[] jarFiles; Object[] jarFiles;
...@@ -819,10 +820,9 @@ public class URLClassPath { ...@@ -819,10 +820,9 @@ public class URLClassPath {
/* no loader has been set up for this jar file /* no loader has been set up for this jar file
* before * before
*/ */
newLoader = (JarLoader) newLoader = AccessController.doPrivileged(
AccessController.doPrivileged( new PrivilegedExceptionAction<JarLoader>() {
new PrivilegedExceptionAction() { public JarLoader run() throws IOException {
public Object run() throws IOException {
return new JarLoader(url, handler, return new JarLoader(url, handler,
lmap); lmap);
} }
......
...@@ -42,8 +42,8 @@ public class NetProperties { ...@@ -42,8 +42,8 @@ public class NetProperties {
static private Properties props = new Properties(); static private Properties props = new Properties();
static { static {
AccessController.doPrivileged( AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction<Void>() {
public Object run() { public Void run() {
loadDefaultProperties(); loadDefaultProperties();
return null; return null;
}}); }});
......
...@@ -64,8 +64,8 @@ public class NetworkClient { ...@@ -64,8 +64,8 @@ public class NetworkClient {
final String encs[] = { null }; final String encs[] = { null };
AccessController.doPrivileged( AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction<Void>() {
public Object run() { public Void run() {
vals[0] = Integer.getInteger("sun.net.client.defaultReadTimeout", 0).intValue(); vals[0] = Integer.getInteger("sun.net.client.defaultReadTimeout", 0).intValue();
vals[1] = Integer.getInteger("sun.net.client.defaultConnectTimeout", 0).intValue(); vals[1] = Integer.getInteger("sun.net.client.defaultConnectTimeout", 0).intValue();
encs[0] = System.getProperty("file.encoding", "ISO8859_1"); encs[0] = System.getProperty("file.encoding", "ISO8859_1");
...@@ -152,9 +152,9 @@ public class NetworkClient { ...@@ -152,9 +152,9 @@ public class NetworkClient {
Socket s; Socket s;
if (proxy != null) { if (proxy != null) {
if (proxy.type() == Proxy.Type.SOCKS) { if (proxy.type() == Proxy.Type.SOCKS) {
s = (Socket) AccessController.doPrivileged( s = AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction<Socket>() {
public Object run() { public Socket run() {
return new Socket(proxy); return new Socket(proxy);
}}); }});
} else } else
......
...@@ -117,8 +117,8 @@ public class FtpClient extends TransferProtocolClient { ...@@ -117,8 +117,8 @@ public class FtpClient extends TransferProtocolClient {
public static int getFtpProxyPort() { public static int getFtpProxyPort() {
final int result[] = {80}; final int result[] = {80};
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Void>() {
public Object run() { public Void run() {
String tmp = System.getProperty("ftp.proxyPort"); String tmp = System.getProperty("ftp.proxyPort");
if (tmp == null) { if (tmp == null) {
...@@ -343,9 +343,9 @@ public class FtpClient extends TransferProtocolClient { ...@@ -343,9 +343,9 @@ public class FtpClient extends TransferProtocolClient {
Socket s; Socket s;
if (proxy != null) { if (proxy != null) {
if (proxy.type() == Proxy.Type.SOCKS) { if (proxy.type() == Proxy.Type.SOCKS) {
s = (Socket) AccessController.doPrivileged( s = AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction<Socket>() {
public Object run() { public Socket run() {
return new Socket(proxy); return new Socket(proxy);
}}); }});
} else } else
......
...@@ -82,9 +82,9 @@ public class DefaultProxySelector extends ProxySelector { ...@@ -82,9 +82,9 @@ public class DefaultProxySelector extends ProxySelector {
static { static {
final String key = "java.net.useSystemProxies"; final String key = "java.net.useSystemProxies";
Boolean b = (Boolean) AccessController.doPrivileged( Boolean b = AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction<Boolean>() {
public Object run() { public Boolean run() {
return NetProperties.getBoolean(key); return NetProperties.getBoolean(key);
}}); }});
if (b != null && b.booleanValue()) { if (b != null && b.booleanValue()) {
...@@ -197,9 +197,9 @@ public class DefaultProxySelector extends ProxySelector { ...@@ -197,9 +197,9 @@ public class DefaultProxySelector extends ProxySelector {
* System properties it does help having only 1 call to doPrivileged. * System properties it does help having only 1 call to doPrivileged.
* Be mindful what you do in here though! * Be mindful what you do in here though!
*/ */
Proxy p = (Proxy) AccessController.doPrivileged( Proxy p = AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction<Proxy>() {
public Object run() { public Proxy run() {
int i, j; int i, j;
String phost = null; String phost = null;
int pport = 0; int pport = 0;
......
...@@ -138,7 +138,7 @@ class MessageHeader { ...@@ -138,7 +138,7 @@ class MessageHeader {
return null; return null;
} }
class HeaderIterator implements Iterator { class HeaderIterator implements Iterator<String> {
int index = 0; int index = 0;
int next = -1; int next = -1;
String key; String key;
...@@ -165,7 +165,7 @@ class MessageHeader { ...@@ -165,7 +165,7 @@ class MessageHeader {
return false; return false;
} }
} }
public Object next() { public String next() {
synchronized (lock) { synchronized (lock) {
if (haveNext) { if (haveNext) {
haveNext = false; haveNext = false;
...@@ -187,17 +187,17 @@ class MessageHeader { ...@@ -187,17 +187,17 @@ class MessageHeader {
* return an Iterator that returns all values of a particular * return an Iterator that returns all values of a particular
* key in sequence * key in sequence
*/ */
public Iterator multiValueIterator (String k) { public Iterator<String> multiValueIterator (String k) {
return new HeaderIterator (k, this); return new HeaderIterator (k, this);
} }
public synchronized Map getHeaders() { public synchronized Map<String, List<String>> getHeaders() {
return getHeaders(null); return getHeaders(null);
} }
public synchronized Map getHeaders(String[] excludeList) { public synchronized Map<String, List<String>> getHeaders(String[] excludeList) {
boolean skipIt = false; boolean skipIt = false;
Map m = new HashMap(); Map<String, List<String>> m = new HashMap<String, List<String>>();
for (int i = nkeys; --i >= 0;) { for (int i = nkeys; --i >= 0;) {
if (excludeList != null) { if (excludeList != null) {
// check if the key is in the excludeList. // check if the key is in the excludeList.
...@@ -211,9 +211,9 @@ class MessageHeader { ...@@ -211,9 +211,9 @@ class MessageHeader {
} }
} }
if (!skipIt) { if (!skipIt) {
List l = (List)m.get(keys[i]); List<String> l = m.get(keys[i]);
if (l == null) { if (l == null) {
l = new ArrayList(); l = new ArrayList<String>();
m.put(keys[i], l); m.put(keys[i], l);
} }
l.add(values[i]); l.add(values[i]);
...@@ -223,11 +223,8 @@ class MessageHeader { ...@@ -223,11 +223,8 @@ class MessageHeader {
} }
} }
Set keySet = m.keySet(); for (String key : m.keySet()) {
for (Iterator i = keySet.iterator(); i.hasNext();) { m.put(key, Collections.unmodifiableList(m.get(key)));
Object key = i.next();
List l = (List)m.get(key);
m.put(key, Collections.unmodifiableList(l));
} }
return Collections.unmodifiableMap(m); return Collections.unmodifiableMap(m);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册