6600143: Remove another 450 unnecessary casts
authormartin
Mon, 10 Mar 2008 15:07:09 -0700
changeset 51 6fe31bc95bbc
parent 50 a437b3f9d7f4
child 54 a007508f7193
6600143: Remove another 450 unnecessary casts Reviewed-by: alanb, iris, lmalvent, bristor, peterjones, darcy, wetmore
jdk/make/tools/src/build/tools/jdwpgen/CommandNode.java
jdk/make/tools/src/build/tools/jdwpgen/ConstantSetNode.java
jdk/make/tools/src/build/tools/jdwpgen/RepeatNode.java
jdk/src/share/classes/com/sun/tools/example/debug/bdi/EventRequestSpec.java
jdk/src/share/classes/com/sun/tools/example/debug/bdi/EventRequestSpecList.java
jdk/src/share/classes/com/sun/tools/example/debug/bdi/ExecutionManager.java
jdk/src/share/classes/com/sun/tools/example/debug/bdi/JDIEventSource.java
jdk/src/share/classes/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java
jdk/src/share/classes/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java
jdk/src/share/classes/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java
jdk/src/share/classes/com/sun/tools/example/debug/bdi/ThreadIterator.java
jdk/src/share/classes/com/sun/tools/example/debug/expr/LValue.java
jdk/src/share/classes/com/sun/tools/example/debug/gui/ClassTreeTool.java
jdk/src/share/classes/com/sun/tools/example/debug/gui/CommandInterpreter.java
jdk/src/share/classes/com/sun/tools/example/debug/gui/JDBFileFilter.java
jdk/src/share/classes/com/sun/tools/example/debug/gui/LaunchTool.java
jdk/src/share/classes/com/sun/tools/example/debug/gui/SearchPath.java
jdk/src/share/classes/com/sun/tools/example/debug/gui/SourceManager.java
jdk/src/share/classes/com/sun/tools/example/debug/gui/SourceModel.java
jdk/src/share/classes/com/sun/tools/example/debug/gui/StackTraceTool.java
jdk/src/share/classes/com/sun/tools/example/debug/gui/ThreadTreeTool.java
jdk/src/share/classes/com/sun/tools/example/debug/tty/BreakpointSpec.java
jdk/src/share/classes/com/sun/tools/example/debug/tty/Commands.java
jdk/src/share/classes/com/sun/tools/example/debug/tty/Env.java
jdk/src/share/classes/com/sun/tools/example/debug/tty/EventHandler.java
jdk/src/share/classes/com/sun/tools/example/debug/tty/EventRequestSpec.java
jdk/src/share/classes/com/sun/tools/example/debug/tty/EventRequestSpecList.java
jdk/src/share/classes/com/sun/tools/example/debug/tty/SourceMapper.java
jdk/src/share/classes/com/sun/tools/example/debug/tty/TTY.java
jdk/src/share/classes/com/sun/tools/example/debug/tty/ThreadGroupIterator.java
jdk/src/share/classes/com/sun/tools/example/debug/tty/ThreadInfo.java
jdk/src/share/classes/com/sun/tools/example/debug/tty/ThreadIterator.java
jdk/src/share/classes/com/sun/tools/example/debug/tty/VMConnection.java
jdk/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java
jdk/src/share/classes/com/sun/tools/hat/internal/server/PlatformClasses.java
jdk/src/share/classes/com/sun/tools/jdi/AbstractLauncher.java
jdk/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java
jdk/src/share/classes/com/sun/tools/jdi/ConcreteMethodImpl.java
jdk/src/share/classes/com/sun/tools/jdi/EventSetImpl.java
jdk/src/share/classes/com/sun/tools/jdi/JNITypeParser.java
jdk/src/share/classes/com/sun/tools/jdi/MethodImpl.java
jdk/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java
jdk/src/share/classes/com/sun/tools/jdi/PacketStream.java
jdk/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java
jdk/src/share/classes/com/sun/tools/jdi/SDE.java
jdk/src/share/classes/com/sun/tools/jdi/StackFrameImpl.java
jdk/src/share/classes/com/sun/tools/jdi/TargetVM.java
jdk/src/share/classes/com/sun/tools/jdi/ThreadGroupReferenceImpl.java
jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java
jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerImpl.java
jdk/src/share/classes/java/io/ObjectInputStream.java
jdk/src/share/classes/java/io/ObjectStreamClass.java
jdk/src/share/classes/java/lang/Class.java
jdk/src/share/classes/java/lang/ClassLoader.java
jdk/src/share/classes/java/lang/Compiler.java
jdk/src/share/classes/java/lang/Long.java
jdk/src/share/classes/java/lang/Package.java
jdk/src/share/classes/java/lang/ref/Finalizer.java
jdk/src/share/classes/java/lang/reflect/AccessibleObject.java
jdk/src/share/classes/java/lang/reflect/Modifier.java
jdk/src/share/classes/java/lang/reflect/Proxy.java
jdk/src/share/classes/java/net/DatagramSocket.java
jdk/src/share/classes/java/net/ServerSocket.java
jdk/src/share/classes/java/net/Socket.java
jdk/src/share/classes/java/net/SocksSocketImpl.java
jdk/src/share/classes/java/net/URLClassLoader.java
jdk/src/share/classes/java/nio/channels/spi/SelectorProvider.java
jdk/src/share/classes/java/rmi/activation/ActivationGroupDesc.java
jdk/src/share/classes/java/rmi/dgc/VMID.java
jdk/src/share/classes/java/security/cert/TrustAnchor.java
jdk/src/share/classes/java/security/cert/X509CertSelector.java
jdk/src/share/classes/java/util/ArrayList.java
jdk/src/share/classes/java/util/Arrays.java
jdk/src/share/classes/java/util/EnumMap.java
jdk/src/share/classes/java/util/IdentityHashMap.java
jdk/src/share/classes/java/util/JumboEnumSet.java
jdk/src/share/classes/java/util/Random.java
jdk/src/share/classes/java/util/TreeSet.java
jdk/src/share/classes/java/util/prefs/AbstractPreferences.java
jdk/src/share/classes/java/util/regex/Matcher.java
jdk/src/share/classes/javax/rmi/ssl/SslRMIClientSocketFactory.java
jdk/src/share/classes/javax/rmi/ssl/SslRMIServerSocketFactory.java
jdk/src/share/classes/javax/security/auth/kerberos/KerberosTicket.java
jdk/src/share/classes/javax/security/auth/kerberos/KeyImpl.java
jdk/src/share/classes/sun/misc/ClassFileTransformer.java
jdk/src/share/classes/sun/misc/Cleaner.java
jdk/src/share/classes/sun/misc/ExtensionDependency.java
jdk/src/share/classes/sun/misc/GC.java
jdk/src/share/classes/sun/misc/Launcher.java
jdk/src/share/classes/sun/misc/PerformanceLogger.java
jdk/src/share/classes/sun/misc/ProxyGenerator.java
jdk/src/share/classes/sun/misc/URLClassPath.java
jdk/src/share/classes/sun/net/NetProperties.java
jdk/src/share/classes/sun/net/NetworkClient.java
jdk/src/share/classes/sun/net/ftp/FtpClient.java
jdk/src/share/classes/sun/net/spi/DefaultProxySelector.java
jdk/src/share/classes/sun/net/www/MessageHeader.java
jdk/src/share/classes/sun/net/www/MimeTable.java
jdk/src/share/classes/sun/net/www/http/HttpClient.java
jdk/src/share/classes/sun/net/www/http/KeepAliveCache.java
jdk/src/share/classes/sun/net/www/http/KeepAliveStream.java
jdk/src/share/classes/sun/net/www/http/KeepAliveStreamCleaner.java
jdk/src/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java
jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
jdk/src/share/classes/sun/net/www/protocol/jar/URLJarFile.java
jdk/src/share/classes/sun/nio/ch/Reflect.java
jdk/src/share/classes/sun/nio/ch/SocketAdaptor.java
jdk/src/share/classes/sun/nio/ch/Util.java
jdk/src/share/classes/sun/reflect/ClassDefiner.java
jdk/src/share/classes/sun/reflect/MethodAccessorGenerator.java
jdk/src/share/classes/sun/reflect/ReflectionFactory.java
jdk/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
jdk/src/share/classes/sun/reflect/misc/MethodUtil.java
jdk/src/share/classes/sun/rmi/log/ReliableLog.java
jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java
jdk/src/share/classes/sun/rmi/rmic/RemoteClass.java
jdk/src/share/classes/sun/rmi/rmic/newrmic/jrmp/RemoteClass.java
jdk/src/share/classes/sun/rmi/runtime/Log.java
jdk/src/share/classes/sun/rmi/server/LoaderHandler.java
jdk/src/share/classes/sun/rmi/server/MarshalInputStream.java
jdk/src/share/classes/sun/rmi/server/MarshalOutputStream.java
jdk/src/share/classes/sun/rmi/server/Util.java
jdk/src/share/classes/sun/rmi/server/WeakClassHashMap.java
jdk/src/share/classes/sun/rmi/transport/DGCClient.java
jdk/src/share/classes/sun/rmi/transport/Target.java
jdk/src/share/classes/sun/rmi/transport/Transport.java
jdk/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java
jdk/src/share/classes/sun/rmi/transport/proxy/HttpSendSocket.java
jdk/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java
jdk/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java
jdk/src/share/classes/sun/security/jgss/GSSManagerImpl.java
jdk/src/share/classes/sun/security/jgss/krb5/InitSecContextToken.java
jdk/src/share/classes/sun/security/ssl/CipherSuite.java
jdk/src/share/classes/sun/security/ssl/DHCrypt.java
jdk/src/share/classes/sun/security/ssl/JsseJce.java
jdk/src/share/classes/sun/security/ssl/ProtocolList.java
jdk/src/share/classes/sun/security/ssl/SSLSessionImpl.java
jdk/src/share/classes/sun/security/ssl/SessionId.java
jdk/src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java
jdk/src/share/classes/sun/security/x509/CertificatePolicySet.java
jdk/src/share/classes/sun/security/x509/X509Cert.java
jdk/src/share/classes/sun/tools/jar/JarVerifierStream.java
jdk/src/share/classes/sun/tools/native2ascii/N2AFilter.java
jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java
jdk/src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java
jdk/src/solaris/classes/sun/security/provider/NativePRNG.java
jdk/src/windows/classes/sun/security/mscapi/SunMSCAPI.java
--- a/jdk/make/tools/src/build/tools/jdwpgen/CommandNode.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/make/tools/src/build/tools/jdwpgen/CommandNode.java	Mon Mar 10 15:07:09 2008 -0700
@@ -32,9 +32,9 @@
 
     void constrain(Context ctx) {
         if (components.size() == 3) {
-            Node out = (Node)components.get(0);
-            Node reply = (Node)components.get(1);
-            Node error = (Node)components.get(2);
+            Node out   = components.get(0);
+            Node reply = components.get(1);
+            Node error = components.get(2);
             if (!(out instanceof OutNode)) {
                 error("Expected 'Out' item, got: " + out);
             }
@@ -45,7 +45,7 @@
                 error("Expected 'ErrorSet' item, got: " + error);
             }
         } else if (components.size() == 1) {
-            Node evt = (Node)components.get(0);
+            Node evt = components.get(0);
             if (!(evt instanceof EventNode)) {
                 error("Expected 'Event' item, got: " + evt);
             }
--- a/jdk/make/tools/src/build/tools/jdwpgen/ConstantSetNode.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/make/tools/src/build/tools/jdwpgen/ConstantSetNode.java	Mon Mar 10 15:07:09 2008 -0700
@@ -98,7 +98,7 @@
         if (constantMap == null) {
             return "";
         }
-        String com = (String) constantMap.get(key);
+        String com = constantMap.get(key);
         if(com == null){
             return "";
         } else {
--- a/jdk/make/tools/src/build/tools/jdwpgen/RepeatNode.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/make/tools/src/build/tools/jdwpgen/RepeatNode.java	Mon Mar 10 15:07:09 2008 -0700
@@ -37,7 +37,7 @@
         if (components.size() != 1) {
             error("Repeat must have exactly one member, use Group for more");
         }
-        member = (Node)(components.get(0));
+        member = components.get(0);
         if (!(member instanceof TypeNode)) {
             error("Repeat member must be type specifier");
         }
--- a/jdk/src/share/classes/com/sun/tools/example/debug/bdi/EventRequestSpec.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/bdi/EventRequestSpec.java	Mon Mar 10 15:07:09 2008 -0700
@@ -91,9 +91,7 @@
 
     void attemptImmediateResolve(VirtualMachine vm) {
         // try to resolve immediately
-        Iterator iter = vm.allClasses().iterator();
-        while (iter.hasNext()) {
-            ReferenceType refType = (ReferenceType)iter.next();
+        for (ReferenceType refType : vm.allClasses()) {
             if (refSpec.matches(refType)) {
                 try {
                     resolve(refType);
--- a/jdk/src/share/classes/com/sun/tools/example/debug/bdi/EventRequestSpecList.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/bdi/EventRequestSpecList.java	Mon Mar 10 15:07:09 2008 -0700
@@ -47,9 +47,8 @@
      */
     void resolve(ReferenceType refType) {
         synchronized(eventRequestSpecs) {
-            Iterator iter = eventRequestSpecs.iterator();
-            while (iter.hasNext()) {
-                ((EventRequestSpec)iter.next()).attemptResolve(refType);
+            for (EventRequestSpec spec : eventRequestSpecs) {
+                spec.attemptResolve(refType);
              }
         }
     }
@@ -79,7 +78,7 @@
 
     BreakpointSpec
     createMethodBreakpoint(String classPattern,
-                           String methodId, List methodArgs) {
+                           String methodId, List<String> methodArgs) {
         ReferenceTypeSpec refSpec =
             new PatternReferenceTypeSpec(classPattern);
         return new MethodBreakpointSpec(this, refSpec,
@@ -132,47 +131,48 @@
 
     // --------  notify routines --------------------
 
-    private Vector specListeners() {
-        return (Vector)runtime.specListeners.clone();
+    @SuppressWarnings("unchecked")
+    private Vector<SpecListener> specListeners() {
+        return (Vector<SpecListener>)runtime.specListeners.clone();
     }
 
     void notifySet(EventRequestSpec spec) {
-        Vector l = specListeners();
+        Vector<SpecListener> l = specListeners();
         SpecEvent evt = new SpecEvent(spec);
         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) {
-        Vector l = specListeners();
+        Vector<SpecListener> l = specListeners();
         SpecEvent evt = new SpecEvent(spec);
         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) {
-        Vector l = specListeners();
+        Vector<SpecListener> l = specListeners();
         SpecEvent evt = new SpecEvent(spec);
         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) {
-        Vector l = specListeners();
+        Vector<SpecListener> l = specListeners();
         SpecEvent evt = new SpecEvent(spec);
         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) {
-        Vector l = specListeners();
+        Vector<SpecListener> l = specListeners();
         SpecErrorEvent evt = new SpecErrorEvent(spec, exc);
         for (int i = 0; i < l.size(); i++) {
-            spec.notifyError((SpecListener)l.elementAt(i), evt);
+            spec.notifyError(l.elementAt(i), evt);
         }
     }
 }
--- a/jdk/src/share/classes/com/sun/tools/example/debug/bdi/ExecutionManager.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/bdi/ExecutionManager.java	Mon Mar 10 15:07:09 2008 -0700
@@ -232,10 +232,7 @@
         if (pattern.startsWith("*.")) {
             // Wildcard matches any leading package name.
             pattern = pattern.substring(1);
-            List classes = vm().allClasses();
-            Iterator iter = classes.iterator();
-            while (iter.hasNext()) {
-                ReferenceType type = ((ReferenceType)iter.next());
+            for (ReferenceType type : vm().allClasses()) {
                 if (type.name().endsWith(pattern)) {
                     result.add(type);
                 }
@@ -278,7 +275,7 @@
     public ThreadGroupReference systemThreadGroup()
                                                 throws NoSessionException {
         ensureActiveSession();
-        return (ThreadGroupReference)vm().topLevelThreadGroups().get(0);
+        return vm().topLevelThreadGroups().get(0);
     }
 
     /*
@@ -349,10 +346,9 @@
          * attach sessions.
          */
         VirtualMachineManager mgr = Bootstrap.virtualMachineManager();
-        List connectors = mgr.attachingConnectors();
-        AttachingConnector connector = (AttachingConnector)connectors.get(0);
+        AttachingConnector connector = mgr.attachingConnectors().get(0);
         Map<String, Connector.Argument> arguments = connector.defaultArguments();
-        ((Connector.Argument)arguments.get("port")).setValue(portName);
+        arguments.get("port").setValue(portName);
 
         Session newSession = internalAttach(connector, arguments);
         if (newSession != null) {
@@ -504,10 +500,7 @@
          * if so, it gets removed here.
          */
          EventRequestManager mgr = vm().eventRequestManager();
-         List requests = mgr.stepRequests();
-         Iterator iter = requests.iterator();
-         while (iter.hasNext()) {
-             StepRequest request = (StepRequest)iter.next();
+         for (StepRequest request : mgr.stepRequests()) {
              if (request.thread().equals(thread)) {
                  mgr.deleteEventRequest(request);
                  break;
@@ -591,7 +584,7 @@
         if (session == null || thread == null) {
             return null;
         }
-        ThreadInfo info = (ThreadInfo)threadInfoMap.get(thread);
+        ThreadInfo info = threadInfoMap.get(thread);
         if (info == null) {
             //### Should not hardcode initial frame count and prefetch here!
             //info = new ThreadInfo(thread, 10, 10);
@@ -607,24 +600,22 @@
 
      void validateThreadInfo() {
         session.interrupted = true;
-        Iterator iter = threadInfoList.iterator();
-            while (iter.hasNext()) {
-                ((ThreadInfo)iter.next()).validate();
+        for (ThreadInfo threadInfo : threadInfoList) {
+            threadInfo.validate();
             }
     }
 
     private void invalidateThreadInfo() {
         if (session != null) {
             session.interrupted = false;
-            Iterator iter = threadInfoList.iterator();
-            while (iter.hasNext()) {
-                ((ThreadInfo)iter.next()).invalidate();
+            for (ThreadInfo threadInfo : threadInfoList) {
+                threadInfo.invalidate();
             }
         }
     }
 
     void removeThreadInfo(ThreadReference thread) {
-        ThreadInfo info = (ThreadInfo)threadInfoMap.get(thread);
+        ThreadInfo info = threadInfoMap.get(thread);
         if (info != null) {
             info.invalidate();
             threadInfoMap.remove(thread);
@@ -702,7 +693,7 @@
                         while (inputBuffer.size() < 1) {
                             inputLock.wait();
                         }
-                        line = (String)inputBuffer.removeLast();
+                        line = inputBuffer.removeLast();
                     } catch (InterruptedException e) {}
                 }
             }
@@ -774,7 +765,7 @@
 
     public BreakpointSpec
     createMethodBreakpoint(String classPattern,
-                           String methodId, List methodArgs) {
+                           String methodId, List<String> methodArgs) {
         return specList.createMethodBreakpoint(classPattern,
                                                  methodId, methodArgs);
     }
@@ -811,7 +802,7 @@
         specList.install(spec, vm());
     }
 
-    public List eventRequestSpecs() {
+    public List<EventRequestSpec> eventRequestSpecs() {
         return specList.eventRequestSpecs();
     }
 }
--- a/jdk/src/share/classes/com/sun/tools/example/debug/bdi/JDIEventSource.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/bdi/JDIEventSource.java	Mon Mar 10 15:07:09 2008 -0700
@@ -82,9 +82,7 @@
                 boolean interrupted = es.suspendedAll();
                 es.notify(firstListener);
                 boolean wantInterrupt = JDIEventSource.this.wantInterrupt;
-                for (Iterator it = session.runtime.jdiListeners.iterator();
-                     it.hasNext(); ) {
-                    JDIListener jl = (JDIListener)it.next();
+                for (JDIListener jl : session.runtime.jdiListeners) {
                     es.notify(jl);
                 }
                 if (interrupted && !wantInterrupt) {
--- a/jdk/src/share/classes/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java	Mon Mar 10 15:07:09 2008 -0700
@@ -58,12 +58,12 @@
                                             LineNotFoundException {
         Location location = null;
         try {
-            List locs = clazz.locationsOfLine(lineNumber());
+            List<Location> locs = clazz.locationsOfLine(lineNumber());
             if (locs.size() == 0) {
                 throw new LineNotFoundException();
             }
             // TODO handle multiple locations
-            location = (Location)locs.get(0);
+            location = locs.get(0);
             if (location.method() == null) {
                 throw new LineNotFoundException();
             }
--- a/jdk/src/share/classes/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java	Mon Mar 10 15:07:09 2008 -0700
@@ -34,11 +34,11 @@
 
 public class MethodBreakpointSpec extends BreakpointSpec {
     String methodId;
-    List methodArgs;
+    List<String> methodArgs;
 
     MethodBreakpointSpec(EventRequestSpecList specs,
                          ReferenceTypeSpec refSpec,
-                         String methodId, List methodArgs) {
+                         String methodId, List<String> methodArgs) {
         super(specs, refSpec);
         this.methodId = methodId;
         this.methodArgs = methodArgs;
@@ -76,7 +76,7 @@
         return methodId;
     }
 
-    public List methodArgs() {
+    public List<String> methodArgs() {
         return methodArgs;
     }
 
@@ -120,14 +120,13 @@
         buffer.append('.');
         buffer.append(methodId);
         if (methodArgs != null) {
-            Iterator iter = methodArgs.iterator();
             boolean first = true;
             buffer.append('(');
-            while (iter.hasNext()) {
+            for (String name : methodArgs) {
                 if (!first) {
                     buffer.append(',');
                 }
-                buffer.append((String)iter.next());
+                buffer.append(name);
                 first = false;
             }
             buffer.append(")");
@@ -151,8 +150,8 @@
      * and if the number of arguments in the method matches the
      * number of names passed
      */
-    private boolean compareArgTypes(Method method, List nameList) {
-        List argTypeNames = method.argumentTypeNames();
+    private boolean compareArgTypes(Method method, List<String> nameList) {
+        List<String> argTypeNames = method.argumentTypeNames();
 
         // If argument counts differ, we can stop here
         if (argTypeNames.size() != nameList.size()) {
@@ -162,8 +161,8 @@
         // Compare each argument type's name
         int nTypes = argTypeNames.size();
         for (int i = 0; i < nTypes; ++i) {
-            String comp1 = (String)argTypeNames.get(i);
-            String comp2 = (String)nameList.get(i);
+            String comp1 = argTypeNames.get(i);
+            String comp2 = nameList.get(i);
             if (! comp1.equals(comp2)) {
                 /*
                  * We have to handle varargs.  EG, the
@@ -288,22 +287,17 @@
         List<String> argTypeNames = null;
         if (methodArgs() != null) {
             argTypeNames = new ArrayList<String>(methodArgs().size());
-            Iterator iter = methodArgs().iterator();
-            while (iter.hasNext()) {
-                String name = (String)iter.next();
+            for (String name : methodArgs()) {
                 name = normalizeArgTypeName(name);
                 argTypeNames.add(name);
             }
         }
 
         // Check each method in the class for matches
-        Iterator iter = clazz.methods().iterator();
         Method firstMatch = null;  // first method with matching name
         Method exactMatch = null;  // (only) method with same name & sig
         int matchCount = 0;        // > 1 implies overload
-        while (iter.hasNext()) {
-            Method candidate = (Method)iter.next();
-
+        for (Method candidate : clazz.methods()) {
             if (candidate.name().equals(methodName())) {
                 matchCount++;
 
--- a/jdk/src/share/classes/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java	Mon Mar 10 15:07:09 2008 -0700
@@ -36,7 +36,7 @@
  * Descend the tree of thread groups.
  * @author Robert G. Field
  */
-public class ThreadGroupIterator implements Iterator {
+public class ThreadGroupIterator implements Iterator<ThreadGroupReference> {
     private final Stack<Iterator<ThreadGroupReference>> stack
                         = new Stack<Iterator<ThreadGroupReference>>();
 
@@ -56,8 +56,8 @@
     }
 */
 
-    private Iterator top() {
-        return (Iterator)stack.peek();
+    private Iterator<ThreadGroupReference> top() {
+        return stack.peek();
     }
 
     /**
@@ -77,12 +77,12 @@
         return !stack.isEmpty();
     }
 
-    public Object next() {
+    public ThreadGroupReference next() {
         return nextThreadGroup();
     }
 
     public ThreadGroupReference nextThreadGroup() {
-        ThreadGroupReference tg = (ThreadGroupReference)top().next();
+        ThreadGroupReference tg = top().next();
         push(tg.threadGroups());
         return tg;
     }
--- a/jdk/src/share/classes/com/sun/tools/example/debug/bdi/ThreadIterator.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/bdi/ThreadIterator.java	Mon Mar 10 15:07:09 2008 -0700
@@ -30,8 +30,8 @@
 import java.util.List;
 import java.util.Iterator;
 
-public class ThreadIterator implements Iterator {
-    Iterator it = null;
+public class ThreadIterator implements Iterator<ThreadReference> {
+    Iterator<ThreadReference> it = null;
     ThreadGroupIterator tgi;
 
     public ThreadIterator(ThreadGroupReference tg) {
@@ -53,12 +53,12 @@
         return true;
     }
 
-    public Object next() {
+    public ThreadReference next() {
         return it.next();
     }
 
     public ThreadReference nextThread() {
-        return (ThreadReference)next();
+        return next();
     }
 
     public void remove() {
--- a/jdk/src/share/classes/com/sun/tools/example/debug/expr/LValue.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/expr/LValue.java	Mon Mar 10 15:07:09 2008 -0700
@@ -191,11 +191,12 @@
         return field;
     }
 
-    static List methodsByName(ReferenceType refType, String name, int kind) {
-        List list = refType.methodsByName(name);
-        Iterator iter = list.iterator();
+    static List<Method> methodsByName(ReferenceType refType,
+                                      String name, int kind) {
+        List<Method> list = refType.methodsByName(name);
+        Iterator<Method> iter = list.iterator();
         while (iter.hasNext()) {
-            Method method = (Method)iter.next();
+            Method method = iter.next();
             boolean isStatic = method.isStatic();
             if (((kind == STATIC) && !isStatic) ||
                 ((kind == INSTANCE) && isStatic)) {
@@ -231,21 +232,21 @@
      * argType is not assignable from the type of the argument value.
      * 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()) {
             return DIFFERENT;
         }
 
-        Iterator typeIter = argTypes.iterator();
-        Iterator valIter = arguments.iterator();
+        Iterator<Type> typeIter = argTypes.iterator();
+        Iterator<Value> valIter = arguments.iterator();
         int result = SAME;
 
         // If any pair aren't the same, change the
         // result to ASSIGNABLE.  If any pair aren't
         // assignable, return DIFFERENT
         while (typeIter.hasNext()) {
-            Type argType = (Type)typeIter.next();
-            Value value = (Value)valIter.next();
+            Type argType = typeIter.next();
+            Value value = valIter.next();
             if (value == null) {
                 // Null values can be passed to any non-primitive argument
                 if (primitiveTypeNames.contains(argType.name())) {
@@ -333,7 +334,7 @@
         if (fromType instanceof ArrayType) {
             return isArrayAssignableTo((ArrayType)fromType, toType);
         }
-        List interfaces;
+        List<InterfaceType> interfaces;
         if (fromType instanceof ClassType) {
             ClassType superclazz = ((ClassType)fromType).superclass();
             if ((superclazz != null) && isAssignableTo(superclazz, toType)) {
@@ -344,9 +345,7 @@
             // fromType must be an InterfaceType
             interfaces = ((InterfaceType)fromType).superinterfaces();
         }
-        Iterator iter = interfaces.iterator();
-        while (iter.hasNext()) {
-            InterfaceType interfaze = (InterfaceType)iter.next();
+        for (InterfaceType interfaze : interfaces) {
             if (isAssignableTo(interfaze, toType)) {
                 return true;
             }
@@ -354,7 +353,8 @@
         return false;
     }
 
-    static Method resolveOverload(List overloads, List arguments)
+    static Method resolveOverload(List<Method> overloads,
+                                  List<Value> arguments)
                                        throws ParseException {
 
         // If there is only one method to call, we'll just choose
@@ -362,7 +362,7 @@
         // the invoke will return a better error message than we
         // could generate here.
         if (overloads.size() == 1) {
-            return (Method)overloads.get(0);
+            return overloads.get(0);
         }
 
         // Resolving overloads is beyond the scope of this exercise.
@@ -374,12 +374,10 @@
         // methods to call. And, since casts aren't implemented,
         // the user can't use them to pick a particular overload to call.
         // IE, the user is out of luck in this case.
-        Iterator iter = overloads.iterator();
         Method retVal = null;
         int assignableCount = 0;
-        while (iter.hasNext()) {
-            Method mm = (Method)iter.next();
-            List argTypes;
+        for (Method mm : overloads) {
+            List<Type> argTypes;
             try {
                 argTypes = mm.argumentTypes();
             } catch (ClassNotLoadedException ee) {
@@ -443,7 +441,7 @@
         final ObjectReference obj;
         final ThreadReference thread;
         final Field matchingField;
-        final List overloads;
+        final List<Method> overloads;
         Method matchingMethod = null;
         List<Value> methodArguments = null;
 
@@ -510,7 +508,7 @@
         final ReferenceType refType;
         final ThreadReference thread;
         final Field matchingField;
-        final List overloads;
+        final List<Method> overloads;
         Method matchingMethod = null;
         List<Value> methodArguments = null;
 
@@ -765,7 +763,7 @@
     static LValue makeNewObject(VirtualMachine vm,
                                  ExpressionParser.GetFrame frameGetter,
                                 String className, List<Value> arguments) throws ParseException {
-        List classes = vm.classesByName(className);
+        List<ReferenceType> classes = vm.classesByName(className);
         if (classes.size() == 0) {
             throw new ParseException("No class named: " + className);
         }
@@ -774,7 +772,7 @@
             throw new ParseException("More than one class named: " +
                                      className);
         }
-        ReferenceType refType = (ReferenceType)classes.get(0);
+        ReferenceType refType = classes.get(0);
 
 
         if (!(refType instanceof ClassType)) {
@@ -784,9 +782,9 @@
 
         ClassType classType = (ClassType)refType;
         List<Method> methods = new ArrayList<Method>(classType.methods()); // writable
-        Iterator iter = methods.iterator();
+        Iterator<Method> iter = methods.iterator();
         while (iter.hasNext()) {
-            Method method = (Method)iter.next();
+            Method method = iter.next();
             if (!method.isConstructor()) {
                 iter.remove();
             }
@@ -858,13 +856,13 @@
                 }
                 // check for class name
                 while (izer.hasMoreTokens()) {
-                    List classes = vm.classesByName(first);
+                    List<ReferenceType> classes = vm.classesByName(first);
                     if (classes.size() > 0) {
                         if (classes.size() > 1) {
                             throw new ParseException("More than one class named: " +
                                                      first);
                         } else {
-                            ReferenceType refType = (ReferenceType)classes.get(0);
+                            ReferenceType refType = classes.get(0);
                             LValue lval = new LValueStaticMember(refType,
                                                             izer.nextToken(), thread);
                             return nFields(lval, izer, thread);
--- a/jdk/src/share/classes/com/sun/tools/example/debug/gui/ClassTreeTool.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/gui/ClassTreeTool.java	Mon Mar 10 15:07:09 2008 -0700
@@ -124,9 +124,7 @@
         public void sessionStart(EventObject e) {
             // Get system classes and any others loaded before attaching.
             try {
-                Iterator iter = runtime.allClasses().iterator();
-                while (iter.hasNext()) {
-                    ReferenceType type = ((ReferenceType)iter.next());
+                for (ReferenceType type : runtime.allClasses()) {
                     root.addClass(type);
                 }
             } catch (VMDisconnectedException ee) {
--- a/jdk/src/share/classes/com/sun/tools/example/debug/gui/CommandInterpreter.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/gui/CommandInterpreter.java	Mon Mar 10 15:07:09 2008 -0700
@@ -77,7 +77,7 @@
             while (ti.hasNext()) {
                 tlist.add(ti.nextThread());
             }
-            threads = (ThreadReference[])tlist.toArray(new ThreadReference[tlist.size()]);
+            threads = tlist.toArray(new ThreadReference[tlist.size()]);
         }
         return threads;
     }
@@ -146,11 +146,9 @@
     // Command: classes
 
     private void commandClasses() throws NoSessionException {
-        List list = runtime.allClasses();
         OutputSink out = env.getOutputSink();
         //out.println("** classes list **");
-        for (int i = 0 ; i < list.size() ; i++) {
-            ReferenceType refType = (ReferenceType)list.get(i);
+        for (ReferenceType refType : runtime.allClasses()) {
             out.println(refType.name());
         }
         out.show();
@@ -167,16 +165,16 @@
         String idClass = t.nextToken();
         ReferenceType cls = findClass(idClass);
         if (cls != null) {
-            List methods = cls.allMethods();
+            List<Method> methods = cls.allMethods();
             OutputSink out = env.getOutputSink();
             for (int i = 0; i < methods.size(); i++) {
-                Method method = (Method)methods.get(i);
+                Method method = methods.get(i);
                 out.print(method.declaringType().name() + " " +
                             method.name() + "(");
-                Iterator it = method.argumentTypeNames().iterator();
+                Iterator<String> it = method.argumentTypeNames().iterator();
                 if (it.hasNext()) {
                     while (true) {
-                        out.print((String)it.next());
+                        out.print(it.next());
                         if (!it.hasNext()) {
                             break;
                         }
@@ -193,10 +191,10 @@
     }
 
     private ReferenceType findClass(String pattern) throws NoSessionException {
-        List results = runtime.findClassesMatchingPattern(pattern);
+        List<ReferenceType> results = runtime.findClassesMatchingPattern(pattern);
         if (results.size() > 0) {
             //### Should handle multiple results sensibly.
-            return (ReferenceType)results.get(0);
+            return results.get(0);
         }
         return null;
     }
@@ -235,11 +233,11 @@
 
     private int printThreadGroup(OutputSink out, ThreadGroupReference tg, int iThread) {
         out.println("Group " + tg.name() + ":");
-        List tlist = tg.threads();
+        List<ThreadReference> tlist = tg.threads();
         int maxId = 0;
         int maxName = 0;
         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();
             if (len > maxId)
                 maxId = len;
@@ -254,7 +252,7 @@
         String maxNumString = String.valueOf(iThread + tlist.size());
         int maxNumDigits = maxNumString.length();
         for (int i = 0 ; i < tlist.size() ; i++) {
-            ThreadReference thr = (ThreadReference)tlist.get(i);
+            ThreadReference thr = tlist.get(i);
             char buf[] = new char[80];
             for (int j = 0; j < 79; j++) {
                 buf[j] = ' ';
@@ -283,9 +281,7 @@
             sbOut.setLength(79);
             out.println(sbOut.toString());
         }
-        List tglist = tg.threadGroups();
-        for (int ig = 0; ig < tglist.size(); ig++) {
-            ThreadGroupReference tg0 = (ThreadGroupReference)tglist.get(ig);
+        for (ThreadGroupReference tg0 : tg.threadGroups()) {
             if (!tg.equals(tg0)) {  // TODO ref mgt
                 iThread += printThreadGroup(out, tg0, iThread + tlist.size());
             }
@@ -733,7 +729,7 @@
             if (token.toLowerCase().equals("all")) {
                 ThreadIterator it = allThreads();
                 while (it.hasNext()) {
-                    ThreadReference thread = (ThreadReference)it.next();
+                    ThreadReference thread = it.next();
                     out.println(thread.name() + ": ");
                     dumpStack(thread, showPC);
                 }
@@ -755,7 +751,7 @@
         //env.failure("Target VM must be in interrupted state.");
         //env.failure("Current thread isn't suspended.");
         //### Should handle extremely long stack traces sensibly for user.
-        List stack = null;
+        List<StackFrame> stack = null;
         try {
             stack = thread.frames();
         } catch (IncompatibleThreadStateException e) {
@@ -772,7 +768,7 @@
             OutputSink out = env.getOutputSink();
             int nFrames = stack.size();
             for (int i = frameIndex; i < nFrames; i++) {
-                StackFrame frame = (StackFrame)stack.get(i);
+                StackFrame frame = stack.get(i);
                 Location loc = frame.location();
                 Method meth = loc.method();
                 out.print("  [" + (i + 1) + "] ");
@@ -780,7 +776,7 @@
                 out.print('.');
                 out.print(meth.name());
                 out.print(" (");
-                if (meth instanceof Method && ((Method)meth).isNative()) {
+                if (meth.isNative()) {
                     out.print("native method");
                 } else if (loc.lineNumber() != -1) {
                     try {
@@ -806,14 +802,13 @@
 
     private void listEventRequests() throws NoSessionException {
         // Print set breakpoints
-        Iterator iter = runtime.eventRequestSpecs().iterator();
-        if (!iter.hasNext()) {
+        List<EventRequestSpec> specs = runtime.eventRequestSpecs();
+        if (specs.isEmpty()) {
             env.notice("No breakpoints/watchpoints/exceptions set.");
         } else {
             OutputSink out = env.getOutputSink();
             out.println("Current breakpoints/watchpoints/exceptions set:");
-            while (iter.hasNext()) {
-                EventRequestSpec  bp = (EventRequestSpec)iter.next();
+            for (EventRequestSpec bp : specs) {
                 out.println("\t" + bp);
             }
             out.show();
@@ -926,13 +921,13 @@
         //### need 'clear all'
         BreakpointSpec bpSpec = parseBreakpointSpec(t.nextToken());
         if (bpSpec != null) {
-            Iterator iter = runtime.eventRequestSpecs().iterator();
-            if (!iter.hasNext()) {
+            List<EventRequestSpec> specs = runtime.eventRequestSpecs();
+
+            if (specs.isEmpty()) {
                 env.notice("No breakpoints set.");
             } else {
-                List<BreakpointSpec> toDelete = new ArrayList<BreakpointSpec>();
-                while (iter.hasNext()) {
-                    BreakpointSpec spec = (BreakpointSpec)iter.next();
+                List<EventRequestSpec> toDelete = new ArrayList<EventRequestSpec>();
+                for (EventRequestSpec spec : specs) {
                     if (spec.equals(bpSpec)) {
                         toDelete.add(spec);
                     }
@@ -941,7 +936,7 @@
                 if (toDelete.size() <= 1) {
                     env.notice("No matching breakpoint set.");
                 }
-                for (BreakpointSpec spec : toDelete) {
+                for (EventRequestSpec spec : toDelete) {
                     runtime.delete(spec);
                 }
             }
@@ -988,7 +983,7 @@
                 lineno = Integer.valueOf(id).intValue();
             } catch (NumberFormatException nfe) {
                 // 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) {
                     env.failure(id +
                                 " is not a valid line number or " +
@@ -1001,7 +996,7 @@
                                 refType.name());
                     return;
                 }
-                loc = ((Method)meths.get(0)).location();
+                loc = meths.get(0).location();
                 lineno = loc.lineNumber();
             }
         }
@@ -1121,7 +1116,7 @@
             return;
         }
 
-        List vars;
+        List<LocalVariable> vars;
         try {
             vars = frame.visibleVariables();
             if (vars == null || vars.size() == 0) {
@@ -1136,15 +1131,13 @@
 
         OutputSink out = env.getOutputSink();
         out.println("Method arguments:");
-        for (Iterator it = vars.iterator(); it.hasNext(); ) {
-            LocalVariable var = (LocalVariable)it.next();
+        for (LocalVariable var : vars) {
             if (var.isArgument()) {
                 printVar(out, var, frame);
             }
         }
         out.println("Local variables:");
-        for (Iterator it = vars.iterator(); it.hasNext(); ) {
-            LocalVariable var = (LocalVariable)it.next();
+        for (LocalVariable var : vars) {
             if (!var.isArgument()) {
                 printVar(out, var, frame);
             }
@@ -1245,8 +1238,7 @@
     private void dump(OutputSink out,
                       ObjectReference obj, ReferenceType refType,
                       ReferenceType refTypeBase) {
-        for (Iterator it = refType.fields().iterator(); it.hasNext(); ) {
-            Field field = (Field)it.next();
+        for (Field field : refType.fields()) {
             out.print("    ");
             if (!refType.equals(refTypeBase)) {
                 out.print(refType.name() + ".");
@@ -1261,9 +1253,8 @@
                 dump(out, obj, sup, refTypeBase);
             }
         } else if (refType instanceof InterfaceType) {
-            List sups = ((InterfaceType)refType).superinterfaces();
-            for (Iterator it = sups.iterator(); it.hasNext(); ) {
-                dump(out, obj, (ReferenceType)it.next(), refTypeBase);
+            for (InterfaceType sup : ((InterfaceType)refType).superinterfaces()) {
+                dump(out, obj, sup, refTypeBase);
             }
         }
     }
--- a/jdk/src/share/classes/com/sun/tools/example/debug/gui/JDBFileFilter.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/gui/JDBFileFilter.java	Mon Mar 10 15:07:09 2008 -0700
@@ -201,11 +201,11 @@
             if(description == null || isExtensionListInDescription()) {
                 fullDescription = description==null ? "(" : description + " (";
                 // build the description from the extension list
-                Enumeration extensions = filters.keys();
+                Enumeration<String> extensions = filters.keys();
                 if(extensions != null) {
-                    fullDescription += "." + (String) extensions.nextElement();
+                    fullDescription += "." + extensions.nextElement();
                     while (extensions.hasMoreElements()) {
-                        fullDescription += ", " + (String) extensions.nextElement();
+                        fullDescription += ", " + extensions.nextElement();
                     }
                 }
                 fullDescription += ")";
--- a/jdk/src/share/classes/com/sun/tools/example/debug/gui/LaunchTool.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/gui/LaunchTool.java	Mon Mar 10 15:07:09 2008 -0700
@@ -131,14 +131,13 @@
         final JPanel radioPanel = new JPanel();
         final ButtonGroup radioGroup = new ButtonGroup();
         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);
 
         dialog.setModal(true);
         dialog.setTitle("Select Connector Type");
         radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.Y_AXIS));
-        for (Iterator it = all.iterator(); it.hasNext(); ) {
-            Connector connector = (Connector)it.next();
+        for (Connector connector : all) {
             JRadioButton radio = new JRadioButton(connector.description());
             modelToConnector.put(radio.getModel(), connector);
             radioPanel.add(radio);
@@ -166,7 +165,7 @@
         dialog.show();
 
         return oked[0] ?
-            (Connector)(modelToConnector.get(radioGroup.getSelection())) :
+            modelToConnector.get(radioGroup.getSelection()) :
             null;
     }
 
@@ -188,13 +187,12 @@
         //        guts.add(new JLabel(connector.description()));
 
         final List<ArgRep> argReps = new ArrayList<ArgRep>(args.size());
-        for (Iterator it = args.values().iterator(); it.hasNext(); ) {
-            Object arg = it.next();
+        for (Connector.Argument arg : args.values()) {
             ArgRep ar;
             if (arg instanceof Connector.BooleanArgument) {
                 ar = new BooleanArgRep((Connector.BooleanArgument)arg, guts);
             } else {
-                ar = new StringArgRep((Connector.Argument)arg, guts);
+                ar = new StringArgRep(arg, guts);
             }
             argReps.add(ar);
         }
@@ -202,8 +200,7 @@
 
         JPanel buttonPanel = okCancel( dialog, new ActionListener() {
             public void actionPerformed(ActionEvent event) {
-                for (Iterator it = argReps.iterator(); it.hasNext(); ) {
-                    ArgRep ar = (ArgRep)it.next();
+                for (ArgRep ar : argReps) {
                     if (!ar.isSpecified()) {
                         JOptionPane.showMessageDialog(dialog,
                                     ar.arg.label() +
--- a/jdk/src/share/classes/com/sun/tools/example/debug/gui/SearchPath.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/gui/SearchPath.java	Mon Mar 10 15:07:09 2008 -0700
@@ -42,7 +42,7 @@
             dlist.add(st.nextToken());
         }
         pathString = searchPath;
-        pathArray = (String[])dlist.toArray(new String[dlist.size()]);
+        pathArray = dlist.toArray(new String[dlist.size()]);
     }
 
     public boolean isEmpty() {
@@ -54,7 +54,7 @@
     }
 
     public String[] asArray() {
-        return (String[])pathArray.clone();
+        return pathArray.clone();
     }
 
     public File resolve(String relativeFileName) {
@@ -89,7 +89,7 @@
                 }
             }
         }
-        return (String[])s.toArray(new String[s.size()]);
+        return s.toArray(new String[s.size()]);
     }
 
 }
--- a/jdk/src/share/classes/com/sun/tools/example/debug/gui/SourceManager.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/gui/SourceManager.java	Mon Mar 10 15:07:09 2008 -0700
@@ -113,7 +113,7 @@
      * Returns null if not available.
      */
     public SourceModel sourceForClass(ReferenceType refType) {
-        SourceModel sm = (SourceModel)classToSource.get(refType);
+        SourceModel sm = classToSource.get(refType);
         if (sm != null) {
             return sm;
         }
@@ -140,10 +140,10 @@
      */
     //### Use hash table for this?
     public SourceModel sourceForFile(File path) {
-        Iterator iter = sourceList.iterator();
+        Iterator<SourceModel> iter = sourceList.iterator();
         SourceModel sm = null;
         while (iter.hasNext()) {
-            SourceModel candidate = (SourceModel)iter.next();
+            SourceModel candidate = iter.next();
             if (candidate.fileName().equals(path)) {
                 sm = candidate;
                 iter.remove();    // Will move to start of list.
--- a/jdk/src/share/classes/com/sun/tools/example/debug/gui/SourceModel.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/gui/SourceModel.java	Mon Mar 10 15:07:09 2008 -0700
@@ -187,22 +187,17 @@
      * when sourceLines is set.
      */
     private void markClassLines(ReferenceType refType) {
-        List methods = refType.methods();
-        for (Iterator mit = methods.iterator(); mit.hasNext();) {
-            Method meth = (Method)mit.next();
+        for (Method meth : refType.methods()) {
             try {
-                List lines = meth.allLineLocations();
-                for (Iterator lit = lines.iterator(); lit.hasNext();) {
-                    Location loc = (Location)lit.next();
+                for (Location loc : meth.allLineLocations()) {
                     showExecutable(loc.lineNumber(), refType);
                 }
             } catch (AbsentInformationException exc) {
                 // do nothing
             }
         }
-        List bps = env.getExecutionManager().eventRequestManager().breakpointRequests();
-        for (Iterator it = bps.iterator(); it.hasNext();) {
-            BreakpointRequest bp = (BreakpointRequest)it.next();
+        for (BreakpointRequest bp :
+                 env.getExecutionManager().eventRequestManager().breakpointRequests()) {
             if (bp.location() != null) {
                 Location loc = bp.location();
                 if (loc.declaringType().equals(refType)) {
@@ -224,8 +219,8 @@
         } finally {
             reader.close();
         }
-        for (Iterator it = classes.iterator(); it.hasNext();) {
-            markClassLines((ClassType)it.next());
+        for (ReferenceType refType : classes) {
+            markClassLines(refType);
         }
     }
 
--- a/jdk/src/share/classes/com/sun/tools/example/debug/gui/StackTraceTool.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/gui/StackTraceTool.java	Mon Mar 10 15:07:09 2008 -0700
@@ -139,7 +139,7 @@
                 String methName =
                     meth.declaringType().name() + '.' + meth.name();
                 String position = "";
-                if (meth instanceof Method && ((Method)meth).isNative()) {
+                if (meth.isNative()) {
                     position = " (native method)";
                 } else if (loc.lineNumber() != -1) {
                     position = ":" + loc.lineNumber();
--- a/jdk/src/share/classes/com/sun/tools/example/debug/gui/ThreadTreeTool.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/gui/ThreadTreeTool.java	Mon Mar 10 15:07:09 2008 -0700
@@ -133,9 +133,7 @@
 
         public void sessionStart(EventObject e) {
             try {
-                Iterator iter = runtime.allThreads().iterator();
-                while (iter.hasNext()) {
-                    ThreadReference thread = ((ThreadReference)iter.next());
+                for (ThreadReference thread : runtime.allThreads()) {
                     root.addThread(thread);
                 }
             } catch (VMDisconnectedException ee) {
@@ -244,16 +242,16 @@
             }
         }
 
-        private void addThread(List threadPath, ThreadReference thread) {
+        private void addThread(List<String> threadPath, ThreadReference thread) {
             int size = threadPath.size();
             if (size == 0) {
                 return;
             } else if (size == 1) {
-                String name = (String)threadPath.get(0);
+                String name = threadPath.get(0);
                 insertNode(name, thread);
             } else {
-                String head = (String)threadPath.get(0);
-                List tail = threadPath.subList(1, size);
+                String head = threadPath.get(0);
+                List<String> tail = threadPath.subList(1, size);
                 ThreadTreeNode child = insertNode(head, null);
                 child.addThread(tail, thread);
             }
@@ -288,17 +286,17 @@
             }
         }
 
-        private void removeThread(List threadPath, ThreadReference thread) {
+        private void removeThread(List<String> threadPath, ThreadReference thread) {
             int size = threadPath.size();
             if (size == 0) {
                 return;
             } else if (size == 1) {
-                String name = (String)threadPath.get(0);
+                String name = threadPath.get(0);
                 ThreadTreeNode child = findLeafNode(thread, name);
                 treeModel.removeNodeFromParent(child);
             } else {
-                String head = (String)threadPath.get(0);
-                List tail = threadPath.subList(1, size);
+                String head = threadPath.get(0);
+                List<String> tail = threadPath.subList(1, size);
                 ThreadTreeNode child = findInternalNode(head);
                 child.removeThread(tail, thread);
                 if (child.isThreadGroup() && child.getChildCount() < 1) {
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/BreakpointSpec.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/BreakpointSpec.java	Mon Mar 10 15:07:09 2008 -0700
@@ -34,7 +34,7 @@
 
 class BreakpointSpec extends EventRequestSpec {
     String methodId;
-    List methodArgs;
+    List<String> methodArgs;
     int lineNumber;
 
     BreakpointSpec(ReferenceTypeSpec refSpec, int lineNumber) {
@@ -45,7 +45,7 @@
     }
 
     BreakpointSpec(ReferenceTypeSpec refSpec, String methodId,
-                   List methodArgs) throws MalformedMemberNameException {
+                   List<String> methodArgs) throws MalformedMemberNameException {
         super(refSpec);
         this.methodId = methodId;
         this.methodArgs = methodArgs;
@@ -83,7 +83,7 @@
         return lineNumber;
     }
 
-    List methodArgs() {
+    List<String> methodArgs() {
         return methodArgs;
     }
 
@@ -146,14 +146,13 @@
             buffer.append('.');
             buffer.append(methodId);
             if (methodArgs != null) {
-                Iterator iter = methodArgs.iterator();
                 boolean first = true;
                 buffer.append('(');
-                while (iter.hasNext()) {
+                for (String arg : methodArgs) {
                     if (!first) {
                         buffer.append(',');
                     }
-                    buffer.append((String)iter.next());
+                    buffer.append(arg);
                     first = false;
                 }
                 buffer.append(")");
@@ -176,12 +175,12 @@
             location = method.location();
         } else {
             // let AbsentInformationException be thrown
-            List locs = refType.locationsOfLine(lineNumber());
+            List<Location> locs = refType.locationsOfLine(lineNumber());
             if (locs.size() == 0) {
                 throw new LineNotFoundException();
             }
             // TO DO: handle multiple locations
-            location = (Location)locs.get(0);
+            location = locs.get(0);
             if (location.method() == null) {
                 throw new LineNotFoundException();
             }
@@ -202,8 +201,8 @@
      * and if the number of arguments in the method matches the
      * number of names passed
      */
-    private boolean compareArgTypes(Method method, List nameList) {
-        List argTypeNames = method.argumentTypeNames();
+    private boolean compareArgTypes(Method method, List<String> nameList) {
+        List<String> argTypeNames = method.argumentTypeNames();
 
         // If argument counts differ, we can stop here
         if (argTypeNames.size() != nameList.size()) {
@@ -213,8 +212,8 @@
         // Compare each argument type's name
         int nTypes = argTypeNames.size();
         for (int i = 0; i < nTypes; ++i) {
-            String comp1 = (String)argTypeNames.get(i);
-            String comp2 = (String)nameList.get(i);
+            String comp1 = argTypeNames.get(i);
+            String comp2 = nameList.get(i);
             if (! comp1.equals(comp2)) {
                 /*
                  * We have to handle varargs.  EG, the
@@ -331,22 +330,17 @@
         List<String> argTypeNames = null;
         if (methodArgs() != null) {
             argTypeNames = new ArrayList<String>(methodArgs().size());
-            Iterator iter = methodArgs().iterator();
-            while (iter.hasNext()) {
-                String name = (String)iter.next();
+            for (String name : methodArgs()) {
                 name = normalizeArgTypeName(name);
                 argTypeNames.add(name);
             }
         }
 
         // Check each method in the class for matches
-        Iterator iter = refType.methods().iterator();
         Method firstMatch = null;  // first method with matching name
         Method exactMatch = null;  // (only) method with same name & sig
         int matchCount = 0;        // > 1 implies overload
-        while (iter.hasNext()) {
-            Method candidate = (Method)iter.next();
-
+        for (Method candidate : refType.methods()) {
             if (candidate.name().equals(methodName())) {
                 matchCount++;
 
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/Commands.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/Commands.java	Mon Mar 10 15:07:09 2008 -0700
@@ -157,16 +157,16 @@
         buf.append(method.name());
         buf.append("(");
 
-        List args = method.argumentTypeNames();
+        List<String> args = method.argumentTypeNames();
         int lastParam = args.size() - 1;
         // output param types except for the last
         for (int ii = 0; ii < lastParam; ii++) {
-            buf.append((String)args.get(ii));
+            buf.append(args.get(ii));
             buf.append(", ");
         }
         if (lastParam >= 0) {
             // output the last param
-            String lastStr = (String)args.get(lastParam);
+            String lastStr = args.get(lastParam);
             if (method.isVarArgs()) {
                 // lastParam is an array.  Replace the [] with ...
                 buf.append(lastStr.substring(0, lastStr.length() - 2));
@@ -180,12 +180,11 @@
     }
 
     void commandConnectors(VirtualMachineManager vmm) {
-        Iterator iter = vmm.allConnectors().iterator();
-        if (iter.hasNext()) {
+        Collection<Connector> ccs = vmm.allConnectors();
+        if (ccs.isEmpty()) {
             MessageOutput.println("Connectors available");
         }
-        while (iter.hasNext()) {
-            Connector cc = (Connector)iter.next();
+        for (Connector cc : ccs) {
             String transportName =
                 cc.transport() == null ? "null" : cc.transport().name();
             MessageOutput.println();
@@ -193,10 +192,7 @@
                                   new Object [] {cc.name(), transportName});
             MessageOutput.println("Connector description", cc.description());
 
-            Iterator argIter = cc.defaultArguments().values().iterator();
-            if (argIter.hasNext()) {
-                while (argIter.hasNext()) {
-                    Connector.Argument aa = (Connector.Argument)argIter.next();
+            for (Connector.Argument aa : cc.defaultArguments().values()) {
                     MessageOutput.println();
 
                     boolean requiredArgument = aa.mustSpecify();
@@ -215,16 +211,12 @@
 
                 }
             }
-        }
 
     }
 
     void commandClasses() {
-        List list = Env.vm().allClasses();
-
         StringBuffer classList = new StringBuffer();
-        for (int i = 0 ; i < list.size() ; i++) {
-            ReferenceType refType = (ReferenceType)list.get(i);
+        for (ReferenceType refType : Env.vm().allClasses()) {
             classList.append(refType.name());
             classList.append("\n");
         }
@@ -232,7 +224,7 @@
     }
 
     void commandClass(StringTokenizer t) {
-        List list = Env.vm().allClasses();
+        List<ReferenceType> list = Env.vm().allClasses();
 
         if (!t.hasMoreTokens()) {
             MessageOutput.println("No class specified.");
@@ -265,51 +257,31 @@
                 superclass = showAll ? superclass.superclass() : null;
             }
 
-            List interfaces = showAll ? clazz.allInterfaces()
-                                      : clazz.interfaces();
-            Iterator iter = interfaces.iterator();
-            while (iter.hasNext()) {
-                InterfaceType interfaze = (InterfaceType)iter.next();
+            List<InterfaceType> interfaces =
+                showAll ? clazz.allInterfaces() : clazz.interfaces();
+            for (InterfaceType interfaze : interfaces) {
                 MessageOutput.println("implements:", interfaze.name());
             }
 
-            List subs = clazz.subclasses();
-            iter = subs.iterator();
-            while (iter.hasNext()) {
-                ClassType sub = (ClassType)iter.next();
+            for (ClassType sub : clazz.subclasses()) {
                 MessageOutput.println("subclass:", sub.name());
             }
-            List nested = clazz.nestedTypes();
-            iter = nested.iterator();
-            while (iter.hasNext()) {
-                ReferenceType nest = (ReferenceType)iter.next();
+            for (ReferenceType nest : clazz.nestedTypes()) {
                 MessageOutput.println("nested:", nest.name());
             }
         } else if (type instanceof InterfaceType) {
             InterfaceType interfaze = (InterfaceType)type;
             MessageOutput.println("Interface:", interfaze.name());
-            List supers = interfaze.superinterfaces();
-            Iterator iter = supers.iterator();
-            while (iter.hasNext()) {
-                InterfaceType superinterface = (InterfaceType)iter.next();
+            for (InterfaceType superinterface : interfaze.superinterfaces()) {
                 MessageOutput.println("extends:", superinterface.name());
             }
-            List subs = interfaze.subinterfaces();
-            iter = subs.iterator();
-            while (iter.hasNext()) {
-                InterfaceType sub = (InterfaceType)iter.next();
+            for (InterfaceType sub : interfaze.subinterfaces()) {
                 MessageOutput.println("subinterface:", sub.name());
             }
-            List implementors = interfaze.implementors();
-            iter = implementors.iterator();
-            while (iter.hasNext()) {
-                ClassType implementor = (ClassType)iter.next();
+            for (ClassType implementor : interfaze.implementors()) {
                 MessageOutput.println("implementor:", implementor.name());
             }
-            List nested = interfaze.nestedTypes();
-            iter = nested.iterator();
-            while (iter.hasNext()) {
-                ReferenceType nest = (ReferenceType)iter.next();
+            for (ReferenceType nest : interfaze.nestedTypes()) {
                 MessageOutput.println("nested:", nest.name());
             }
         } else {  // array type
@@ -327,10 +299,8 @@
         String idClass = t.nextToken();
         ReferenceType cls = Env.getReferenceTypeFromToken(idClass);
         if (cls != null) {
-            List methods = cls.allMethods();
             StringBuffer methodsList = new StringBuffer();
-            for (int i = 0; i < methods.size(); i++) {
-                Method method = (Method)methods.get(i);
+            for (Method method : cls.allMethods()) {
                 methodsList.append(method.declaringType().name());
                 methodsList.append(" ");
                 methodsList.append(typedName(method));
@@ -351,11 +321,10 @@
         String idClass = t.nextToken();
         ReferenceType cls = Env.getReferenceTypeFromToken(idClass);
         if (cls != null) {
-            List fields = cls.allFields();
-            List visible = cls.visibleFields();
+            List<Field> fields = cls.allFields();
+            List<Field> visible = cls.visibleFields();
             StringBuffer fieldsList = new StringBuffer();
-            for (int i = 0; i < fields.size(); i++) {
-                Field field = (Field)fields.get(i);
+            for (Field field : fields) {
                 String s;
                 if (!visible.contains(field)) {
                     s = MessageOutput.format("list field typename and name hidden",
@@ -386,7 +355,7 @@
         int maxIdLength = 0;
         int maxNameLength = 0;
         while (threadIter.hasNext()) {
-            ThreadReference thr = (ThreadReference)threadIter.next();
+            ThreadReference thr = threadIter.next();
             maxIdLength = Math.max(maxIdLength,
                                    Env.description(thr).length());
             maxNameLength = Math.max(maxNameLength,
@@ -395,7 +364,7 @@
 
         threadIter = new ThreadIterator(tg);
         while (threadIter.hasNext()) {
-            ThreadReference thr = (ThreadReference)threadIter.next();
+            ThreadReference thr = threadIter.next();
             if (thr.threadGroup() == null) {
                 continue;
             }
@@ -588,9 +557,7 @@
     private List<ThreadReference> allThreads(ThreadGroupReference group) {
         List<ThreadReference> list = new ArrayList<ThreadReference>();
         list.addAll(group.threads());
-        Iterator iter = group.threadGroups().iterator();
-        while (iter.hasNext()) {
-            ThreadGroupReference child = (ThreadGroupReference)iter.next();
+        for (ThreadGroupReference child : group.threadGroups()) {
             list.addAll(allThreads(child));
         }
         return list;
@@ -641,10 +608,7 @@
          * if so, it gets removed here.
          */
          EventRequestManager mgr = Env.vm().eventRequestManager();
-         List requests = mgr.stepRequests();
-         Iterator iter = requests.iterator();
-         while (iter.hasNext()) {
-             StepRequest request = (StepRequest)iter.next();
+         for (StepRequest request : mgr.stepRequests()) {
              if (request.thread().equals(thread)) {
                  mgr.deleteEventRequest(request);
                  break;
@@ -768,9 +732,7 @@
         boolean noExceptions = true;
 
         // Print a listing of the catch patterns currently in place
-        Iterator iter = Env.specList.eventRequestSpecs().iterator();
-        while (iter.hasNext()) {
-            EventRequestSpec spec = (EventRequestSpec)iter.next();
+        for (EventRequestSpec spec : Env.specList.eventRequestSpecs()) {
             if (spec instanceof ExceptionSpec) {
                 if (noExceptions) {
                     noExceptions = false;
@@ -928,7 +890,7 @@
     }
 
     private void dumpStack(ThreadInfo threadInfo, boolean showPC) {
-        List stack = null;
+        List<StackFrame> stack = null;
         try {
             stack = threadInfo.getStack();
         } catch (IncompatibleThreadStateException e) {
@@ -940,7 +902,7 @@
         } else {
             int nFrames = stack.size();
             for (int i = threadInfo.getCurrentFrameIndex(); i < nFrames; i++) {
-                StackFrame frame = (StackFrame)stack.get(i);
+                StackFrame frame = stack.get(i);
                 dumpFrame (i, showPC, frame);
             }
         }
@@ -956,7 +918,7 @@
 
         long lineNumber = loc.lineNumber();
         String methodInfo = null;
-        if (meth instanceof Method && ((Method)meth).isNative()) {
+        if (meth.isNative()) {
             methodInfo = MessageOutput.format("native method");
         } else if (lineNumber != -1) {
             try {
@@ -994,9 +956,7 @@
         } else {
             String token = t.nextToken();
             if (token.toLowerCase().equals("all")) {
-                Iterator iter = ThreadInfo.threads().iterator();
-                while (iter.hasNext()) {
-                    ThreadInfo threadInfo = (ThreadInfo)iter.next();
+                for (ThreadInfo threadInfo : ThreadInfo.threads()) {
                     MessageOutput.println("Thread:",
                                           threadInfo.getThread().name());
                     dumpStack(threadInfo, showPC);
@@ -1051,9 +1011,7 @@
         boolean noBreakpoints = true;
 
         // Print set breakpoints
-        Iterator iter = Env.specList.eventRequestSpecs().iterator();
-        while (iter.hasNext()) {
-            EventRequestSpec spec = (EventRequestSpec)iter.next();
+        for (EventRequestSpec spec : Env.specList.eventRequestSpecs()) {
             if (spec instanceof BreakpointSpec) {
                 if (noBreakpoints) {
                     noBreakpoints = false;
@@ -1075,7 +1033,7 @@
 
     protected BreakpointSpec parseBreakpointSpec(StringTokenizer t,
                                              String atForm, String inForm) {
-        EventRequestSpec breakpoint = null;
+        BreakpointSpec breakpoint = null;
         try {
             String token = t.nextToken(":( \t\n\r");
 
@@ -1149,7 +1107,7 @@
             printBreakpointCommandUsage(atForm, inForm);
             return null;
         }
-        return (BreakpointSpec)breakpoint;
+        return breakpoint;
     }
 
     private void resolveNow(EventRequestSpec spec) {
@@ -1209,8 +1167,8 @@
         }
     }
 
-    private List<EventRequestSpec> parseWatchpointSpec(StringTokenizer t) {
-        List<EventRequestSpec> list = new ArrayList<EventRequestSpec>();
+    private List<WatchpointSpec> parseWatchpointSpec(StringTokenizer t) {
+        List<WatchpointSpec> list = new ArrayList<WatchpointSpec>();
         boolean access = false;
         boolean modification = false;
         int suspendPolicy = EventRequest.SUSPEND_ALL;
@@ -1242,7 +1200,7 @@
         fieldName = fieldName.substring(dot+1);
 
         try {
-            EventRequestSpec spec;
+            WatchpointSpec spec;
             if (access) {
                 spec = Env.specList.createAccessWatchpoint(className,
                                                            fieldName);
@@ -1269,9 +1227,8 @@
             return;
         }
 
-        Iterator iter = parseWatchpointSpec(t).iterator();
-        while (iter.hasNext()) {
-            resolveNow((WatchpointSpec)iter.next());
+        for (WatchpointSpec spec : parseWatchpointSpec(t)) {
+            resolveNow(spec);
         }
     }
 
@@ -1281,9 +1238,7 @@
             return;
         }
 
-        Iterator iter = parseWatchpointSpec(t).iterator();
-        while (iter.hasNext()) {
-            WatchpointSpec spec = (WatchpointSpec)iter.next();
+        for (WatchpointSpec spec : parseWatchpointSpec(t)) {
             if (Env.specList.delete(spec)) {
                 MessageOutput.println("Removed:", spec.toString());
             } else {
@@ -1482,7 +1437,7 @@
                     lineno = n.intValue();
                 } catch (java.text.ParseException jtpe) {
                     // 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) {
                             MessageOutput.println("is not a valid line number or method name for",
                                                   new Object [] {id, refType.name()});
@@ -1492,7 +1447,7 @@
                                                   new Object [] {id, refType.name()});
                             return;
                         }
-                        loc = ((Method)meths.get(0)).location();
+                        loc = meths.get(0).location();
                         lineno = loc.lineNumber();
                 }
             }
@@ -1539,14 +1494,11 @@
             try {
                 ReferenceType refType = Env.getReferenceTypeFromToken(idClass);
                 if (refType != null) {
-                    List lines = null;
+                    List<Location> lines = null;
                     if (idMethod == null) {
                         lines = refType.allLineLocations();
                     } else {
-                        List methods = refType.allMethods();
-                        Iterator iter = methods.iterator();
-                        while (iter.hasNext()) {
-                            Method method = (Method)iter.next();
+                        for (Method method : refType.allMethods()) {
                             if (method.name().equals(idMethod)) {
                                 lines = method.allLineLocations();
                             }
@@ -1555,9 +1507,7 @@
                             MessageOutput.println("is not a valid method name", idMethod);
                         }
                     }
-                    Iterator iter = lines.iterator();
-                    while (iter.hasNext()) {
-                        Location line = (Location)iter.next();
+                    for (Location line : lines) {
                         MessageOutput.printDirectln(line.toString());// Special case: use printDirectln()
                     }
                 } else {
@@ -1620,21 +1570,19 @@
                 MessageOutput.println("No local variables");
                 return;
             }
-            Map values = frame.getValues(vars);
+            Map<LocalVariable, Value> values = frame.getValues(vars);
 
             MessageOutput.println("Method arguments:");
-            for (Iterator it = vars.iterator(); it.hasNext(); ) {
-                LocalVariable var = (LocalVariable)it.next();
+            for (LocalVariable var : vars) {
                 if (var.isArgument()) {
-                    Value val = (Value)values.get(var);
+                    Value val = values.get(var);
                     printVar(var, val);
                 }
             }
             MessageOutput.println("Local variables:");
-            for (Iterator it = vars.iterator(); it.hasNext(); ) {
-                LocalVariable var = (LocalVariable)it.next();
+            for (LocalVariable var : vars) {
                 if (!var.isArgument()) {
-                    Value val = (Value)values.get(var);
+                    Value val = values.get(var);
                     printVar(var, val);
                 }
             }
@@ -1647,9 +1595,8 @@
 
     private void dump(ObjectReference obj, ReferenceType refType,
                       ReferenceType refTypeBase) {
-        for (Iterator it = refType.fields().iterator(); it.hasNext(); ) {
+        for (Field field : refType.fields()) {
             StringBuffer o = new StringBuffer();
-            Field field = (Field)it.next();
             o.append("    ");
             if (!refType.equals(refTypeBase)) {
                 o.append(refType.name());
@@ -1666,14 +1613,13 @@
                 dump(obj, sup, refTypeBase);
             }
         } else if (refType instanceof InterfaceType) {
-            List sups = ((InterfaceType)refType).superinterfaces();
-            for (Iterator it = sups.iterator(); it.hasNext(); ) {
-                dump(obj, (ReferenceType)it.next(), refTypeBase);
+            for (InterfaceType sup : ((InterfaceType)refType).superinterfaces()) {
+                dump(obj, sup, refTypeBase);
             }
         } else {
             /* else refType is an instanceof ArrayType */
             if (obj instanceof ArrayReference) {
-                for (Iterator it = ((ArrayReference)obj).getValues().iterator();
+                for (Iterator<Value> it = ((ArrayReference)obj).getValues().iterator();
                      it.hasNext(); ) {
                     MessageOutput.printDirect(it.next().toString());// Special case: use printDirect()
                     if (it.hasNext()) {
@@ -1770,13 +1716,11 @@
                                           new Object [] {owner.name(),
                                                          new Integer (object.entryCount())});
                 }
-                List waiters = object.waitingThreads();
+                List<ThreadReference> waiters = object.waitingThreads();
                 if (waiters.size() == 0) {
                     MessageOutput.println("No waiters");
                 } else {
-                    Iterator iter = waiters.iterator();
-                    while (iter.hasNext()) {
-                        ThreadReference waiter = (ThreadReference)iter.next();
+                    for (ThreadReference waiter : waiters) {
                         MessageOutput.println("Waiting thread:", waiter.name());
                     }
                 }
@@ -1800,13 +1744,11 @@
         ThreadReference thread = threadInfo.getThread();
         try {
             MessageOutput.println("Monitor information for thread", thread.name());
-            List owned = thread.ownedMonitors();
+            List<ObjectReference> owned = thread.ownedMonitors();
             if (owned.size() == 0) {
                 MessageOutput.println("No monitors owned");
             } else {
-                Iterator iter = owned.iterator();
-                while (iter.hasNext()) {
-                    ObjectReference monitor = (ObjectReference)iter.next();
+                for (ObjectReference monitor : owned) {
                     MessageOutput.println("Owned monitor:", monitor.toString());
                 }
             }
@@ -1833,9 +1775,7 @@
         }
         String token = t.nextToken();
         if (token.toLowerCase().equals("all")) {
-            Iterator iter = ThreadInfo.threads().iterator();
-            while (iter.hasNext()) {
-                ThreadInfo threadInfo = (ThreadInfo)iter.next();
+            for (ThreadInfo threadInfo : ThreadInfo.threads()) {
                 printThreadLockInfo(threadInfo);
             }
         } else {
@@ -1930,14 +1870,12 @@
 
     void commandSave(final StringTokenizer t) { // Undocumented command: useful for testing.
         if (!t.hasMoreTokens()) {
-            Set keys = Env.getSaveKeys();
-            Iterator iter = keys.iterator();
-            if (!iter.hasNext()) {
+            Set<String> keys = Env.getSaveKeys();
+            if (keys.isEmpty()) {
                 MessageOutput.println("No saved values");
                 return;
             }
-            while (iter.hasNext()) {
-                String key = (String)iter.next();
+            for (String key : keys) {
                 Value value = Env.getSavedValue(key);
                 if ((value instanceof ObjectReference) &&
                     ((ObjectReference)value).isCollected()) {
@@ -1976,7 +1914,7 @@
         // Overloading is not handled here.
         String methodName = t.nextToken();
 
-        List classes = Env.vm().classesByName(className);
+        List<ReferenceType> classes = Env.vm().classesByName(className);
         // TO DO: handle multiple classes found
         if (classes.size() == 0) {
             if (className.indexOf('.') < 0) {
@@ -1987,17 +1925,14 @@
             return;
         }
 
-        ReferenceType rt = (ReferenceType)classes.get(0);
+        ReferenceType rt = classes.get(0);
         if (!(rt instanceof ClassType)) {
             MessageOutput.println("not a class", className);
             return;
         }
 
         byte[] bytecodes = null;
-        List list = rt.methodsByName(methodName);
-        Iterator iter = list.iterator();
-        while (iter.hasNext()) {
-            Method method = (Method)iter.next();
+        for (Method method : rt.methodsByName(methodName)) {
             if (!method.isAbstract()) {
                 bytecodes = method.bytecodes();
                 break;
@@ -2047,7 +1982,7 @@
             MessageOutput.println("Specify classes to redefine");
         } else {
             String className = t.nextToken();
-            List classes = Env.vm().classesByName(className);
+            List<ReferenceType> classes = Env.vm().classesByName(className);
             if (classes.size() == 0) {
                 MessageOutput.println("No class named", className);
                 return;
@@ -2057,7 +1992,7 @@
                 return;
             }
             Env.setSourcePath(Env.getSourcePath());
-            ReferenceType refType = (ReferenceType)classes.get(0);
+            ReferenceType refType = classes.get(0);
             if (!t.hasMoreTokens()) {
                 MessageOutput.println("Specify file name for class", className);
                 return;
@@ -2074,7 +2009,8 @@
                              new Object [] {fileName, exc.toString()});
                 return;
             }
-            Map<ReferenceType, byte[]> map = new HashMap<ReferenceType, byte[]>();
+            Map<ReferenceType, byte[]> map
+                = new HashMap<ReferenceType, byte[]>();
             map.put(refType, bytes);
             try {
                 Env.vm().redefineClasses(map);
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/Env.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/Env.java	Mon Mar 10 15:07:09 2008 -0700
@@ -89,7 +89,7 @@
         sourceCache.clear();
     }
 
-    static void setSourcePath(List srcList) {
+    static void setSourcePath(List<String> srcList) {
         sourceMapper = new SourceMapper(srcList);
         sourceCache.clear();
     }
@@ -106,10 +106,8 @@
     }
 
     static String excludesString() {
-        Iterator iter = excludes().iterator();
         StringBuffer buffer = new StringBuffer();
-        while (iter.hasNext()) {
-            String pattern = (String)iter.next();
+        for (String pattern : excludes()) {
             buffer.append(pattern);
             buffer.append(",");
         }
@@ -117,25 +115,19 @@
     }
 
     static void addExcludes(StepRequest request) {
-        Iterator iter = excludes().iterator();
-        while (iter.hasNext()) {
-            String pattern = (String)iter.next();
+        for (String pattern : excludes()) {
             request.addClassExclusionFilter(pattern);
         }
     }
 
     static void addExcludes(MethodEntryRequest request) {
-        Iterator iter = excludes().iterator();
-        while (iter.hasNext()) {
-            String pattern = (String)iter.next();
+        for (String pattern : excludes()) {
             request.addClassExclusionFilter(pattern);
         }
     }
 
     static void addExcludes(MethodExitRequest request) {
-        Iterator iter = excludes().iterator();
-        while (iter.hasNext()) {
-            String pattern = (String)iter.next();
+        for (String pattern : excludes()) {
             request.addClassExclusionFilter(pattern);
         }
     }
@@ -175,10 +167,10 @@
         try {
             String fileName = location.sourceName();
 
-            Iterator iter = sourceCache.iterator();
+            Iterator<SourceCode> iter = sourceCache.iterator();
             SourceCode code = null;
             while (iter.hasNext()) {
-                SourceCode candidate = (SourceCode)iter.next();
+                SourceCode candidate = iter.next();
                 if (candidate.fileName().equals(fileName)) {
                     code = candidate;
                     iter.remove();
@@ -269,10 +261,7 @@
         // loaded class whose name matches this limited regular
         // expression is selected.
         idToken = idToken.substring(1);
-        List classes = Env.vm().allClasses();
-        Iterator iter = classes.iterator();
-        while (iter.hasNext()) {
-            ReferenceType type = ((ReferenceType)iter.next());
+        for (ReferenceType type : Env.vm().allClasses()) {
             if (type.name().endsWith(idToken)) {
                 cls = type;
                 break;
@@ -280,21 +269,21 @@
         }
     } else {
             // It's a class name
-            List classes = Env.vm().classesByName(idToken);
+            List<ReferenceType> classes = Env.vm().classesByName(idToken);
             if (classes.size() > 0) {
                 // TO DO: handle multiples
-                cls = (ReferenceType)classes.get(0);
+                cls = classes.get(0);
             }
         }
         return cls;
     }
 
-    static Set getSaveKeys() {
+    static Set<String> getSaveKeys() {
         return savedValues.keySet();
     }
 
     static Value getSavedValue(String key) {
-        return (Value)savedValues.get(key);
+        return savedValues.get(key);
     }
 
     static void setSavedValue(String key, Value value) {
@@ -327,7 +316,7 @@
             if (index >= sourceLines.size()) {
                 return null;
             } else {
-                return (String)sourceLines.get(index);
+                return sourceLines.get(index);
             }
         }
     }
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/EventHandler.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/EventHandler.java	Mon Mar 10 15:07:09 2008 -0700
@@ -150,7 +150,7 @@
                 EventSet eventSet = queue.remove();
                 EventIterator iter = eventSet.eventIterator();
                 while (iter.hasNext()) {
-                    handleExitEvent((Event)iter.next());
+                    handleExitEvent(iter.next());
                 }
             } catch (InterruptedException exc) {
                 // ignore
@@ -183,7 +183,7 @@
              * If any event in the set has a thread associated with it,
              * 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);
         } else {
             thread = null;
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/EventRequestSpec.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/EventRequestSpec.java	Mon Mar 10 15:07:09 2008 -0700
@@ -101,10 +101,8 @@
                  * so that is all we need to examine.
                  */
                 ArrayList<ExceptionRequest> deleteList = new ArrayList<ExceptionRequest>();
-                Iterator iter =
-                    Env.vm().eventRequestManager().exceptionRequests().iterator();
-                while (iter.hasNext()) {
-                    ExceptionRequest er = (ExceptionRequest)iter.next();
+                for (ExceptionRequest er :
+                         Env.vm().eventRequestManager().exceptionRequests()) {
                     if (prs.matches(er.exception())) {
                         deleteList.add (er);
                     }
@@ -115,9 +113,7 @@
     }
 
     private EventRequest resolveAgainstPreparedClasses() throws Exception {
-        Iterator iter = Env.vm().allClasses().iterator();
-        while (iter.hasNext()) {
-            ReferenceType refType = (ReferenceType)iter.next();
+        for (ReferenceType refType : Env.vm().allClasses()) {
             if (refType.isPrepared() && refSpec.matches(refType)) {
                 resolved = resolveEventRequest(refType);
             }
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/EventRequestSpecList.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/EventRequestSpecList.java	Mon Mar 10 15:07:09 2008 -0700
@@ -55,9 +55,7 @@
     boolean resolve(ClassPrepareEvent event) {
         boolean failure = false;
         synchronized(eventRequestSpecs) {
-            Iterator iter = eventRequestSpecs.iterator();
-            while (iter.hasNext()) {
-                EventRequestSpec spec = (EventRequestSpec)iter.next();
+            for (EventRequestSpec spec : eventRequestSpecs) {
                 if (!spec.isResolved()) {
                     try {
                         EventRequest eventRequest = spec.resolve(event);
@@ -77,9 +75,7 @@
     }
 
     void resolveAll() {
-        Iterator iter = eventRequestSpecs.iterator();
-        while (iter.hasNext()) {
-            EventRequestSpec spec = (EventRequestSpec)iter.next();
+        for (EventRequestSpec spec : eventRequestSpecs) {
             try {
                 EventRequest eventRequest = spec.resolveEagerly();
                 if (eventRequest != null) {
@@ -106,16 +102,16 @@
         }
     }
 
-    EventRequestSpec createBreakpoint(String classPattern,
-                                 int line) throws ClassNotFoundException {
+    BreakpointSpec createBreakpoint(String classPattern, int line)
+        throws ClassNotFoundException {
         ReferenceTypeSpec refSpec =
             new PatternReferenceTypeSpec(classPattern);
         return new BreakpointSpec(refSpec, line);
     }
 
-    EventRequestSpec createBreakpoint(String classPattern,
+    BreakpointSpec createBreakpoint(String classPattern,
                                  String methodId,
-                                 List methodArgs)
+                                    List<String> methodArgs)
                                 throws MalformedMemberNameException,
                                        ClassNotFoundException {
         ReferenceTypeSpec refSpec =
@@ -132,7 +128,7 @@
         return new ExceptionSpec(refSpec, notifyCaught, notifyUncaught);
     }
 
-    EventRequestSpec createAccessWatchpoint(String classPattern,
+    WatchpointSpec createAccessWatchpoint(String classPattern,
                                        String fieldId)
                                       throws MalformedMemberNameException,
                                              ClassNotFoundException {
@@ -141,7 +137,7 @@
         return new AccessWatchpointSpec(refSpec, fieldId);
     }
 
-    EventRequestSpec createModificationWatchpoint(String classPattern,
+    WatchpointSpec createModificationWatchpoint(String classPattern,
                                        String fieldId)
                                       throws MalformedMemberNameException,
                                              ClassNotFoundException {
@@ -154,7 +150,7 @@
         synchronized (eventRequestSpecs) {
             int inx = eventRequestSpecs.indexOf(proto);
             if (inx != -1) {
-                EventRequestSpec spec = (EventRequestSpec)eventRequestSpecs.get(inx);
+                EventRequestSpec spec = eventRequestSpecs.get(inx);
                 spec.remove();
                 eventRequestSpecs.remove(inx);
                 return true;
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/SourceMapper.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/SourceMapper.java	Mon Mar 10 15:07:09 2008 -0700
@@ -39,15 +39,13 @@
 
     private final String[] dirs;
 
-    SourceMapper(List sourcepath) {
+    SourceMapper(List<String> sourcepath) {
         /*
          * sourcepath can arrive from the debugee as a List.
          * (via PathSearchingVirtualMachine.classPath())
          */
         List<String> dirList = new ArrayList<String>();
-        Iterator iter = sourcepath.iterator();
-        while (iter.hasNext()) {
-            String element = (String)iter.next();
+        for (String element : sourcepath) {
             //XXX remove .jar and .zip files; we want only directories on
             //the source path. (Bug ID 4186582)
             if ( ! (element.endsWith(".jar") ||
@@ -55,7 +53,7 @@
                 dirList.add(element);
             }
         }
-        dirs = (String[])dirList.toArray(new String[0]);
+        dirs = dirList.toArray(new String[0]);
     }
 
     SourceMapper(String sourcepath) {
@@ -79,7 +77,7 @@
                 dirList.add(s);
             }
         }
-        dirs = (String[])dirList.toArray(new String[0]);
+        dirs = dirList.toArray(new String[0]);
     }
 
     /*
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/TTY.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/TTY.java	Mon Mar 10 15:07:09 2008 -0700
@@ -160,9 +160,7 @@
                 // here the next time.
                 Env.setAtExitMethod(null);
                 EventRequestManager erm = Env.vm().eventRequestManager();
-                Iterator it = erm.methodExitRequests().iterator();
-                while (it.hasNext()) {
-                    EventRequest eReq = (EventRequest)it.next();
+                for (EventRequest eReq : erm.methodExitRequests()) {
                     if (eReq.equals(me.request())) {
                         eReq.disable();
                     }
@@ -178,9 +176,8 @@
     public void vmInterrupted() {
         Thread.yield();  // fetch output
         printCurrentLocation();
-        Iterator it = monitorCommands.iterator();
-        while (it.hasNext()) {
-            StringTokenizer t = new StringTokenizer((String)it.next());
+        for (String cmd : monitorCommands) {
+            StringTokenizer t = new StringTokenizer(cmd);
             t.nextToken();  // get rid of monitor number
             executeCommand(t);
         }
@@ -563,9 +560,8 @@
             ++monitorCount;
             monitorCommands.add(monitorCount + ": " + t.nextToken(""));
         } else {
-            Iterator it = monitorCommands.iterator();
-            while (it.hasNext()) {
-                MessageOutput.printDirectln((String)it.next());// Special case: use printDirectln()
+            for (String cmd : monitorCommands) {
+                MessageOutput.printDirectln(cmd);// Special case: use printDirectln()
             }
         }
     }
@@ -581,9 +577,7 @@
                 return;
             }
             String monStr = monTok + ":";
-            Iterator it = monitorCommands.iterator();
-            while (it.hasNext()) {
-                String cmd = (String)it.next();
+            for (String cmd : monitorCommands) {
                 StringTokenizer ct = new StringTokenizer(cmd);
                 if (ct.nextToken().equals(monStr)) {
                     monitorCommands.remove(cmd);
@@ -768,10 +762,8 @@
     }
 
     private static boolean supportsSharedMemory() {
-        List connectors = Bootstrap.virtualMachineManager().allConnectors();
-        Iterator iter = connectors.iterator();
-        while (iter.hasNext()) {
-            Connector connector = (Connector)iter.next();
+        for (Connector connector :
+                 Bootstrap.virtualMachineManager().allConnectors()) {
             if (connector.transport() == null) {
                 continue;
             }
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/ThreadGroupIterator.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/ThreadGroupIterator.java	Mon Mar 10 15:07:09 2008 -0700
@@ -36,7 +36,7 @@
  * Descend the tree of thread groups.
  * @author Robert G. Field
  */
-class ThreadGroupIterator implements Iterator {
+class ThreadGroupIterator implements Iterator<ThreadGroupReference> {
     private final Stack<Iterator<ThreadGroupReference>> stack = new Stack<Iterator<ThreadGroupReference>>();
 
     ThreadGroupIterator(List<ThreadGroupReference> tgl) {
@@ -53,8 +53,8 @@
         this(Env.vm().topLevelThreadGroups());
     }
 
-    private Iterator top() {
-        return (Iterator)stack.peek();
+    private Iterator<ThreadGroupReference> top() {
+        return stack.peek();
     }
 
     /**
@@ -74,12 +74,12 @@
         return !stack.isEmpty();
     }
 
-    public Object next() {
+    public ThreadGroupReference next() {
         return nextThreadGroup();
     }
 
     public ThreadGroupReference nextThreadGroup() {
-        ThreadGroupReference tg = (ThreadGroupReference)top().next();
+        ThreadGroupReference tg = top().next();
         push(tg.threadGroups());
         return tg;
     }
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/ThreadInfo.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/ThreadInfo.java	Mon Mar 10 15:07:09 2008 -0700
@@ -56,9 +56,7 @@
 
     private static void initThreads() {
         if (!gotInitialThreads) {
-            Iterator iter = Env.vm().allThreads().iterator();
-            while (iter.hasNext()) {
-                ThreadReference thread = (ThreadReference)iter.next();
+            for (ThreadReference thread : Env.vm().allThreads()) {
                 threads.add(new ThreadInfo(thread));
             }
             gotInitialThreads = true;
@@ -113,9 +111,7 @@
         current = null;
         group = null;
         synchronized (threads) {
-            Iterator iter = threads().iterator();
-            while (iter.hasNext()) {
-                ThreadInfo ti = (ThreadInfo)iter.next();
+            for (ThreadInfo ti : threads()) {
                 ti.invalidate();
             }
         }
@@ -163,8 +159,7 @@
         if (group == null) {
             // Current thread group defaults to the first top level
             // thread group.
-            setThreadGroup((ThreadGroupReference)
-                           Env.vm().topLevelThreadGroups().get(0));
+            setThreadGroup(Env.vm().topLevelThreadGroups().get(0));
         }
         return group;
     }
@@ -173,9 +168,7 @@
         ThreadInfo retInfo = null;
 
         synchronized (threads) {
-            Iterator iter = threads().iterator();
-            while (iter.hasNext()) {
-                ThreadInfo ti  = (ThreadInfo)iter.next();
+            for (ThreadInfo ti : threads()) {
                 if (ti.thread.uniqueID() == id) {
                    retInfo = ti;
                    break;
@@ -208,7 +201,7 @@
      *
      * @return a <code>List</code> of the stack frames.
      */
-    List getStack() throws IncompatibleThreadStateException {
+    List<StackFrame> getStack() throws IncompatibleThreadStateException {
         return thread.frames();
     }
 
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/ThreadIterator.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/ThreadIterator.java	Mon Mar 10 15:07:09 2008 -0700
@@ -30,8 +30,8 @@
 import java.util.List;
 import java.util.Iterator;
 
-class ThreadIterator implements Iterator {
-    Iterator it = null;
+class ThreadIterator implements Iterator<ThreadReference> {
+    Iterator<ThreadReference> it = null;
     ThreadGroupIterator tgi;
 
     ThreadIterator(ThreadGroupReference tg) {
@@ -56,12 +56,12 @@
         return true;
     }
 
-    public Object next() {
+    public ThreadReference next() {
         return it.next();
     }
 
     public ThreadReference nextThread() {
-        return (ThreadReference)next();
+        return next();
     }
 
     public void remove() {
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/VMConnection.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/VMConnection.java	Mon Mar 10 15:07:09 2008 -0700
@@ -61,10 +61,8 @@
     }
 
     private Connector findConnector(String name) {
-        List connectors = Bootstrap.virtualMachineManager().allConnectors();
-        Iterator iter = connectors.iterator();
-        while (iter.hasNext()) {
-            Connector connector = (Connector)iter.next();
+        for (Connector connector :
+                 Bootstrap.virtualMachineManager().allConnectors()) {
             if (connector.name().equals(name)) {
                 return connector;
             }
@@ -108,7 +106,7 @@
             String value = token.substring(index + 1,
                                            token.length() - 1); // Remove comma delimiter
 
-            Connector.Argument argument = (Connector.Argument)arguments.get(name);
+            Connector.Argument argument = arguments.get(name);
             if (argument == null) {
                 throw new IllegalArgumentException
                     (MessageOutput.format("Argument is not defined for connector:",
@@ -195,7 +193,7 @@
             return false;
         }
 
-        Connector.Argument argument = (Connector.Argument)connectorArgs.get(name);
+        Connector.Argument argument = connectorArgs.get(name);
         if (argument == null) {
             return false;
         }
@@ -204,7 +202,7 @@
     }
 
     String connectorArg(String name) {
-        Connector.Argument argument = (Connector.Argument)connectorArgs.get(name);
+        Connector.Argument argument = connectorArgs.get(name);
         if (argument == null) {
             return "";
         }
--- a/jdk/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java	Mon Mar 10 15:07:09 2008 -0700
@@ -99,8 +99,7 @@
         }
 
         out.println("<h2>Instance Data Members:</h2>");
-        JavaField[] ff = clazz.getFields();
-        ff = (JavaField[]) ff.clone();
+        JavaField[] ff = clazz.getFields().clone();
         ArraySorter.sort(ff, new Comparer() {
             public int compare(Object lhs, Object rhs) {
                 JavaField left = (JavaField) lhs;
--- a/jdk/src/share/classes/com/sun/tools/hat/internal/server/PlatformClasses.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/hat/internal/server/PlatformClasses.java	Mon Mar 10 15:07:09 2008 -0700
@@ -90,9 +90,7 @@
                     // is the right thing to do anyway.
                 }
             }
-            int num = list.size();
-            names = new String[num];
-            names = (String[]) list.toArray(names);
+            names = list.toArray(new String[list.size()]);
         }
         return names;
     }
--- a/jdk/src/share/classes/com/sun/tools/jdi/AbstractLauncher.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/AbstractLauncher.java	Mon Mar 10 15:07:09 2008 -0700
@@ -119,7 +119,7 @@
 
         String[] tokenArray = new String[tokenList.size()];
         for (int i = 0; i < tokenList.size(); i++) {
-            tokenArray[i] = (String)tokenList.get(i);
+            tokenArray[i] = tokenList.get(i);
         }
         return tokenArray;
     }
--- a/jdk/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -95,11 +95,8 @@
     }
 
     public List<ClassType> subclasses() {
-        List<ReferenceType> all = vm.allClasses();
         List<ClassType> subs = new ArrayList<ClassType>();
-        Iterator iter = all.iterator();
-        while (iter.hasNext()) {
-            ReferenceType refType = (ReferenceType)iter.next();
+        for (ReferenceType refType : vm.allClasses()) {
             if (refType instanceof ClassType) {
                 ClassType clazz = (ClassType)refType;
                 ClassType superclass = clazz.superclass();
@@ -223,7 +220,7 @@
 
         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;
         try {
             PacketStream stream =
@@ -271,7 +268,7 @@
 
         List<Value> arguments = method.validateAndPrepareArgumentsForInvoke(
                                                        origArguments);
-        ValueImpl[] args = (ValueImpl[])arguments.toArray(new ValueImpl[0]);
+        ValueImpl[] args = arguments.toArray(new ValueImpl[0]);
         JDWP.ClassType.NewInstance ret = null;
         try {
             PacketStream stream =
@@ -301,11 +298,8 @@
     }
 
     public Method concreteMethodByName(String name, String signature)  {
-       List methods = visibleMethods();
        Method method = null;
-       Iterator iter = methods.iterator();
-       while (iter.hasNext()) {
-           Method candidate = (Method)iter.next();
+       for (Method candidate : visibleMethods()) {
            if (candidate.name().equals(name) &&
                candidate.signature().equals(signature) &&
                !candidate.isAbstract()) {
@@ -330,9 +324,7 @@
          * Avoid duplicate checking on each method by iterating through
          * duplicate-free allInterfaces() rather than recursing
          */
-        Iterator iter = allInterfaces().iterator();
-        while (iter.hasNext()) {
-            InterfaceType interfaze = (InterfaceType)iter.next();
+        for (InterfaceType interfaze : allInterfaces()) {
             list.addAll(interfaze.methods());
         }
 
--- a/jdk/src/share/classes/com/sun/tools/jdi/ConcreteMethodImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/ConcreteMethodImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -247,7 +247,7 @@
 
     public byte[] bytecodes() {
         byte[] bytecodes = (bytecodesRef == null) ? null :
-                                     (byte[])bytecodesRef.get();
+                                     bytecodesRef.get();
         if (bytecodes == null) {
             try {
                 bytecodes = JDWP.Method.Bytecodes.
@@ -262,7 +262,7 @@
          * to return the cached bytecodes directly; instead, we
          * make a clone at the cost of using more memory.
          */
-        return (byte[])bytecodes.clone();
+        return bytecodes.clone();
     }
 
     int argSlotCount() throws AbsentInformationException {
@@ -279,7 +279,7 @@
         String stratumID = stratum.id();
         SoftLocationXRefs info =
             (softOtherLocationXRefsRef == null) ? null :
-               (SoftLocationXRefs)softOtherLocationXRefsRef.get();
+               softOtherLocationXRefsRef.get();
         if (info != null && info.stratumID.equals(stratumID)) {
             return info;
         }
@@ -348,7 +348,7 @@
 
     private SoftLocationXRefs getBaseLocations() {
         SoftLocationXRefs info = (softBaseLocationXRefsRef == null) ? null :
-                                     (SoftLocationXRefs)softBaseLocationXRefsRef.get();
+                                     softBaseLocationXRefsRef.get();
         if (info != null) {
             return info;
         }
--- a/jdk/src/share/classes/com/sun/tools/jdi/EventSetImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/EventSetImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -56,10 +56,8 @@
     public String toString() {
         String string = "event set, policy:" + suspendPolicy +
                         ", count:" + this.size() + " = {";
-        Iterator iter = this.iterator();
         boolean first = true;
-        while (iter.hasNext()) {
-            Event event = (Event)iter.next();
+        for (Event event : this) {
             if (!first) {
                 string += ", ";
             }
@@ -787,9 +785,7 @@
     }
 
     private ThreadReference eventThread() {
-        Iterator iter = this.iterator();
-        while (iter.hasNext()) {
-            Event event = (Event)iter.next();
+        for (Event event : this) {
             if (event instanceof ThreadedEventImpl) {
                 return ((ThreadedEventImpl)event).thread();
             }
@@ -846,7 +842,7 @@
         }
 
         public Event nextEvent() {
-            return (Event)next();
+            return next();
         }
 
         public void remove() {
--- a/jdk/src/share/classes/com/sun/tools/jdi/JNITypeParser.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/JNITypeParser.java	Mon Mar 10 15:07:09 2008 -0700
@@ -82,7 +82,7 @@
     }
 
     String typeName() {
-        return (String)typeNameList().get(typeNameList().size()-1);
+        return typeNameList().get(typeNameList().size()-1);
     }
 
     List<String> argumentTypeNames() {
@@ -90,7 +90,7 @@
     }
 
     String signature() {
-        return (String)signatureList().get(signatureList().size()-1);
+        return signatureList().get(signatureList().size()-1);
     }
 
     List<String> argumentSignatures() {
--- a/jdk/src/share/classes/com/sun/tools/jdi/MethodImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/MethodImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -158,7 +158,7 @@
 
     Type argumentType(int index) throws ClassNotLoadedException {
         ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType();
-        String signature = (String)argumentSignatures().get(index);
+        String signature = argumentSignatures().get(index);
         return enclosing.findType(signature);
     }
 
@@ -263,10 +263,10 @@
             return argumentType(index);
         }
         public String typeName(){
-            return (String)argumentTypeNames().get(index);
+            return argumentTypeNames().get(index);
         }
         public String signature() {
-            return (String)argumentSignatures().get(index);
+            return argumentSignatures().get(index);
         }
         public Type findType(String signature) throws ClassNotLoadedException {
             return MethodImpl.this.findType(signature);
@@ -307,7 +307,7 @@
             arguments.add(argArray);
             return;
         }
-        Value nthArgValue = (Value)arguments.get(paramCount - 1);
+        Value nthArgValue = arguments.get(paramCount - 1);
         if (nthArgValue == null) {
             return;
         }
@@ -371,7 +371,7 @@
         }
 
         for (int i = 0; i < argSize; i++) {
-            Value value = (Value)arguments.get(i);
+            Value value = arguments.get(i);
             value = ValueImpl.prepareForAssignment(value,
                                                    new ArgumentContainer(i));
             arguments.set(i, value);
@@ -386,11 +386,11 @@
         sb.append(name());
         sb.append("(");
         boolean first = true;
-        for (Iterator it = argumentTypeNames().iterator(); it.hasNext();) {
+        for (String name : argumentTypeNames()) {
             if (!first) {
                 sb.append(", ");
             }
-            sb.append((String)it.next());
+            sb.append(name);
             first = false;
         }
         sb.append(")");
--- a/jdk/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -383,7 +383,7 @@
         List<Value> arguments = method.validateAndPrepareArgumentsForInvoke(
                                                   origArguments);
 
-        ValueImpl[] args = (ValueImpl[])arguments.toArray(new ValueImpl[0]);
+        ValueImpl[] args = arguments.toArray(new ValueImpl[0]);
         JDWP.ObjectReference.InvokeMethod ret;
         try {
             PacketStream stream =
@@ -583,7 +583,7 @@
         // Validate assignment
         ReferenceType destType = (ReferenceTypeImpl)destination.type();
         ReferenceTypeImpl myType = (ReferenceTypeImpl)referenceType();
-        if (!myType.isAssignableTo((ReferenceType)destType)) {
+        if (!myType.isAssignableTo(destType)) {
             JNITypeParser parser = new JNITypeParser(destType.signature());
             String destTypeName = parser.typeName();
             throw new InvalidTypeException("Can't assign " +
--- a/jdk/src/share/classes/com/sun/tools/jdi/PacketStream.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/PacketStream.java	Mon Mar 10 15:07:09 2008 -0700
@@ -485,7 +485,7 @@
      * Read field represented as vm specific byte sequence.
      */
     Field readField() {
-        ReferenceTypeImpl refType = (ReferenceTypeImpl)readReferenceType();
+        ReferenceTypeImpl refType = readReferenceType();
         long fieldRef = readFieldRef();
         return refType.getFieldMirror(fieldRef);
     }
--- a/jdk/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -59,7 +59,7 @@
     private boolean constantPoolInfoGotten = false;
     private int constanPoolCount;
     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 */
     private static final String ABSENT_BASE_SOURCE_NAME = "**ABSENT_BASE_SOURCE_NAME**";
@@ -352,13 +352,10 @@
     abstract List<? extends ReferenceType> inheritedTypes();
 
     void addVisibleFields(List<Field> visibleList, Map<String, Field> visibleTable, List<String> ambiguousNames) {
-        List<Field> list = visibleFields();
-        Iterator iter = list.iterator();
-        while (iter.hasNext()) {
-            Field field = (Field)iter.next();
+        for (Field field : visibleFields()) {
             String name = field.name();
             if (!ambiguousNames.contains(name)) {
-                Field duplicate = (Field)visibleTable.get(name);
+                Field duplicate = visibleTable.get(name);
                 if (duplicate == null) {
                     visibleList.add(field);
                     visibleTable.put(name, field);
@@ -402,10 +399,8 @@
          * hide.
          */
         List<Field> retList = new ArrayList<Field>(fields());
-        iter = retList.iterator();
-        while (iter.hasNext()) {
-            Field field = (Field)iter.next();
-            Field hidden = (Field)visibleTable.get(field.name());
+        for (Field field : retList) {
+            Field hidden = visibleTable.get(field.name());
             if (hidden != null) {
                 visibleList.remove(hidden);
             }
@@ -515,12 +510,9 @@
      * methods.
      */
     void addToMethodMap(Map<String, Method> methodMap, List<Method> methodList) {
-        Iterator iter = methodList.iterator();
-        while (iter.hasNext()) {
-            Method method = (Method)iter.next();
+        for (Method method : methodList)
             methodMap.put(method.name().concat(method.signature()), method);
         }
-    }
 
     abstract void addVisibleMethods(Map<String, Method> methodMap);
 
@@ -549,9 +541,7 @@
     public List<Method> methodsByName(String name) {
         List<Method> methods = visibleMethods();
         ArrayList<Method> retList = new ArrayList<Method>(methods.size());
-        Iterator iter = methods.iterator();
-        while (iter.hasNext()) {
-            Method candidate = (Method)iter.next();
+        for (Method candidate : methods) {
             if (candidate.name().equals(name)) {
                 retList.add(candidate);
             }
@@ -563,9 +553,7 @@
     public List<Method> methodsByName(String name, String signature) {
         List<Method> methods = visibleMethods();
         ArrayList<Method> retList = new ArrayList<Method>(methods.size());
-        Iterator iter = methods.iterator();
-        while (iter.hasNext()) {
-            Method candidate = (Method)iter.next();
+        for (Method candidate : methods) {
             if (candidate.name().equals(name) &&
                 candidate.signature().equals(signature)) {
                 retList.add(candidate);
@@ -706,7 +694,7 @@
     }
 
     public String sourceName() throws AbsentInformationException {
-        return (String)(sourceNames(vm.getDefaultStratum()).get(0));
+        return sourceNames(vm.getDefaultStratum()).get(0);
     }
 
     public List<String> sourceNames(String stratumID)
@@ -796,7 +784,7 @@
         if (!vm.canGetSourceDebugExtension()) {
             return NO_SDE_INFO_MARK;
         }
-        SDE sde = (sdeRef == null) ?  null : (SDE)sdeRef.get();
+        SDE sde = (sdeRef == null) ?  null : sdeRef.get();
         if (sde == null) {
             String extension = null;
             try {
@@ -1034,13 +1022,13 @@
             throw exc;
         }
         if (constantPoolBytesRef != null) {
-            byte[] cpbytes = (byte[])constantPoolBytesRef.get();
+            byte[] cpbytes = constantPoolBytesRef.get();
             /*
              * Arrays are always modifiable, so it is a little unsafe
              * to return the cached bytecodes directly; instead, we
              * make a clone at the cost of using more memory.
              */
-            return (byte[])cpbytes.clone();
+            return cpbytes.clone();
         } else {
             return null;
         }
--- a/jdk/src/share/classes/com/sun/tools/jdi/SDE.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/SDE.java	Mon Mar 10 15:07:09 2008 -0700
@@ -327,7 +327,7 @@
 
         ignoreWhite();
         while (((ch = sdeRead()) != '\n') && (ch != '\r')) {
-            sb.append((char)ch);
+            sb.append(ch);
         }
         // check for CR LF
         if ((ch == '\r') && (sdePeek() == '\n')) {
--- a/jdk/src/share/classes/com/sun/tools/jdi/StackFrameImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/StackFrameImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -162,7 +162,7 @@
             for (LocalVariable variable : allVariables) {
                 String name = variable.name();
                 if (variable.isVisible(this)) {
-                    LocalVariable existing = (LocalVariable)map.get(name);
+                    LocalVariable existing = map.get(name);
                     if ((existing == null) ||
                         ((LocalVariableImpl)variable).hides(existing)) {
                         map.put(name, variable);
@@ -330,7 +330,7 @@
             slot = 1;
         }
         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);
             if (sigChar == 'J' || sigChar == 'D') {
                 slot++;
--- a/jdk/src/share/classes/com/sun/tools/jdi/TargetVM.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/TargetVM.java	Mon Mar 10 15:07:09 2008 -0700
@@ -148,7 +148,7 @@
                 idString = String.valueOf(p.id);
 
                 synchronized(waitingQueue) {
-                    p2 = (Packet)waitingQueue.get(idString);
+                    p2 = waitingQueue.get(idString);
 
                     if (p2 != null)
                         waitingQueue.remove(idString);
--- a/jdk/src/share/classes/com/sun/tools/jdi/ThreadGroupReferenceImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/ThreadGroupReferenceImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -86,30 +86,22 @@
     }
 
     public void suspend() {
-        List threads = threads();
-        Iterator iter = threads.iterator();
-        while (iter.hasNext()) {
-                ((ThreadReference)iter.next()).suspend();
+        for (ThreadReference thread : threads()) {
+            thread.suspend();
         }
 
-        List groups = threadGroups();
-        iter = groups.iterator();
-        while (iter.hasNext()) {
-                ((ThreadGroupReference)iter.next()).suspend();
+        for (ThreadGroupReference threadGroup : threadGroups()) {
+            threadGroup.suspend();
         }
     }
 
     public void resume() {
-        List threads = threads();
-        Iterator iter = threads.iterator();
-        while (iter.hasNext()) {
-                ((ThreadReference)iter.next()).resume();
+        for (ThreadReference thread : threads()) {
+            thread.resume();
         }
 
-        List groups = threadGroups();
-        iter = groups.iterator();
-        while (iter.hasNext()) {
-                ((ThreadGroupReference)iter.next()).resume();
+        for (ThreadGroupReference threadGroup : threadGroups()) {
+            threadGroup.resume();
         }
     }
 
--- a/jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -1191,8 +1191,7 @@
                 }
                 requests = new JDWP.VirtualMachine.DisposeObjects.Request[size];
                 for (int i = 0; i < requests.length; i++) {
-                    SoftObjectReference ref =
-                        (SoftObjectReference)batchedDisposeRequests.get(i);
+                    SoftObjectReference ref = batchedDisposeRequests.get(i);
                     if ((traceFlags & TRACE_OBJREFS) != 0) {
                         printTrace("Disposing object " + ref.key().longValue() +
                                    " (ref count = " + ref.count() + ")");
@@ -1436,7 +1435,7 @@
        }
 
        ObjectReferenceImpl object() {
-           return (ObjectReferenceImpl)get();
+           return get();
        }
    }
 }
--- a/jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -92,7 +92,7 @@
             Connector connector;
 
             try {
-                connector = (Connector)connectors.next();
+                connector = connectors.next();
             } catch (ThreadDeath x) {
                 throw x;
             } catch (Exception x) {
@@ -121,7 +121,7 @@
             TransportService transportService;
 
             try {
-                transportService = (TransportService)transportServices.next();
+                transportService = transportServices.next();
             } catch (ThreadDeath x) {
                 throw x;
             } catch (Exception x) {
--- a/jdk/src/share/classes/java/io/ObjectInputStream.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/io/ObjectInputStream.java	Mon Mar 10 15:07:09 2008 -0700
@@ -212,7 +212,8 @@
     private static final Object unsharedMarker = new Object();
 
     /** 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 {
         primClasses.put("boolean", boolean.class);
         primClasses.put("byte", byte.class);
@@ -620,7 +621,7 @@
         try {
             return Class.forName(name, false, latestUserDefinedLoader());
         } catch (ClassNotFoundException ex) {
-            Class cl = (Class) primClasses.get(name);
+            Class<?> cl = primClasses.get(name);
             if (cl != null) {
                 return cl;
             } else {
@@ -1254,11 +1255,11 @@
      * override security-sensitive non-final methods.  Returns true if subclass
      * is "safe", false otherwise.
      */
-    private static boolean auditSubclass(final Class subcl) {
+    private static boolean auditSubclass(final Class<?> subcl) {
         Boolean result = AccessController.doPrivileged(
             new PrivilegedAction<Boolean>() {
                 public Boolean run() {
-                    for (Class cl = subcl;
+                    for (Class<?> cl = subcl;
                          cl != ObjectInputStream.class;
                          cl = cl.getSuperclass())
                     {
@@ -2217,9 +2218,9 @@
             try {
                 while (list != null) {
                     AccessController.doPrivileged(
-                        new PrivilegedExceptionAction()
+                        new PrivilegedExceptionAction<Void>()
                     {
-                        public Object run() throws InvalidObjectException {
+                        public Void run() throws InvalidObjectException {
                             list.obj.validateObject();
                             return null;
                         }
--- a/jdk/src/share/classes/java/io/ObjectStreamClass.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/io/ObjectStreamClass.java	Mon Mar 10 15:07:09 2008 -0700
@@ -77,7 +77,7 @@
         NO_FIELDS;
 
     /** reflection factory for obtaining serialization constructors */
-    private static final ReflectionFactory reflFactory = (ReflectionFactory)
+    private static final ReflectionFactory reflFactory =
         AccessController.doPrivileged(
             new ReflectionFactory.GetReflectionFactoryAction());
 
@@ -216,10 +216,10 @@
     public long getSerialVersionUID() {
         // REMIND: synchronize instead of relying on volatile?
         if (suid == null) {
-            suid = (Long) AccessController.doPrivileged(
-                new PrivilegedAction() {
-                    public Object run() {
-                        return Long.valueOf(computeDefaultSUID(cl));
+            suid = AccessController.doPrivileged(
+                new PrivilegedAction<Long>() {
+                    public Long run() {
+                        return computeDefaultSUID(cl);
                     }
                 }
             );
@@ -392,8 +392,8 @@
             }
             if (interrupted) {
                 AccessController.doPrivileged(
-                    new PrivilegedAction() {
-                        public Object run() {
+                    new PrivilegedAction<Void>() {
+                        public Void run() {
                             Thread.currentThread().interrupt();
                             return null;
                         }
@@ -427,8 +427,8 @@
         localDesc = this;
 
         if (serializable) {
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+            AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                public Void run() {
                     if (isEnum) {
                         suid = Long.valueOf(0);
                         fields = NO_FIELDS;
@@ -802,7 +802,7 @@
      * non-primitive types, and any other non-null type matches assignable
      * 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++) {
             ObjectStreamField f = fields[i];
             if (f.getName().equals(name)) {
@@ -811,7 +811,7 @@
                 {
                     return f;
                 }
-                Class ftype = f.getType();
+                Class<?> ftype = f.getType();
                 if (ftype != null && type.isAssignableFrom(ftype)) {
                     return f;
                 }
@@ -1130,7 +1130,7 @@
     private ClassDataSlot[] getClassDataLayout0()
         throws InvalidClassException
     {
-        ArrayList slots = new ArrayList();
+        ArrayList<ClassDataSlot> slots = new ArrayList<ClassDataSlot>();
         Class start = cl, end = cl;
 
         // locate closest non-serializable superclass
@@ -1171,8 +1171,7 @@
 
         // order slots from superclass -> subclass
         Collections.reverse(slots);
-        return (ClassDataSlot[])
-            slots.toArray(new ClassDataSlot[slots.size()]);
+        return slots.toArray(new ClassDataSlot[slots.size()]);
     }
 
     /**
@@ -1309,9 +1308,9 @@
      * Access checks are disabled on the returned constructor (if any), since
      * the defining class may still be non-public.
      */
-    private static Constructor getExternalizableConstructor(Class cl) {
+    private static Constructor getExternalizableConstructor(Class<?> cl) {
         try {
-            Constructor cons = cl.getDeclaredConstructor((Class[]) null);
+            Constructor cons = cl.getDeclaredConstructor((Class<?>[]) null);
             cons.setAccessible(true);
             return ((cons.getModifiers() & Modifier.PUBLIC) != 0) ?
                 cons : null;
@@ -1325,15 +1324,15 @@
      * superclass, or null if none found.  Access checks are disabled on the
      * returned constructor (if any).
      */
-    private static Constructor getSerializableConstructor(Class cl) {
-        Class initCl = cl;
+    private static Constructor getSerializableConstructor(Class<?> cl) {
+        Class<?> initCl = cl;
         while (Serializable.class.isAssignableFrom(initCl)) {
             if ((initCl = initCl.getSuperclass()) == null) {
                 return null;
             }
         }
         try {
-            Constructor cons = initCl.getDeclaredConstructor((Class[]) null);
+            Constructor cons = initCl.getDeclaredConstructor((Class<?>[]) null);
             int mods = cons.getModifiers();
             if ((mods & Modifier.PRIVATE) != 0 ||
                 ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) == 0 &&
@@ -1355,12 +1354,12 @@
      * null if no match found.  Access checks are disabled on the returned
      * method (if any).
      */
-    private static Method getInheritableMethod(Class cl, String name,
+    private static Method getInheritableMethod(Class<?> cl, String name,
                                                Class[] argTypes,
                                                Class returnType)
     {
         Method meth = null;
-        Class defCl = cl;
+        Class<?> defCl = cl;
         while (defCl != null) {
             try {
                 meth = defCl.getDeclaredMethod(name, argTypes);
@@ -1391,9 +1390,9 @@
      * class, or null if none found.  Access checks are disabled on the
      * returned method (if any).
      */
-    private static Method getPrivateMethod(Class cl, String name,
-                                           Class[] argTypes,
-                                           Class returnType)
+    private static Method getPrivateMethod(Class<?> cl, String name,
+                                           Class<?>[] argTypes,
+                                           Class<?> returnType)
     {
         try {
             Method meth = cl.getDeclaredMethod(name, argTypes);
@@ -1567,7 +1566,7 @@
 
         ObjectStreamField[] boundFields =
             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++) {
             ObjectStreamField spf = serialPersistentFields[i];
@@ -1605,7 +1604,7 @@
      */
     private static ObjectStreamField[] getDefaultSerialFields(Class cl) {
         Field[] clFields = cl.getDeclaredFields();
-        ArrayList list = new ArrayList();
+        ArrayList<ObjectStreamField> list = new ArrayList<ObjectStreamField>();
         int mask = Modifier.STATIC | Modifier.TRANSIENT;
 
         for (int i = 0; i < clFields.length; i++) {
@@ -1615,7 +1614,7 @@
         }
         int size = list.size();
         return (size == 0) ? NO_FIELDS :
-            (ObjectStreamField[]) list.toArray(new ObjectStreamField[size]);
+            list.toArray(new ObjectStreamField[size]);
     }
 
     /**
@@ -1688,11 +1687,9 @@
             for (int i = 0; i < fields.length; i++) {
                 fieldSigs[i] = new MemberSignature(fields[i]);
             }
-            Arrays.sort(fieldSigs, new Comparator() {
-                public int compare(Object o1, Object o2) {
-                    String name1 = ((MemberSignature) o1).name;
-                    String name2 = ((MemberSignature) o2).name;
-                    return name1.compareTo(name2);
+            Arrays.sort(fieldSigs, new Comparator<MemberSignature>() {
+                public int compare(MemberSignature ms1, MemberSignature ms2) {
+                    return ms1.name.compareTo(ms2.name);
                 }
             });
             for (int i = 0; i < fieldSigs.length; i++) {
@@ -1721,11 +1718,9 @@
             for (int i = 0; i < cons.length; i++) {
                 consSigs[i] = new MemberSignature(cons[i]);
             }
-            Arrays.sort(consSigs, new Comparator() {
-                public int compare(Object o1, Object o2) {
-                    String sig1 = ((MemberSignature) o1).signature;
-                    String sig2 = ((MemberSignature) o2).signature;
-                    return sig1.compareTo(sig2);
+            Arrays.sort(consSigs, new Comparator<MemberSignature>() {
+                public int compare(MemberSignature ms1, MemberSignature ms2) {
+                    return ms1.signature.compareTo(ms2.signature);
                 }
             });
             for (int i = 0; i < consSigs.length; i++) {
@@ -1746,10 +1741,8 @@
             for (int i = 0; i < methods.length; i++) {
                 methSigs[i] = new MemberSignature(methods[i]);
             }
-            Arrays.sort(methSigs, new Comparator() {
-                public int compare(Object o1, Object o2) {
-                    MemberSignature ms1 = (MemberSignature) o1;
-                    MemberSignature ms2 = (MemberSignature) o2;
+            Arrays.sort(methSigs, new Comparator<MemberSignature>() {
+                public int compare(MemberSignature ms1, MemberSignature ms2) {
                     int comp = ms1.name.compareTo(ms2.name);
                     if (comp == 0) {
                         comp = ms1.signature.compareTo(ms2.signature);
@@ -1859,7 +1852,7 @@
             keys = new long[nfields];
             offsets = new int[nfields];
             typeCodes = new char[nfields];
-            ArrayList typeList = new ArrayList();
+            ArrayList<Class<?>> typeList = new ArrayList<Class<?>>();
 
             for (int i = 0; i < nfields; i++) {
                 ObjectStreamField f = fields[i];
@@ -1873,7 +1866,7 @@
                 }
             }
 
-            types = (Class[]) typeList.toArray(new Class[typeList.size()]);
+            types = typeList.toArray(new Class<?>[typeList.size()]);
             numPrimFields = nfields - types.length;
         }
 
--- a/jdk/src/share/classes/java/lang/Class.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/lang/Class.java	Mon Mar 10 15:07:09 2008 -0700
@@ -345,9 +345,9 @@
                 // since we have to do the security check here anyway
                 // (the stack depth is wrong for the Constructor's
                 // security check to work)
-                java.security.AccessController.doPrivileged
-                    (new java.security.PrivilegedAction() {
-                            public Object run() {
+                java.security.AccessController.doPrivileged(
+                    new java.security.PrivilegedAction<Void>() {
+                        public Void run() {
                                 c.setAccessible(true);
                                 return null;
                             }
@@ -1302,10 +1302,10 @@
         // out anything other than public members and (2) public member access
         // has already been ok'd by the SecurityManager.
 
-        Class[] result = (Class[]) java.security.AccessController.doPrivileged
-            (new java.security.PrivilegedAction() {
-                public Object run() {
-                    java.util.List<Class> list = new java.util.ArrayList();
+        return java.security.AccessController.doPrivileged(
+            new java.security.PrivilegedAction<Class[]>() {
+                public Class[] run() {
+                    List<Class> list = new ArrayList<Class>();
                     Class currentClass = Class.this;
                     while (currentClass != null) {
                         Class[] members = currentClass.getDeclaredClasses();
@@ -1316,12 +1316,9 @@
                         }
                         currentClass = currentClass.getSuperclass();
                     }
-                    Class[] empty = {};
-                    return list.toArray(empty);
+                    return list.toArray(new Class[0]);
                 }
             });
-
-        return result;
     }
 
 
@@ -2215,15 +2212,15 @@
 
     // Caches for certain reflective results
     private static boolean useCaches = true;
-    private volatile transient SoftReference declaredFields;
-    private volatile transient SoftReference publicFields;
-    private volatile transient SoftReference declaredMethods;
-    private volatile transient SoftReference publicMethods;
-    private volatile transient SoftReference declaredConstructors;
-    private volatile transient SoftReference publicConstructors;
+    private volatile transient SoftReference<Field[]> declaredFields;
+    private volatile transient SoftReference<Field[]> publicFields;
+    private volatile transient SoftReference<Method[]> declaredMethods;
+    private volatile transient SoftReference<Method[]> publicMethods;
+    private volatile transient SoftReference<Constructor<T>[]> declaredConstructors;
+    private volatile transient SoftReference<Constructor<T>[]> publicConstructors;
     // Intermediate results for getFields and getMethods
-    private volatile transient SoftReference declaredPublicFields;
-    private volatile transient SoftReference declaredPublicMethods;
+    private volatile transient SoftReference<Field[]> declaredPublicFields;
+    private volatile transient SoftReference<Method[]> declaredPublicMethods;
 
     // Incremented by the VM on each call to JVM TI RedefineClasses()
     // that redefines this class or a superclass.
@@ -2295,11 +2292,11 @@
             clearCachesOnClassRedefinition();
             if (publicOnly) {
                 if (declaredPublicFields != null) {
-                    res = (Field[]) declaredPublicFields.get();
+                    res = declaredPublicFields.get();
                 }
             } else {
                 if (declaredFields != null) {
-                    res = (Field[]) declaredFields.get();
+                    res = declaredFields.get();
                 }
             }
             if (res != null) return res;
@@ -2308,9 +2305,9 @@
         res = Reflection.filterFields(this, getDeclaredFields0(publicOnly));
         if (useCaches) {
             if (publicOnly) {
-                declaredPublicFields = new SoftReference(res);
+                declaredPublicFields = new SoftReference<Field[]>(res);
             } else {
-                declaredFields = new SoftReference(res);
+                declaredFields = new SoftReference<Field[]>(res);
             }
         }
         return res;
@@ -2319,22 +2316,22 @@
     // Returns an array of "root" fields. These Field objects must NOT
     // be propagated to the outside world, but must instead be copied
     // via ReflectionFactory.copyField.
-    private Field[] privateGetPublicFields(Set traversedInterfaces) {
+    private Field[] privateGetPublicFields(Set<Class<?>> traversedInterfaces) {
         checkInitted();
         Field[] res = null;
         if (useCaches) {
             clearCachesOnClassRedefinition();
             if (publicFields != null) {
-                res = (Field[]) publicFields.get();
+                res = publicFields.get();
             }
             if (res != null) return res;
         }
 
         // No cached value available; compute value recursively.
         // Traverse in correct order for getField().
-        List fields = new ArrayList();
+        List<Field> fields = new ArrayList<Field>();
         if (traversedInterfaces == null) {
-            traversedInterfaces = new HashSet();
+            traversedInterfaces = new HashSet<Class<?>>();
         }
 
         // Local fields
@@ -2342,9 +2339,7 @@
         addAll(fields, tmp);
 
         // Direct superinterfaces, recursively
-        Class[] interfaces = getInterfaces();
-        for (int i = 0; i < interfaces.length; i++) {
-            Class c = interfaces[i];
+        for (Class<?> c : getInterfaces()) {
             if (!traversedInterfaces.contains(c)) {
                 traversedInterfaces.add(c);
                 addAll(fields, c.privateGetPublicFields(traversedInterfaces));
@@ -2353,7 +2348,7 @@
 
         // Direct superclass, recursively
         if (!isInterface()) {
-            Class c = getSuperclass();
+            Class<?> c = getSuperclass();
             if (c != null) {
                 addAll(fields, c.privateGetPublicFields(traversedInterfaces));
             }
@@ -2362,12 +2357,12 @@
         res = new Field[fields.size()];
         fields.toArray(res);
         if (useCaches) {
-            publicFields = new SoftReference(res);
+            publicFields = new SoftReference<Field[]>(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++) {
             c.add(o[i]);
         }
@@ -2383,18 +2378,18 @@
     // Returns an array of "root" constructors. These Constructor
     // objects must NOT be propagated to the outside world, but must
     // instead be copied via ReflectionFactory.copyConstructor.
-    private Constructor[] privateGetDeclaredConstructors(boolean publicOnly) {
+    private Constructor<T>[] privateGetDeclaredConstructors(boolean publicOnly) {
         checkInitted();
-        Constructor[] res = null;
+        Constructor<T>[] res = null;
         if (useCaches) {
             clearCachesOnClassRedefinition();
             if (publicOnly) {
                 if (publicConstructors != null) {
-                    res = (Constructor[]) publicConstructors.get();
+                    res = publicConstructors.get();
                 }
             } else {
                 if (declaredConstructors != null) {
-                    res = (Constructor[]) declaredConstructors.get();
+                    res = declaredConstructors.get();
                 }
             }
             if (res != null) return res;
@@ -2407,9 +2402,9 @@
         }
         if (useCaches) {
             if (publicOnly) {
-                publicConstructors = new SoftReference(res);
+                publicConstructors = new SoftReference<Constructor<T>[]>(res);
             } else {
-                declaredConstructors = new SoftReference(res);
+                declaredConstructors = new SoftReference<Constructor<T>[]>(res);
             }
         }
         return res;
@@ -2431,11 +2426,11 @@
             clearCachesOnClassRedefinition();
             if (publicOnly) {
                 if (declaredPublicMethods != null) {
-                    res = (Method[]) declaredPublicMethods.get();
+                    res = declaredPublicMethods.get();
                 }
             } else {
                 if (declaredMethods != null) {
-                    res = (Method[]) declaredMethods.get();
+                    res = declaredMethods.get();
                 }
             }
             if (res != null) return res;
@@ -2444,9 +2439,9 @@
         res = Reflection.filterMethods(this, getDeclaredMethods0(publicOnly));
         if (useCaches) {
             if (publicOnly) {
-                declaredPublicMethods = new SoftReference(res);
+                declaredPublicMethods = new SoftReference<Method[]>(res);
             } else {
-                declaredMethods = new SoftReference(res);
+                declaredMethods = new SoftReference<Method[]>(res);
             }
         }
         return res;
@@ -2552,7 +2547,7 @@
         if (useCaches) {
             clearCachesOnClassRedefinition();
             if (publicMethods != null) {
-                res = (Method[]) publicMethods.get();
+                res = publicMethods.get();
             }
             if (res != null) return res;
         }
@@ -2602,7 +2597,7 @@
         methods.compactAndTrim();
         res = methods.getArray();
         if (useCaches) {
-            publicMethods = new SoftReference(res);
+            publicMethods = new SoftReference<Method[]>(res);
         }
         return res;
     }
@@ -2713,11 +2708,11 @@
     private Constructor<T> getConstructor0(Class[] parameterTypes,
                                         int which) throws NoSuchMethodException
     {
-        Constructor[] constructors = privateGetDeclaredConstructors((which == Member.PUBLIC));
-        for (int i = 0; i < constructors.length; i++) {
+        Constructor<T>[] constructors = privateGetDeclaredConstructors((which == Member.PUBLIC));
+        for (Constructor<T> constructor : constructors) {
             if (arrayContentsEq(parameterTypes,
-                                constructors[i].getParameterTypes())) {
-                return getReflectionFactory().copyConstructor(constructors[i]);
+                                constructor.getParameterTypes())) {
+                return getReflectionFactory().copyConstructor(constructor);
             }
         }
         throw new NoSuchMethodException(getName() + ".<init>" + argumentTypesToString(parameterTypes));
@@ -2767,18 +2762,18 @@
         return out;
     }
 
-    private static Constructor[] copyConstructors(Constructor[] arg) {
-        Constructor[] out = new Constructor[arg.length];
+    private static <U> Constructor<U>[] copyConstructors(Constructor<U>[] arg) {
+        Constructor<U>[] out = arg.clone();
         ReflectionFactory fact = getReflectionFactory();
-        for (int i = 0; i < arg.length; i++) {
-            out[i] = fact.copyConstructor(arg[i]);
+        for (int i = 0; i < out.length; i++) {
+            out[i] = fact.copyConstructor(out[i]);
         }
         return out;
     }
 
     private native Field[]       getDeclaredFields0(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 static String        argumentTypesToString(Class[] argTypes) {
@@ -2883,7 +2878,7 @@
     // Fetches the factory for reflective objects
     private static ReflectionFactory getReflectionFactory() {
         if (reflectionFactory == null) {
-            reflectionFactory =  (ReflectionFactory)
+            reflectionFactory =
                 java.security.AccessController.doPrivileged
                     (new sun.reflect.ReflectionFactory.GetReflectionFactoryAction());
         }
@@ -2895,8 +2890,8 @@
     private static boolean initted = false;
     private static void checkInitted() {
         if (initted) return;
-        AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                public Void run() {
                     // Tests to ensure the system properties table is fully
                     // initialized. This is needed because reflection code is
                     // called very early in the initialization process (before
@@ -2941,17 +2936,17 @@
     /**
      * Returns the elements of this enum class or null if this
      * Class object does not represent an enum type;
-     * identical to getEnumConstantsShared except that
-     * the result is uncloned, cached, and shared by all callers.
+     * identical to getEnumConstants except that the result is
+     * uncloned, cached, and shared by all callers.
      */
     T[] getEnumConstantsShared() {
         if (enumConstants == null) {
             if (!isEnum()) return null;
             try {
                 final Method values = getMethod("values");
-                java.security.AccessController.doPrivileged
-                    (new java.security.PrivilegedAction() {
-                            public Object run() {
+                java.security.AccessController.doPrivileged(
+                    new java.security.PrivilegedAction<Void>() {
+                        public Void run() {
                                 values.setAccessible(true);
                                 return null;
                             }
--- a/jdk/src/share/classes/java/lang/ClassLoader.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/lang/ClassLoader.java	Mon Mar 10 15:07:09 2008 -0700
@@ -39,6 +39,7 @@
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.security.ProtectionDomain;
+import java.security.cert.Certificate;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.HashMap;
@@ -172,17 +173,18 @@
     private ClassLoader parent;
 
     // 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
-    java.security.cert.Certificate[] nocerts;
+    Certificate[] nocerts;
 
     // 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.
-    private Vector classes = new Vector();
+    private Vector<Class<?>> classes = new Vector<Class<?>>();
 
     // 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.
     void addClass(Class c) {
@@ -191,7 +193,7 @@
 
     // The packages defined in this class loader.  Each package name is mapped
     // 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
@@ -342,8 +344,8 @@
             final String name = cls.getName();
             final int i = name.lastIndexOf('.');
             if (i != -1) {
-                AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
+                AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                    public Void run() {
                         sm.checkPackageAccess(name.substring(0, i));
                         return null;
                     }
@@ -524,17 +526,20 @@
         // Class format error - try to transform the bytecode and
         // define the class again
         //
-        Object[] transformers = ClassFileTransformer.getTransformers();
+        ClassFileTransformer[] transformers = ClassFileTransformer.getTransformers();
         Class c = null;
 
-        for (int i = 0; transformers != null && i < transformers.length; i++) {
-            try {
-              // Transform byte code using transformer
-              byte[] tb = ((ClassFileTransformer) transformers[i]).transform(b, off, len);
-              c = defineClass1(name, tb, 0, tb.length, protectionDomain, source);
-              break;
-            } catch (ClassFormatError cfe2)     {
-              // If ClassFormatError occurs, try next transformer
+        if (transformers != null) {
+            for (ClassFileTransformer transformer : transformers) {
+                try {
+                    // Transform byte code using transformer
+                    byte[] tb = transformer.transform(b, off, len);
+                    c = defineClass1(name, tb, 0, tb.length,
+                                     protectionDomain, source);
+                    break;
+                } catch (ClassFormatError cfe2)     {
+                    // If ClassFormatError occurs, try next transformer
+                }
             }
         }
 
@@ -550,7 +555,7 @@
     private void postDefineClass(Class c, ProtectionDomain protectionDomain)
     {
         if (protectionDomain.getCodeSource() != null) {
-            java.security.cert.Certificate certs[] =
+            Certificate certs[] =
                 protectionDomain.getCodeSource().getCertificates();
             if (certs != null)
                 setSigners(c, certs);
@@ -767,8 +772,7 @@
     private synchronized void checkCerts(String name, CodeSource cs) {
         int i = name.lastIndexOf('.');
         String pname = (i == -1) ? "" : name.substring(0, i);
-        java.security.cert.Certificate[] pcerts =
-            (java.security.cert.Certificate[]) package2certs.get(pname);
+        Certificate[] pcerts = package2certs.get(pname);
         if (pcerts == null) {
             // first class in this package gets to define which
             // certificates must be the same for all other classes
@@ -778,12 +782,12 @@
             }
             if (pcerts == null) {
                 if (nocerts == null)
-                    nocerts = new java.security.cert.Certificate[0];
+                    nocerts = new Certificate[0];
                 pcerts = nocerts;
             }
             package2certs.put(pname, pcerts);
         } else {
-            java.security.cert.Certificate[] certs = null;
+            Certificate[] certs = null;
             if (cs != null) {
                 certs = cs.getCertificates();
             }
@@ -799,8 +803,8 @@
      * 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)
      */
-    private boolean compareCerts(java.security.cert.Certificate[] pcerts,
-                                 java.security.cert.Certificate[] certs)
+    private boolean compareCerts(Certificate[] pcerts,
+                                 Certificate[] certs)
     {
         // certs can be null, indicating no certs.
         if ((certs == null) || (certs.length == 0)) {
@@ -1031,7 +1035,7 @@
         }
         tmp[1] = findResources(name);
 
-        return new CompoundEnumeration(tmp);
+        return new CompoundEnumeration<URL>(tmp);
     }
 
     /**
@@ -1068,7 +1072,7 @@
      * @since  1.2
      */
     protected Enumeration<URL> findResources(String name) throws IOException {
-        return new CompoundEnumeration(new Enumeration[0]);
+        return java.util.Collections.emptyEnumeration();
     }
 
     /**
@@ -1134,13 +1138,13 @@
     /**
      * Find resources from the VM's built-in classloader.
      */
-    private static Enumeration getBootstrapResources(String name)
+    private static Enumeration<URL> getBootstrapResources(String name)
         throws IOException
     {
-        final Enumeration e = getBootstrapClassPath().getResources(name);
-        return new Enumeration () {
-            public Object nextElement() {
-                return ((Resource)e.nextElement()).getURL();
+        final Enumeration<Resource> e = getBootstrapClassPath().getResources(name);
+        return new Enumeration<URL> () {
+            public URL nextElement() {
+                return e.nextElement().getURL();
             }
             public boolean hasMoreElements() {
                 return e.hasMoreElements();
@@ -1323,9 +1327,8 @@
                 Throwable oops = null;
                 scl = l.getClassLoader();
                 try {
-                    PrivilegedExceptionAction a;
-                    a = new SystemClassLoaderAction(scl);
-                    scl = (ClassLoader) AccessController.doPrivileged(a);
+                    scl = AccessController.doPrivileged(
+                        new SystemClassLoaderAction(scl));
                 } catch (PrivilegedActionException pae) {
                     oops = pae.getCause();
                     if (oops instanceof InvocationTargetException) {
@@ -1456,7 +1459,7 @@
      */
     protected Package getPackage(String name) {
         synchronized (packages) {
-            Package pkg = (Package)packages.get(name);
+            Package pkg = packages.get(name);
             if (pkg == null) {
                 if (parent != null) {
                     pkg = parent.getPackage(name);
@@ -1481,9 +1484,9 @@
      * @since  1.2
      */
     protected Package[] getPackages() {
-        Map map;
+        Map<String, Package> map;
         synchronized (packages) {
-            map = (Map)packages.clone();
+            map = new HashMap<String, Package>(packages);
         }
         Package[] pkgs;
         if (parent != null) {
@@ -1499,7 +1502,7 @@
                 }
             }
         }
-        return (Package[])map.values().toArray(new Package[map.size()]);
+        return map.values().toArray(new Package[map.size()]);
     }
 
 
@@ -1585,8 +1588,7 @@
         // Invoked in the VM to determine the context class in
         // JNI_Load/JNI_Unload
         static Class getFromClass() {
-            return ((NativeLibrary)
-                    (ClassLoader.nativeLibraryContext.peek())).fromClass;
+            return ClassLoader.nativeLibraryContext.peek().fromClass;
         }
     }
 
@@ -1597,22 +1599,27 @@
     // Returns (and initializes) the default domain.
     private synchronized ProtectionDomain getDefaultDomain() {
         if (defaultDomain == null) {
-            CodeSource cs =
-                new CodeSource(null, (java.security.cert.Certificate[]) null);
+            CodeSource cs = new CodeSource(null, (Certificate[]) null);
             defaultDomain = new ProtectionDomain(cs, null, this, null);
         }
         return defaultDomain;
     }
 
     // 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.
-    private static Vector systemNativeLibraries = new Vector();
+    private static Vector<NativeLibrary> systemNativeLibraries
+        = new Vector<NativeLibrary>();
+
     // Native libraries associated with the class loader.
-    private Vector nativeLibraries = new Vector();
+    private Vector<NativeLibrary> nativeLibraries
+        = new Vector<NativeLibrary>();
 
     // native libraries being loaded/unloaded.
-    private static Stack nativeLibraryContext = new Stack();
+    private static Stack<NativeLibrary> nativeLibraryContext
+        = new Stack<NativeLibrary>();
 
     // The paths searched for libraries
     static private String usr_paths[];
@@ -1699,13 +1706,13 @@
     }
 
     private static boolean loadLibrary0(Class fromClass, final File file) {
-        Boolean exists = (Boolean)
-            AccessController.doPrivileged(new PrivilegedAction() {
+        boolean exists = AccessController.doPrivileged(
+            new PrivilegedAction<Object>() {
                 public Object run() {
-                    return new Boolean(file.exists());
-                }
-            });
-        if (!exists.booleanValue()) {
+                    return file.exists() ? Boolean.TRUE : null;
+                }})
+            != null;
+        if (!exists) {
             return false;
         }
         String name;
@@ -1716,12 +1723,12 @@
         }
         ClassLoader loader =
             (fromClass == null) ? null : fromClass.getClassLoader();
-        Vector libs =
+        Vector<NativeLibrary> libs =
             loader != null ? loader.nativeLibraries : systemNativeLibraries;
         synchronized (libs) {
             int size = libs.size();
             for (int i = 0; i < size; i++) {
-                NativeLibrary lib = (NativeLibrary)libs.elementAt(i);
+                NativeLibrary lib = libs.elementAt(i);
                 if (name.equals(lib.name)) {
                     return true;
                 }
@@ -1748,8 +1755,7 @@
                  */
                 int n = nativeLibraryContext.size();
                 for (int i = 0; i < n; i++) {
-                    NativeLibrary lib = (NativeLibrary)
-                        nativeLibraryContext.elementAt(i);
+                    NativeLibrary lib = nativeLibraryContext.elementAt(i);
                     if (name.equals(lib.name)) {
                         if (loader == lib.fromClass.getClassLoader()) {
                             return true;
@@ -1780,12 +1786,12 @@
 
     // Invoked in the VM class linking code.
     static long findNative(ClassLoader loader, String name) {
-        Vector libs =
+        Vector<NativeLibrary> libs =
             loader != null ? loader.nativeLibraries : systemNativeLibraries;
         synchronized (libs) {
             int size = libs.size();
             for (int i = 0; i < size; i++) {
-                NativeLibrary lib = (NativeLibrary)libs.elementAt(i);
+                NativeLibrary lib = libs.elementAt(i);
                 long entry = lib.find(name);
                 if (entry != 0)
                     return entry;
@@ -1805,13 +1811,13 @@
     // is null then we are delegating assertion status queries to the VM, i.e.,
     // none of this ClassLoader's assertion status modification methods have
     // been invoked.
-    private Map packageAssertionStatus = null;
+    private Map<String, Boolean> packageAssertionStatus = null;
 
     // Maps String fullyQualifiedClassName to Boolean assertionStatus If this
     // field is null then we are delegating assertion status queries to the VM,
     // i.e., none of this ClassLoader's assertion status modification methods
     // have been invoked.
-    Map classAssertionStatus = null;
+    Map<String, Boolean> classAssertionStatus = null;
 
     /**
      * Sets the default assertion status for this class loader.  This setting
@@ -1878,7 +1884,7 @@
         if (packageAssertionStatus == null)
             initializeJavaAssertionMaps();
 
-        packageAssertionStatus.put(packageName, Boolean.valueOf(enabled));
+        packageAssertionStatus.put(packageName, enabled);
     }
 
     /**
@@ -1909,7 +1915,7 @@
         if (classAssertionStatus == null)
             initializeJavaAssertionMaps();
 
-        classAssertionStatus.put(className, Boolean.valueOf(enabled));
+        classAssertionStatus.put(className, enabled);
     }
 
     /**
@@ -1927,8 +1933,8 @@
          * Whether or not "Java assertion maps" are initialized, set
          * them to empty maps, effectively ignoring any present settings.
          */
-        classAssertionStatus = new HashMap();
-        packageAssertionStatus = new HashMap();
+        classAssertionStatus = new HashMap<String, Boolean>();
+        packageAssertionStatus = new HashMap<String, Boolean>();
 
         defaultAssertionStatus = false;
     }
@@ -1962,20 +1968,20 @@
         // assert packageAssertionStatus != null;
 
         // Check for a class entry
-        result = (Boolean)classAssertionStatus.get(className);
+        result = classAssertionStatus.get(className);
         if (result != null)
             return result.booleanValue();
 
         // Check for most specific package entry
         int dotIndex = className.lastIndexOf(".");
         if (dotIndex < 0) { // default package
-            result = (Boolean)packageAssertionStatus.get(null);
+            result = packageAssertionStatus.get(null);
             if (result != null)
                 return result.booleanValue();
         }
         while(dotIndex > 0) {
             className = className.substring(0, dotIndex);
-            result = (Boolean)packageAssertionStatus.get(className);
+            result = packageAssertionStatus.get(className);
             if (result != null)
                 return result.booleanValue();
             dotIndex = className.lastIndexOf(".", dotIndex-1);
@@ -1989,17 +1995,17 @@
     private void initializeJavaAssertionMaps() {
         // assert Thread.holdsLock(this);
 
-        classAssertionStatus = new HashMap();
-        packageAssertionStatus = new HashMap();
+        classAssertionStatus = new HashMap<String, Boolean>();
+        packageAssertionStatus = new HashMap<String, Boolean>();
         AssertionStatusDirectives directives = retrieveDirectives();
 
         for(int i = 0; i < directives.classes.length; i++)
             classAssertionStatus.put(directives.classes[i],
-                              Boolean.valueOf(directives.classEnabled[i]));
+                                     directives.classEnabled[i]);
 
         for(int i = 0; i < directives.packages.length; i++)
             packageAssertionStatus.put(directives.packages[i],
-                              Boolean.valueOf(directives.packageEnabled[i]));
+                                       directives.packageEnabled[i]);
 
         defaultAssertionStatus = directives.deflt;
     }
@@ -2009,28 +2015,24 @@
 }
 
 
-class SystemClassLoaderAction implements PrivilegedExceptionAction {
+class SystemClassLoaderAction
+    implements PrivilegedExceptionAction<ClassLoader> {
     private ClassLoader parent;
 
     SystemClassLoaderAction(ClassLoader parent) {
         this.parent = parent;
     }
 
-    public Object run() throws Exception {
-        ClassLoader sys;
-        Constructor ctor;
-        Class c;
-        Class cp[] = { ClassLoader.class };
-        Object params[] = { parent };
-
+    public ClassLoader run() throws Exception {
         String cls = System.getProperty("java.system.class.loader");
         if (cls == null) {
             return parent;
         }
 
-        c = Class.forName(cls, true, parent);
-        ctor = c.getDeclaredConstructor(cp);
-        sys = (ClassLoader) ctor.newInstance(params);
+        Constructor ctor = Class.forName(cls, true, parent)
+            .getDeclaredConstructor(new Class[] { ClassLoader.class });
+        ClassLoader sys = (ClassLoader) ctor.newInstance(
+            new Object[] { parent });
         Thread.currentThread().setContextClassLoader(sys);
         return sys;
     }
--- a/jdk/src/share/classes/java/lang/Compiler.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/lang/Compiler.java	Mon Mar 10 15:07:09 2008 -0700
@@ -53,9 +53,9 @@
 
     static {
         registerNatives();
-        java.security.AccessController.doPrivileged
-            (new java.security.PrivilegedAction() {
-                public Object run() {
+        java.security.AccessController.doPrivileged(
+            new java.security.PrivilegedAction<Void>() {
+                public Void run() {
                     boolean loaded = false;
                     String jit = System.getProperty("java.compiler");
                     if ((jit != null) && (!jit.equals("NONE")) &&
--- a/jdk/src/share/classes/java/lang/Long.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/lang/Long.java	Mon Mar 10 15:07:09 2008 -0700
@@ -650,7 +650,7 @@
 
         try {
             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) {
             // 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
--- a/jdk/src/share/classes/java/lang/Package.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/lang/Package.java	Mon Mar 10 15:07:09 2008 -0700
@@ -507,7 +507,7 @@
      */
     static Package getSystemPackage(String name) {
         synchronized (pkgs) {
-            Package pkg = (Package)pkgs.get(name);
+            Package pkg = pkgs.get(name);
             if (pkg == null) {
                 name = name.replace('.', '/').concat("/");
                 String fn = getSystemPackage0(name);
@@ -529,18 +529,18 @@
             for (int i = 0; i < names.length; 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,
                                                final String fn)
     {
-        return (Package) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
+        return AccessController.doPrivileged(new PrivilegedAction<Package>() {
+            public Package run() {
                 String name = iname;
                 // Get the cached code source url for the file name
-                URL url = (URL)urls.get(fn);
+                URL url = urls.get(fn);
                 if (url == null) {
                     // URL not found, so create one
                     File file = new File(fn);
@@ -559,7 +559,7 @@
                 // Convert to "."-separated package name
                 name = name.substring(0, name.length() - 1).replace('/', '.');
                 Package pkg;
-                Manifest man = (Manifest)mans.get(fn);
+                Manifest man = mans.get(fn);
                 if (man != null) {
                     pkg = new Package(name, man, url, null);
                 } else {
@@ -588,13 +588,16 @@
     }
 
     // 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
-    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
-    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[] getSystemPackages0();
--- a/jdk/src/share/classes/java/lang/ref/Finalizer.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/lang/ref/Finalizer.java	Mon Mar 10 15:07:09 2008 -0700
@@ -121,8 +121,9 @@
        invokers of these methods from a stalled or deadlocked finalizer thread.
      */
     private static void forkSecondaryFinalizer(final Runnable proc) {
-        PrivilegedAction pa = new PrivilegedAction() {
-            public Object run() {
+        AccessController.doPrivileged(
+            new PrivilegedAction<Void>() {
+                public Void run() {
                 ThreadGroup tg = Thread.currentThread().getThreadGroup();
                 for (ThreadGroup tgn = tg;
                      tgn != null;
@@ -135,8 +136,7 @@
                     /* Ignore */
                 }
                 return null;
-            }};
-        AccessController.doPrivileged(pa);
+                }});
     }
 
     /* Called by Runtime.runFinalization() */
--- a/jdk/src/share/classes/java/lang/reflect/AccessibleObject.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/lang/reflect/AccessibleObject.java	Mon Mar 10 15:07:09 2008 -0700
@@ -165,9 +165,9 @@
     // Reflection factory used by subclasses for creating field,
     // method, and constructor accessors. Note that this is called
     // very early in the bootstrapping process.
-    static final ReflectionFactory reflectionFactory = (ReflectionFactory)
-        AccessController.doPrivileged
-            (new sun.reflect.ReflectionFactory.GetReflectionFactoryAction());
+    static final ReflectionFactory reflectionFactory =
+        AccessController.doPrivileged(
+            new sun.reflect.ReflectionFactory.GetReflectionFactoryAction());
 
     /**
      * @throws NullPointerException {@inheritDoc}
--- a/jdk/src/share/classes/java/lang/reflect/Modifier.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/lang/reflect/Modifier.java	Mon Mar 10 15:07:09 2008 -0700
@@ -58,9 +58,8 @@
      */
     static {
         sun.reflect.ReflectionFactory factory =
-            (sun.reflect.ReflectionFactory) AccessController.doPrivileged(
-                new ReflectionFactory.GetReflectionFactoryAction()
-            );
+            AccessController.doPrivileged(
+                new ReflectionFactory.GetReflectionFactoryAction());
         factory.setLangReflectAccess(new java.lang.reflect.ReflectAccess());
     }
 
--- a/jdk/src/share/classes/java/lang/reflect/Proxy.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/lang/reflect/Proxy.java	Mon Mar 10 15:07:09 2008 -0700
@@ -33,6 +33,7 @@
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.List;
 import java.util.WeakHashMap;
 import sun.misc.ProxyGenerator;
 
@@ -230,7 +231,8 @@
         { InvocationHandler.class };
 
     /** 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 */
     private static Object pendingGenerationMarker = new Object();
@@ -240,8 +242,8 @@
     private static Object nextUniqueNumberLock = new Object();
 
     /** set of all generated proxy classes, for isProxyClass implementation */
-    private static Map proxyClasses =
-        Collections.synchronizedMap(new WeakHashMap());
+    private static Map<Class<?>, Void> proxyClasses =
+        Collections.synchronizedMap(new WeakHashMap<Class<?>, Void>());
 
     /**
      * the invocation handler for this proxy instance.
@@ -353,7 +355,8 @@
         /* collect interface names to use as key for proxy class cache */
         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++) {
             /*
@@ -401,16 +404,16 @@
          * representation of a class makes for an implicit weak
          * 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.
          */
-        Map cache;
+        Map<List<String>, Object> cache;
         synchronized (loaderToCache) {
-            cache = (Map) loaderToCache.get(loader);
+            cache = loaderToCache.get(loader);
             if (cache == null) {
-                cache = new HashMap();
+                cache = new HashMap<List<String>, Object>();
                 loaderToCache.put(loader, cache);
             }
             /*
@@ -442,7 +445,7 @@
             do {
                 Object value = cache.get(key);
                 if (value instanceof Reference) {
-                    proxyClass = (Class) ((Reference) value).get();
+                    proxyClass = (Class<?>) ((Reference) value).get();
                 }
                 if (proxyClass != null) {
                     // proxy class already generated: return it
@@ -544,7 +547,7 @@
              */
             synchronized (cache) {
                 if (proxyClass != null) {
-                    cache.put(key, new WeakReference(proxyClass));
+                    cache.put(key, new WeakReference<Class<?>>(proxyClass));
                 } else {
                     cache.remove(key);
                 }
@@ -595,14 +598,14 @@
         /*
          * 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.
          */
         try {
             Constructor cons = cl.getConstructor(constructorParams);
-            return (Object) cons.newInstance(new Object[] { h });
+            return cons.newInstance(new Object[] { h });
         } catch (NoSuchMethodException e) {
             throw new InternalError(e.toString());
         } catch (IllegalAccessException e) {
--- a/jdk/src/share/classes/java/net/DatagramSocket.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/net/DatagramSocket.java	Mon Mar 10 15:07:09 2008 -0700
@@ -287,8 +287,9 @@
         // DatagramSocketImpl.peekdata() is a protected method, therefore we need to use
         // getDeclaredMethod, therefore we need permission to access the member
         try {
-            AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                    public Object run() throws NoSuchMethodException {
+            AccessController.doPrivileged(
+                new PrivilegedExceptionAction<Void>() {
+                    public Void run() throws NoSuchMethodException {
                         Class[] cl = new Class[1];
                         cl[0] = DatagramPacket.class;
                         impl.getClass().getDeclaredMethod("peekData", cl);
--- a/jdk/src/share/classes/java/net/ServerSocket.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/net/ServerSocket.java	Mon Mar 10 15:07:09 2008 -0700
@@ -247,8 +247,9 @@
         // SocketImpl.connect() is a protected method, therefore we need to use
         // getDeclaredMethod, therefore we need permission to access the member
         try {
-            AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                    public Object run() throws NoSuchMethodException {
+            AccessController.doPrivileged(
+                new PrivilegedExceptionAction<Void>() {
+                    public Void run() throws NoSuchMethodException {
                         Class[] cl = new Class[2];
                         cl[0] = SocketAddress.class;
                         cl[1] = Integer.TYPE;
--- a/jdk/src/share/classes/java/net/Socket.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/net/Socket.java	Mon Mar 10 15:07:09 2008 -0700
@@ -847,9 +847,9 @@
         final Socket s = this;
         InputStream is = null;
         try {
-            is = (InputStream)
-                AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                    public Object run() throws IOException {
+            is = AccessController.doPrivileged(
+                new PrivilegedExceptionAction<InputStream>() {
+                    public InputStream run() throws IOException {
                         return impl.getInputStream();
                     }
                 });
@@ -887,9 +887,9 @@
         final Socket s = this;
         OutputStream os = null;
         try {
-            os = (OutputStream)
-                AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                    public Object run() throws IOException {
+            os = AccessController.doPrivileged(
+                new PrivilegedExceptionAction<OutputStream>() {
+                    public OutputStream run() throws IOException {
                         return impl.getOutputStream();
                     }
                 });
--- a/jdk/src/share/classes/java/net/SocksSocketImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/net/SocksSocketImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -78,8 +78,8 @@
     {
         try {
             AccessController.doPrivileged(
-                  new java.security.PrivilegedExceptionAction() {
-                          public Object run() throws IOException {
+                new java.security.PrivilegedExceptionAction<Void>() {
+                    public Void run() throws IOException {
                               superConnectServer(host, port, timeout);
                               cmdIn = getInputStream();
                               cmdOut = getOutputStream();
@@ -129,10 +129,10 @@
             String userName;
             String password = null;
             final InetAddress addr = InetAddress.getByName(server);
-            PasswordAuthentication pw = (PasswordAuthentication)
+            PasswordAuthentication pw =
                 java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedAction() {
-                            public Object run() {
+                    new java.security.PrivilegedAction<PasswordAuthentication>() {
+                        public PasswordAuthentication run() {
                                 return Authenticator.requestPasswordAuthentication(
                                        server, addr, port, "SOCKS5", "SOCKS authentication", null);
                             }
@@ -339,10 +339,9 @@
             // This is the general case
             // server is not null only when the socket was created with a
             // specified proxy in which case it does bypass the ProxySelector
-            ProxySelector sel = (ProxySelector)
-                java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedAction() {
-                        public Object run() {
+            ProxySelector sel = java.security.AccessController.doPrivileged(
+                new java.security.PrivilegedAction<ProxySelector>() {
+                    public ProxySelector run() {
                             return ProxySelector.getDefault();
                         }
                     });
@@ -652,10 +651,9 @@
             // This is the general case
             // server is not null only when the socket was created with a
             // specified proxy in which case it does bypass the ProxySelector
-            ProxySelector sel = (ProxySelector)
-                java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedAction() {
-                        public Object run() {
+            ProxySelector sel = java.security.AccessController.doPrivileged(
+                new java.security.PrivilegedAction<ProxySelector>() {
+                    public ProxySelector run() {
                             return ProxySelector.getDefault();
                         }
                     });
@@ -701,8 +699,9 @@
 
                 // Connects to the SOCKS server
                 try {
-                    AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                            public Object run() throws Exception {
+                    AccessController.doPrivileged(
+                        new PrivilegedExceptionAction<Void>() {
+                            public Void run() throws Exception {
                                 cmdsock = new Socket(new PlainSocketImpl());
                                 cmdsock.connect(new InetSocketAddress(server, port));
                                 cmdIn = cmdsock.getInputStream();
@@ -731,8 +730,9 @@
             }
         } else {
             try {
-                AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                        public Object run() throws Exception {
+                AccessController.doPrivileged(
+                    new PrivilegedExceptionAction<Void>() {
+                        public Void run() throws Exception {
                             cmdsock = new Socket(new PlainSocketImpl());
                             cmdsock.connect(new InetSocketAddress(server, port));
                             cmdIn = cmdsock.getInputStream();
--- a/jdk/src/share/classes/java/net/URLClassLoader.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/net/URLClassLoader.java	Mon Mar 10 15:07:09 2008 -0700
@@ -205,9 +205,9 @@
          throws ClassNotFoundException
     {
         try {
-            return (Class)
-                AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                    public Object run() throws ClassNotFoundException {
+            return AccessController.doPrivileged(
+                new PrivilegedExceptionAction<Class>() {
+                    public Class run() throws ClassNotFoundException {
                         String path = name.replace('.', '/').concat(".class");
                         Resource res = ucp.getResource(path, false);
                         if (res != null) {
@@ -376,9 +376,9 @@
         /*
          * The same restriction to finding classes applies to resources
          */
-        URL url =
-            (URL) AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+        URL url = AccessController.doPrivileged(
+            new PrivilegedAction<URL>() {
+                public URL run() {
                     return ucp.findResource(name, true);
                 }
             }, acc);
@@ -397,7 +397,7 @@
     public Enumeration<URL> findResources(final String name)
         throws IOException
     {
-        final Enumeration e = ucp.findResources(name, true);
+        final Enumeration<URL> e = ucp.findResources(name, true);
 
         return new Enumeration<URL>() {
             private URL url = null;
@@ -407,9 +407,9 @@
                     return true;
                 }
                 do {
-                    URL u = (URL)
-                        AccessController.doPrivileged(new PrivilegedAction() {
-                            public Object run() {
+                    URL u = AccessController.doPrivileged(
+                        new PrivilegedAction<URL>() {
+                            public URL run() {
                                 if (!e.hasMoreElements())
                                     return null;
                                 return e.nextElement();
@@ -515,8 +515,8 @@
             final SecurityManager sm = System.getSecurityManager();
             if (sm != null) {
                 final Permission fp = p;
-                AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() throws SecurityException {
+                AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                    public Void run() throws SecurityException {
                         sm.checkPermission(fp);
                         return null;
                     }
@@ -544,9 +544,9 @@
         // Save the caller's context
         AccessControlContext acc = AccessController.getContext();
         // Need a privileged block to create the class loader
-        URLClassLoader ucl =
-            (URLClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+        URLClassLoader ucl = AccessController.doPrivileged(
+            new PrivilegedAction<URLClassLoader>() {
+                public URLClassLoader run() {
                     return new FactoryURLClassLoader(urls, parent);
                 }
             });
@@ -571,9 +571,9 @@
         // Save the caller's context
         AccessControlContext acc = AccessController.getContext();
         // Need a privileged block to create the class loader
-        URLClassLoader ucl = (URLClassLoader)
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+        URLClassLoader ucl = AccessController.doPrivileged(
+            new PrivilegedAction<URLClassLoader>() {
+                public URLClassLoader run() {
                     return new FactoryURLClassLoader(urls);
                 }
             });
--- a/jdk/src/share/classes/java/nio/channels/spi/SelectorProvider.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/nio/channels/spi/SelectorProvider.java	Mon Mar 10 15:07:09 2008 -0700
@@ -167,9 +167,9 @@
         synchronized (lock) {
             if (provider != null)
                 return provider;
-            return (SelectorProvider)AccessController
-                .doPrivileged(new PrivilegedAction() {
-                        public Object run() {
+            return AccessController.doPrivileged(
+                new PrivilegedAction<SelectorProvider>() {
+                    public SelectorProvider run() {
                             if (loadProviderFromProperty())
                                 return provider;
                             if (loadProviderAsService())
--- a/jdk/src/share/classes/java/rmi/activation/ActivationGroupDesc.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/rmi/activation/ActivationGroupDesc.java	Mon Mar 10 15:07:09 2008 -0700
@@ -263,7 +263,7 @@
          * @since 1.2
          */
         public String[] getCommandOptions() {
-            return (String[]) options.clone();
+            return options.clone();
         }
 
         /**
--- a/jdk/src/share/classes/java/rmi/dgc/VMID.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/rmi/dgc/VMID.java	Mon Mar 10 15:07:09 2008 -0700
@@ -136,9 +136,9 @@
         /*
          * Get the local host's IP address.
          */
-        byte[] addr = (byte[]) java.security.AccessController.doPrivileged(
-            new PrivilegedAction() {
-            public Object run() {
+        byte[] addr = java.security.AccessController.doPrivileged(
+            new PrivilegedAction<byte[]>() {
+            public byte[] run() {
                 try {
                     return InetAddress.getLocalHost().getAddress();
                 } catch (Exception e) {
--- a/jdk/src/share/classes/java/security/cert/TrustAnchor.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/security/cert/TrustAnchor.java	Mon Mar 10 15:07:09 2008 -0700
@@ -275,7 +275,7 @@
             ncBytes = null;
             nc = null;
         } else {
-            ncBytes = (byte []) bytes.clone();
+            ncBytes = bytes.clone();
             // validate DER encoding
             try {
                 nc = new NameConstraintsExtension(Boolean.FALSE, bytes);
@@ -309,7 +309,7 @@
      *         or <code>null</code> if not set.
      */
     public final byte [] getNameConstraints() {
-        return (ncBytes == null ? null : (byte []) ncBytes.clone());
+        return ncBytes == null ? null : ncBytes.clone();
     }
 
     /**
--- a/jdk/src/share/classes/java/security/cert/X509CertSelector.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/security/cert/X509CertSelector.java	Mon Mar 10 15:07:09 2008 -0700
@@ -381,7 +381,7 @@
         if (subjectKeyID == null) {
             this.subjectKeyID = null;
         } else {
-            this.subjectKeyID = (byte[])subjectKeyID.clone();
+            this.subjectKeyID = subjectKeyID.clone();
         }
     }
 
@@ -442,7 +442,7 @@
         if (authorityKeyID == null) {
             this.authorityKeyID = null;
         } else {
-            this.authorityKeyID = (byte[])authorityKeyID.clone();
+            this.authorityKeyID = authorityKeyID.clone();
         }
     }
 
@@ -566,7 +566,7 @@
             subjectPublicKey = null;
             subjectPublicKeyBytes = null;
         } else {
-            subjectPublicKeyBytes = (byte[])key.clone();
+            subjectPublicKeyBytes = key.clone();
             subjectPublicKey = X509Key.parse(new DerValue(subjectPublicKeyBytes));
         }
     }
@@ -590,7 +590,7 @@
         if (keyUsage == null) {
             this.keyUsage = null;
         } else {
-            this.keyUsage = (boolean[])keyUsage.clone();
+            this.keyUsage = keyUsage.clone();
         }
     }
 
@@ -1041,7 +1041,7 @@
             ncBytes = null;
             nc = null;
         } else {
-            ncBytes = (byte[])bytes.clone();
+            ncBytes = bytes.clone();
             nc = new NameConstraintsExtension(FALSE, bytes);
         }
     }
@@ -1438,7 +1438,7 @@
         if (subjectKeyID == null) {
             return null;
         }
-        return (byte[])subjectKeyID.clone();
+        return subjectKeyID.clone();
     }
 
     /**
@@ -1457,7 +1457,7 @@
         if (authorityKeyID == null) {
           return null;
         }
-        return (byte[])authorityKeyID.clone();
+        return authorityKeyID.clone();
     }
 
     /**
@@ -1546,7 +1546,7 @@
         if (keyUsage == null) {
             return null;
         }
-        return (boolean[])keyUsage.clone();
+        return keyUsage.clone();
     }
 
     /**
@@ -1736,7 +1736,7 @@
         if (ncBytes == null) {
             return null;
         } else {
-            return (byte[]) ncBytes.clone();
+            return ncBytes.clone();
         }
     }
 
--- a/jdk/src/share/classes/java/util/ArrayList.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/util/ArrayList.java	Mon Mar 10 15:07:09 2008 -0700
@@ -892,7 +892,7 @@
         private final AbstractList<E> parent;
         private final int parentOffset;
         private final int offset;
-        private int size;
+        int size;
 
         SubList(AbstractList<E> parent,
                 int offset, int fromIndex, int toIndex) {
@@ -971,6 +971,7 @@
         public ListIterator<E> listIterator(final int index) {
             checkForComodification();
             rangeCheckForAdd(index);
+            final int offset = this.offset;
 
             return new ListIterator<E>() {
                 int cursor = index;
--- a/jdk/src/share/classes/java/util/Arrays.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/util/Arrays.java	Mon Mar 10 15:07:09 2008 -0700
@@ -1088,7 +1088,7 @@
      *          <i>mutually comparable</i> (for example, strings and integers).
      */
     public static void sort(Object[] a) {
-        Object[] aux = (Object[])a.clone();
+        Object[] aux = a.clone();
         mergeSort(aux, a, 0, a.length, 0);
     }
 
@@ -1216,7 +1216,7 @@
      *          not <i>mutually comparable</i> using the specified comparator.
      */
     public static <T> void sort(T[] a, Comparator<? super T> c) {
-        T[] aux = (T[])a.clone();
+        T[] aux = a.clone();
         if (c==null)
             mergeSort(aux, a, 0, a.length, 0);
         else
@@ -1257,7 +1257,7 @@
     public static <T> void sort(T[] a, int fromIndex, int toIndex,
                                 Comparator<? super T> c) {
         rangeCheck(a.length, fromIndex, toIndex);
-        T[] aux = (T[])copyOfRange(a, fromIndex, toIndex);
+        T[] aux = copyOfRange(a, fromIndex, toIndex);
         if (c==null)
             mergeSort(aux, a, fromIndex, toIndex, -fromIndex);
         else
@@ -4128,7 +4128,7 @@
         if (a.length != 0 && bufLen <= 0)
             bufLen = Integer.MAX_VALUE;
         StringBuilder buf = new StringBuilder(bufLen);
-        deepToString(a, buf, new HashSet());
+        deepToString(a, buf, new HashSet<Object[]>());
         return buf.toString();
     }
 
--- a/jdk/src/share/classes/java/util/EnumMap.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/util/EnumMap.java	Mon Mar 10 15:07:09 2008 -0700
@@ -140,7 +140,7 @@
     public EnumMap(EnumMap<K, ? extends V> m) {
         keyType = m.keyType;
         keyUniverse = m.keyUniverse;
-        vals = (Object[]) m.vals.clone();
+        vals = m.vals.clone();
         size = m.size;
     }
 
@@ -161,7 +161,7 @@
             EnumMap<K, ? extends V> em = (EnumMap<K, ? extends V>) m;
             keyType = em.keyType;
             keyUniverse = em.keyUniverse;
-            vals = (Object[]) em.vals.clone();
+            vals = em.vals.clone();
             size = em.size;
         } else {
             if (m.isEmpty())
@@ -257,7 +257,7 @@
     public V put(K key, V value) {
         typeCheck(key);
 
-        int index = ((Enum)key).ordinal();
+        int index = key.ordinal();
         Object oldValue = vals[index];
         vals[index] = maskNull(value);
         if (oldValue == null)
@@ -662,7 +662,7 @@
         } catch(CloneNotSupportedException e) {
             throw new AssertionError();
         }
-        result.vals = (Object[]) result.vals.clone();
+        result.vals = result.vals.clone();
         return result;
     }
 
--- a/jdk/src/share/classes/java/util/IdentityHashMap.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/util/IdentityHashMap.java	Mon Mar 10 15:07:09 2008 -0700
@@ -701,7 +701,7 @@
         try {
             IdentityHashMap<K,V> m = (IdentityHashMap<K,V>) super.clone();
             m.entrySet = null;
-            m.table = (Object[])table.clone();
+            m.table = table.clone();
             return m;
         } catch (CloneNotSupportedException e) {
             throw new InternalError();
@@ -975,7 +975,7 @@
          */
         public boolean removeAll(Collection<?> c) {
             boolean modified = false;
-            for (Iterator i = iterator(); i.hasNext(); ) {
+            for (Iterator<K> i = iterator(); i.hasNext(); ) {
                 if (c.contains(i.next())) {
                     i.remove();
                     modified = true;
@@ -1033,7 +1033,7 @@
             return containsValue(o);
         }
         public boolean remove(Object o) {
-            for (Iterator i = iterator(); i.hasNext(); ) {
+            for (Iterator<V> i = iterator(); i.hasNext(); ) {
                 if (i.next() == o) {
                     i.remove();
                     return true;
@@ -1121,7 +1121,7 @@
          */
         public boolean removeAll(Collection<?> c) {
             boolean modified = false;
-            for (Iterator i = iterator(); i.hasNext(); ) {
+            for (Iterator<Map.Entry<K,V>> i = iterator(); i.hasNext(); ) {
                 if (c.contains(i.next())) {
                     i.remove();
                     modified = true;
--- a/jdk/src/share/classes/java/util/JumboEnumSet.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/util/JumboEnumSet.java	Mon Mar 10 15:07:09 2008 -0700
@@ -364,7 +364,7 @@
 
     public EnumSet<E> clone() {
         JumboEnumSet<E> result = (JumboEnumSet<E>) super.clone();
-        result.elements = (long[]) result.elements.clone();
+        result.elements = result.elements.clone();
         return result;
     }
 }
--- a/jdk/src/share/classes/java/util/Random.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/util/Random.java	Mon Mar 10 15:07:09 2008 -0700
@@ -504,7 +504,7 @@
 
         // The seed is read in as {@code long} for
         // 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)
           throw new java.io.StreamCorruptedException(
                               "Random: invalid seed");
--- a/jdk/src/share/classes/java/util/TreeSet.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/util/TreeSet.java	Mon Mar 10 15:07:09 2008 -0700
@@ -195,7 +195,7 @@
      * @since 1.6
      */
     public NavigableSet<E> descendingSet() {
-        return new TreeSet(m.descendingMap());
+        return new TreeSet<E>(m.descendingMap());
     }
 
     /**
@@ -505,8 +505,8 @@
         s.writeInt(m.size());
 
         // Write out all elements in the proper order.
-        for (Iterator i=m.keySet().iterator(); i.hasNext(); )
-            s.writeObject(i.next());
+        for (E e : m.keySet())
+            s.writeObject(e);
     }
 
     /**
--- a/jdk/src/share/classes/java/util/prefs/AbstractPreferences.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/util/prefs/AbstractPreferences.java	Mon Mar 10 15:07:09 2008 -0700
@@ -155,7 +155,8 @@
      * All known unremoved children of this node.  (This "cache" is consulted
      * 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
@@ -712,11 +713,10 @@
             if (removed)
                 throw new IllegalStateException("Node has been removed.");
 
-            Set s = new TreeSet(kidCache.keySet());
-            String[] kids = childrenNamesSpi();
-            for(int i=0; i<kids.length; i++)
-                s.add(kids[i]);
-            return (String[]) s.toArray(EMPTY_STRING_ARRAY);
+            Set<String> s = new TreeSet<String>(kidCache.keySet());
+            for (String kid : childrenNamesSpi())
+                s.add(kid);
+            return s.toArray(EMPTY_STRING_ARRAY);
         }
     }
 
@@ -728,8 +728,7 @@
      * @return all known unremoved children of this node.
      */
     protected final AbstractPreferences[] cachedChildren() {
-        return (AbstractPreferences[]) kidCache.values().
-            toArray(EMPTY_ABSTRACT_PREFS_ARRAY);
+        return kidCache.values().toArray(EMPTY_ABSTRACT_PREFS_ARRAY);
     }
 
     private static final AbstractPreferences[] EMPTY_ABSTRACT_PREFS_ARRAY
@@ -825,7 +824,7 @@
         if (token.equals("/"))  // Check for consecutive slashes
             throw new IllegalArgumentException("Consecutive slashes in path");
         synchronized(lock) {
-            AbstractPreferences child=(AbstractPreferences)kidCache.get(token);
+            AbstractPreferences child = kidCache.get(token);
             if (child == null) {
                 if (token.length() > MAX_NAME_LENGTH)
                     throw new IllegalArgumentException(
@@ -893,7 +892,7 @@
         if (token.equals("/"))  // Check for consecutive slashes
             throw new IllegalArgumentException("Consecutive slashes in path");
         synchronized(lock) {
-            AbstractPreferences child=(AbstractPreferences)kidCache.get(token);
+            AbstractPreferences child = kidCache.get(token);
             if (child == null)
                 child = getChild(token);
             if (child==null)
@@ -964,9 +963,10 @@
                     kidCache.put(kidNames[i], childSpi(kidNames[i]));
 
             // Recursively remove all cached children
-            for (Iterator i = kidCache.values().iterator(); i.hasNext();) {
+            for (Iterator<AbstractPreferences> i = kidCache.values().iterator();
+                 i.hasNext();) {
                 try {
-                    ((AbstractPreferences)i.next()).removeNode2();
+                    i.next().removeNode2();
                     i.remove();
                 } catch (BackingStoreException x) { }
             }
@@ -1020,13 +1020,12 @@
      *         preference tree.
      */
     public boolean isUserNode() {
-        Boolean result = (Boolean)
-          AccessController.doPrivileged( new PrivilegedAction() {
-            public Object run() {
-                return Boolean.valueOf(root == Preferences.userRoot());
+        return AccessController.doPrivileged(
+            new PrivilegedAction<Boolean>() {
+                public Boolean run() {
+                    return root == Preferences.userRoot();
             }
-        });
-        return result.booleanValue();
+            }).booleanValue();
     }
 
     public void addPreferenceChangeListener(PreferenceChangeListener pcl) {
@@ -1443,7 +1442,8 @@
      * event delivery from preference activity, greatly simplifying
      * 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
@@ -1476,7 +1476,7 @@
                     try {
                         while (eventQueue.isEmpty())
                             eventQueue.wait();
-                        event = (EventObject) eventQueue.remove(0);
+                        event = eventQueue.remove(0);
                     } catch (InterruptedException e) {
                         // XXX Log "Event dispatch thread interrupted. Exiting"
                         return;
--- a/jdk/src/share/classes/java/util/regex/Matcher.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/util/regex/Matcher.java	Mon Mar 10 15:07:09 2008 -0700
@@ -249,7 +249,7 @@
         Matcher result = new Matcher(this.parentPattern, text.toString());
         result.first = this.first;
         result.last = this.last;
-        result.groups = (int[])(this.groups.clone());
+        result.groups = this.groups.clone();
         return result;
     }
 
--- a/jdk/src/share/classes/javax/rmi/ssl/SslRMIClientSocketFactory.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/javax/rmi/ssl/SslRMIClientSocketFactory.java	Mon Mar 10 15:07:09 2008 -0700
@@ -121,7 +121,7 @@
             sslSocketFactory.createSocket(host, port);
         // Set the SSLSocket Enabled Cipher Suites
         //
-        final String enabledCipherSuites = (String)
+        final String enabledCipherSuites =
             System.getProperty("javax.rmi.ssl.client.enabledCipherSuites");
         if (enabledCipherSuites != null) {
             StringTokenizer st = new StringTokenizer(enabledCipherSuites, ",");
@@ -139,7 +139,7 @@
         }
         // Set the SSLSocket Enabled Protocols
         //
-        final String enabledProtocols = (String)
+        final String enabledProtocols =
             System.getProperty("javax.rmi.ssl.client.enabledProtocols");
         if (enabledProtocols != null) {
             StringTokenizer st = new StringTokenizer(enabledProtocols, ",");
--- a/jdk/src/share/classes/javax/rmi/ssl/SslRMIServerSocketFactory.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/javax/rmi/ssl/SslRMIServerSocketFactory.java	Mon Mar 10 15:07:09 2008 -0700
@@ -165,9 +165,9 @@
         // Initialize the configuration parameters.
         //
         this.enabledCipherSuites = enabledCipherSuites == null ?
-            null : (String[]) enabledCipherSuites.clone();
+            null : enabledCipherSuites.clone();
         this.enabledProtocols = enabledProtocols == null ?
-            null : (String[]) enabledProtocols.clone();
+            null : enabledProtocols.clone();
         this.needClientAuth = needClientAuth;
 
         // Force the initialization of the default at construction time,
@@ -196,13 +196,11 @@
         //
         if (this.enabledCipherSuites != null) {
             sslSocket.setEnabledCipherSuites(this.enabledCipherSuites);
-            enabledCipherSuitesList =
-                    Arrays.asList((String[]) this.enabledCipherSuites);
+            enabledCipherSuitesList = Arrays.asList(this.enabledCipherSuites);
         }
         if (this.enabledProtocols != null) {
             sslSocket.setEnabledProtocols(this.enabledProtocols);
-            enabledProtocolsList =
-                    Arrays.asList((String[]) this.enabledProtocols);
+            enabledProtocolsList = Arrays.asList(this.enabledProtocols);
         }
     }
 
@@ -218,7 +216,7 @@
      */
     public final String[] getEnabledCipherSuites() {
         return enabledCipherSuites == null ?
-            null : (String[]) enabledCipherSuites.clone();
+            null : enabledCipherSuites.clone();
     }
 
     /**
@@ -234,7 +232,7 @@
      */
     public final String[] getEnabledProtocols() {
         return enabledProtocols == null ?
-            null : (String[]) enabledProtocols.clone();
+            null : enabledProtocols.clone();
     }
 
     /**
@@ -315,8 +313,8 @@
                 (enabledCipherSuites != null && that.enabledCipherSuites == null))
             return false;
         if (enabledCipherSuites != null && that.enabledCipherSuites != null) {
-            List thatEnabledCipherSuitesList =
-                    Arrays.asList((String[]) that.enabledCipherSuites);
+            List<String> thatEnabledCipherSuitesList =
+                    Arrays.asList(that.enabledCipherSuites);
             if (!enabledCipherSuitesList.equals(thatEnabledCipherSuitesList))
                 return false;
         }
@@ -327,8 +325,8 @@
                 (enabledProtocols != null && that.enabledProtocols == null))
             return false;
         if (enabledProtocols != null && that.enabledProtocols != null) {
-            List thatEnabledProtocolsList =
-                    Arrays.asList((String[]) that.enabledProtocols);
+            List<String> thatEnabledProtocolsList =
+                    Arrays.asList(that.enabledProtocols);
             if (!enabledProtocolsList.equals(thatEnabledProtocolsList))
                 return false;
         }
@@ -374,7 +372,7 @@
     private final String[] enabledCipherSuites;
     private final String[] enabledProtocols;
     private final boolean needClientAuth;
-    private List enabledCipherSuitesList;
-    private List enabledProtocolsList;
+    private List<String> enabledCipherSuitesList;
+    private List<String> enabledProtocolsList;
     private SSLContext context;
 }
--- a/jdk/src/share/classes/javax/security/auth/kerberos/KerberosTicket.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/javax/security/auth/kerberos/KerberosTicket.java	Mon Mar 10 15:07:09 2008 -0700
@@ -276,7 +276,7 @@
 
         if (flags != null) {
            if (flags.length >= NUM_FLAGS)
-                this.flags = (boolean[]) flags.clone();
+                this.flags = flags.clone();
            else {
                 this.flags = new boolean[NUM_FLAGS];
                 // Fill in whatever we have
@@ -304,7 +304,7 @@
         this.endTime = endTime;
 
         if (clientAddresses != null)
-           this.clientAddresses = (InetAddress[]) clientAddresses.clone();
+           this.clientAddresses = clientAddresses.clone();
     }
 
     /**
@@ -430,7 +430,7 @@
      * @return the flags associated with this ticket.
      */
     public final boolean[]  getFlags() {
-        return (flags == null? null: (boolean[]) flags.clone());
+        return (flags == null? null: flags.clone());
     }
 
     /**
@@ -479,8 +479,7 @@
      * provided.
      */
     public final java.net.InetAddress[] getClientAddresses() {
-        return (clientAddresses == null?
-                null: (InetAddress[]) clientAddresses.clone());
+        return (clientAddresses == null) ? null: clientAddresses.clone();
     }
 
     /**
@@ -491,7 +490,7 @@
     public final byte[] getEncoded() {
         if (destroyed)
             throw new IllegalStateException("This ticket is no longer valid");
-        return (byte[]) asn1Encoding.clone();
+        return asn1Encoding.clone();
     }
 
     /** Determines if this ticket is still current.  */
--- a/jdk/src/share/classes/javax/security/auth/kerberos/KeyImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/javax/security/auth/kerberos/KeyImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -66,7 +66,7 @@
      */
     public KeyImpl(byte[] keyBytes,
                        int keyType) {
-        this.keyBytes = (byte[]) keyBytes.clone();
+        this.keyBytes = keyBytes.clone();
         this.keyType = keyType;
     }
 
@@ -151,7 +151,7 @@
     public final byte[] getEncoded() {
         if (destroyed)
             throw new IllegalStateException("This key is no longer valid");
-        return (byte[])keyBytes.clone();
+        return keyBytes.clone();
     }
 
     public void destroy() throws DestroyFailedException {
--- a/jdk/src/share/classes/sun/misc/ClassFileTransformer.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/misc/ClassFileTransformer.java	Mon Mar 10 15:07:09 2008 -0700
@@ -46,8 +46,10 @@
 {
     // Singleton of ClassFileTransformer
     //
-    private static ArrayList transformerList = new ArrayList();
-    private static Object[] transformers = new Object[0];
+    private static ArrayList<ClassFileTransformer> transformerList
+        = new ArrayList<ClassFileTransformer>();
+    private static ClassFileTransformer[] transformers
+        = new ClassFileTransformer[0];
 
     /**
      * Add the class file transformer object.
@@ -59,7 +61,7 @@
         synchronized(transformerList)
         {
             transformerList.add(t);
-            transformers = transformerList.toArray();
+            transformers = transformerList.toArray(new ClassFileTransformer[0]);
         }
     }
 
@@ -68,7 +70,7 @@
      *
      * @return ClassFileTransformer object array
      */
-    public static Object[] getTransformers()
+    public static ClassFileTransformer[] getTransformers()
     {
         // transformers is not intended to be changed frequently,
         // so it is okay to not put synchronized block here
--- a/jdk/src/share/classes/sun/misc/Cleaner.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/misc/Cleaner.java	Mon Mar 10 15:07:09 2008 -0700
@@ -141,8 +141,8 @@
         try {
             thunk.run();
         } catch (final Throwable x) {
-            AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
+            AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                    public Void run() {
                         if (System.err != null)
                             new Error("Cleaner terminated abnormally", x)
                                 .printStackTrace();
--- a/jdk/src/share/classes/sun/misc/ExtensionDependency.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/misc/ExtensionDependency.java	Mon Mar 10 15:07:09 2008 -0700
@@ -284,10 +284,9 @@
         // Load the jar file ...
         Manifest man;
         try {
-            man = (Manifest) AccessController.doPrivileged
-                (
-                 new PrivilegedExceptionAction() {
-                     public Object run()
+            man = AccessController.doPrivileged(
+                new PrivilegedExceptionAction<Manifest>() {
+                    public Manifest run()
                             throws IOException, FileNotFoundException {
                          if (!file.exists())
                              throw new FileNotFoundException(file.getName());
@@ -391,9 +390,9 @@
         final String extName = extensionName;
         final String[] fileExt = {".jar", ".zip"};
 
-        return (File) AccessController.doPrivileged
-            (new PrivilegedAction() {
-                public Object run() {
+        return AccessController.doPrivileged(
+            new PrivilegedAction<File>() {
+                public File run() {
                     try {
                         File fExtension;
                         File[] dirs = getExtDirs();
@@ -460,7 +459,7 @@
      * @return the list of files installed in all the directories
      */
     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++) {
             String[] files = dirs[i].list(new JarFilter());
             if (files != null) {
@@ -484,16 +483,15 @@
      * </p>
      */
     private File[] getInstalledExtensions() throws IOException {
-        return (File[]) AccessController.doPrivileged
-            (
-             new PrivilegedAction() {
-                 public Object run() {
+        return AccessController.doPrivileged(
+            new PrivilegedAction<File[]>() {
+                public File[] run() {
                      try {
                          return getExtFiles(getExtDirs());
                      } catch(IOException e) {
                          debug("Cannot get list of installed extensions");
                          debugException(e);
-                         return new URL[0];
+                        return new File[0];
                      }
                  }
             });
--- a/jdk/src/share/classes/sun/misc/GC.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/misc/GC.java	Mon Mar 10 15:07:09 2008 -0700
@@ -128,8 +128,8 @@
 
         /* Create a new daemon thread in the root thread group */
         public static void create() {
-            PrivilegedAction pa = new PrivilegedAction() {
-                public Object run() {
+            PrivilegedAction<Void> pa = new PrivilegedAction<Void>() {
+                public Void run() {
                     ThreadGroup tg = Thread.currentThread().getThreadGroup();
                     for (ThreadGroup tgn = tg;
                          tgn != null;
@@ -170,13 +170,14 @@
      * method.  Given a request, the only interesting operation is that of
      * cancellation.
      */
-    public static class LatencyRequest implements Comparable {
+    public static class LatencyRequest
+        implements Comparable<LatencyRequest> {
 
         /* Instance counter, used to generate unique identifers */
         private static long counter = 0;
 
         /* 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.
          * Must be invoked while holding the lock.
@@ -187,7 +188,7 @@
                     setLatencyTarget(NO_TARGET);
                 }
             } else {
-                LatencyRequest r = (LatencyRequest)requests.first();
+                LatencyRequest r = requests.first();
                 if (r.latency != latencyTarget) {
                     setLatencyTarget(r.latency);
                 }
@@ -211,7 +212,7 @@
             synchronized (lock) {
                 this.id = ++counter;
                 if (requests == null) {
-                    requests = new TreeSet();
+                    requests = new TreeSet<LatencyRequest>();
                 }
                 requests.add(this);
                 adjustLatencyIfNeeded();
@@ -240,8 +241,7 @@
             }
         }
 
-        public int compareTo(Object o) {
-            LatencyRequest r = (LatencyRequest)o;
+        public int compareTo(LatencyRequest r) {
             long d = this.latency - r.latency;
             if (d == 0) d = this.id - r.id;
             return (d < 0) ? -1 : ((d > 0) ? +1 : 0);
--- a/jdk/src/share/classes/sun/misc/Launcher.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/misc/Launcher.java	Mon Mar 10 15:07:09 2008 -0700
@@ -135,9 +135,9 @@
                 // aa synthesized ACC via a call to the private method
                 // ExtClassLoader.getContext().
 
-                return (ExtClassLoader) AccessController.doPrivileged(
-                     new PrivilegedExceptionAction() {
-                        public Object run() throws IOException {
+                return AccessController.doPrivileged(
+                    new PrivilegedExceptionAction<ExtClassLoader>() {
+                        public ExtClassLoader run() throws IOException {
                             int len = dirs.length;
                             for (int i = 0; i < len; i++) {
                                 MetaIndex.registerDirectory(dirs[i]);
@@ -180,7 +180,7 @@
         }
 
         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++) {
                 String[] files = dirs[i].list();
                 if (files != null) {
@@ -261,9 +261,9 @@
             // when loading  classes. Specifically it prevent
             // accessClassInPackage.sun.* grants from being honored.
             //
-            return (AppClassLoader)
-                AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+            return AccessController.doPrivileged(
+                new PrivilegedAction<AppClassLoader>() {
+                    public AppClassLoader run() {
                     URL[] urls =
                         (s == null) ? new URL[0] : pathToURLs(path);
                     return new AppClassLoader(urls, extcl);
@@ -348,12 +348,12 @@
         URL[] urls;
         if (prop != null) {
             final String path = prop;
-            urls = (URL[])AccessController.doPrivileged(
-                new PrivilegedAction() {
-                    public Object run() {
+            urls = AccessController.doPrivileged(
+                new PrivilegedAction<URL[]>() {
+                    public URL[] run() {
                         File[] classPath = getClassPath(path);
                         int len = classPath.length;
-                        Set seenDirs = new HashSet();
+                        Set<File> seenDirs = new HashSet<File>();
                         for (int i = 0; i < len; i++) {
                             File curEntry = classPath[i];
                             // Negative test used to properly handle
@@ -509,8 +509,8 @@
         perms.add(new java.util.PropertyPermission("java.*",
             SecurityConstants.PROPERTY_READ_ACTION));
 
-        AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+            public Void run() {
                 for (int i=0; i < path.length; i++) {
                     File f = path[i];
                     String path;
@@ -553,7 +553,7 @@
         return perms.implies(permission);
     }
 
-    public java.util.Enumeration elements() {
+    public java.util.Enumeration<Permission> elements() {
         if (perms == null)
             init();
         synchronized (perms) {
--- a/jdk/src/share/classes/sun/misc/PerformanceLogger.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/misc/PerformanceLogger.java	Mon Mar 10 15:07:09 2008 -0700
@@ -78,7 +78,7 @@
 
     private static boolean perfLoggingOn = false;
     private static boolean useNanoTime = false;
-    private static Vector times;
+    private static Vector<TimeData> times;
     private static String logFileName = null;
     private static Writer logWriter = null;
 
@@ -104,8 +104,8 @@
             if (logFileName != null) {
                 if (logWriter == null) {
                     java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedAction() {
-                        public Object run() {
+                    new java.security.PrivilegedAction<Void>() {
+                        public Void run() {
                             try {
                                 File logFile = new File(logFileName);
                                 logFile.createNewFile();
@@ -124,7 +124,7 @@
                 logWriter = new OutputStreamWriter(System.out);
             }
         }
-        times = new Vector(10);
+        times = new Vector<TimeData>(10);
         // Reserve predefined slots
         for (int i = 0; i <= LAST_RESERVED; ++i) {
             times.add(new TimeData("Time " + i + " not set", 0));
@@ -207,7 +207,7 @@
      */
     public static long getStartTime() {
         if (loggingEnabled()) {
-            return ((TimeData)times.get(START_INDEX)).getTime();
+            return times.get(START_INDEX).getTime();
         } else {
             return 0;
         }
@@ -253,7 +253,7 @@
      */
     public static long getTimeAtIndex(int index) {
         if (loggingEnabled()) {
-            return ((TimeData)times.get(index)).getTime();
+            return times.get(index).getTime();
         } else {
             return 0;
         }
@@ -264,7 +264,7 @@
      */
     public static String getMessageAtIndex(int index) {
         if (loggingEnabled()) {
-            return ((TimeData)times.get(index)).getMessage();
+            return times.get(index).getMessage();
         } else {
             return null;
         }
@@ -278,7 +278,7 @@
             try {
                 synchronized(times) {
                     for (int i = 0; i < times.size(); ++i) {
-                        TimeData td = (TimeData)times.get(i);
+                        TimeData td = times.get(i);
                         if (td != null) {
                             writer.write(i + " " + td.getMessage() + ": " +
                                          td.getTime() + "\n");
--- a/jdk/src/share/classes/sun/misc/ProxyGenerator.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/misc/ProxyGenerator.java	Mon Mar 10 15:07:09 2008 -0700
@@ -324,8 +324,8 @@
 
         if (saveGeneratedFiles) {
             java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction() {
-                public Object run() {
+            new java.security.PrivilegedAction<Void>() {
+                public Void run() {
                     try {
                         FileOutputStream file =
                             new FileOutputStream(dotToSlash(name) + ".class");
@@ -576,7 +576,7 @@
                      * compatibly with the throws clauses of both
                      * overridden methods.
                      */
-                    List<Class> legalExceptions = new ArrayList<Class>();
+                    List<Class<?>> legalExceptions = new ArrayList<Class<?>>();
                     collectCompatibleTypes(
                         exceptionTypes, pm.exceptionTypes, legalExceptions);
                     collectCompatibleTypes(
@@ -618,11 +618,11 @@
          * List of return types that are not yet known to be
          * assignable from ("covered" by) any of the others.
          */
-        LinkedList<Class> uncoveredReturnTypes = new LinkedList<Class>();
+        LinkedList<Class<?>> uncoveredReturnTypes = new LinkedList<Class<?>>();
 
     nextNewReturnType:
         for (ProxyMethod pm : methods) {
-            Class newReturnType = pm.returnType;
+            Class<?> newReturnType = pm.returnType;
             if (newReturnType.isPrimitive()) {
                 throw new IllegalArgumentException(
                     "methods with same signature " +
@@ -637,9 +637,9 @@
              * Compare the new return type to the existing uncovered
              * return types.
              */
-            ListIterator<Class> liter = uncoveredReturnTypes.listIterator();
+            ListIterator<Class<?>> liter = uncoveredReturnTypes.listIterator();
             while (liter.hasNext()) {
-                Class uncoveredReturnType = liter.next();
+                Class<?> uncoveredReturnType = liter.next();
 
                 /*
                  * If an existing uncovered return type is assignable
@@ -944,10 +944,10 @@
 
             tryEnd = pc = (short) minfo.code.size();
 
-            List<Class> catchList = computeUniqueCatchList(exceptionTypes);
+            List<Class<?>> catchList = computeUniqueCatchList(exceptionTypes);
             if (catchList.size() > 0) {
 
-                for (Class ex : catchList) {
+                for (Class<?> ex : catchList) {
                     minfo.exceptionTable.add(new ExceptionTableEntry(
                         tryBegin, tryEnd, pc,
                         cp.getClass(dotToSlash(ex.getName()))));
@@ -1521,8 +1521,9 @@
      * declared exceptions from duplicate methods inherited from
      * different interfaces.
      */
-    private static void collectCompatibleTypes(Class[] from, Class[] with,
-                                               List<Class> list)
+    private static void collectCompatibleTypes(Class<?>[] from,
+                                               Class<?>[] with,
+                                               List<Class<?>> list)
     {
         for (int i = 0; i < from.length; i++) {
             if (!list.contains(from[i])) {
@@ -1557,8 +1558,8 @@
      * given list of declared exceptions, indicating that no exceptions
      * need to be caught.
      */
-    private static List<Class> computeUniqueCatchList(Class[] exceptions) {
-        List<Class> uniqueList = new ArrayList<Class>();
+    private static List<Class<?>> computeUniqueCatchList(Class<?>[] exceptions) {
+        List<Class<?>> uniqueList = new ArrayList<Class<?>>();
                                                 // unique exceptions to catch
 
         uniqueList.add(Error.class);            // always catch/rethrow these
@@ -1566,7 +1567,7 @@
 
     nextException:
         for (int i = 0; i < exceptions.length; i++) {
-            Class ex = exceptions[i];
+            Class<?> ex = exceptions[i];
             if (ex.isAssignableFrom(Throwable.class)) {
                 /*
                  * If Throwable is declared to be thrown by the proxy method,
@@ -1586,7 +1587,7 @@
              * exceptions that need to be caught:
              */
             for (int j = 0; j < uniqueList.size();) {
-                Class ex2 = uniqueList.get(j);
+                Class<?> ex2 = uniqueList.get(j);
                 if (ex2.isAssignableFrom(ex)) {
                     /*
                      * if a superclass of this exception is already on
--- a/jdk/src/share/classes/sun/misc/URLClassPath.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/misc/URLClassPath.java	Mon Mar 10 15:07:09 2008 -0700
@@ -86,16 +86,16 @@
     }
 
     /* The original search path of URLs. */
-    private ArrayList path = new ArrayList();
+    private ArrayList<URL> path = new ArrayList<URL>();
 
     /* The stack of unopened URLs */
-    Stack urls = new Stack();
+    Stack<URL> urls = new Stack<URL>();
 
     /* 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 */
-    HashMap lmap = new HashMap();
+    HashMap<URL, Loader> lmap = new HashMap<URL, Loader>();
 
     /* The jar protocol handler to use when creating new URLs */
     private URLStreamHandler jarHandler;
@@ -146,7 +146,7 @@
      */
     public URL[] getURLs() {
         synchronized (urls) {
-            return (URL[])path.toArray(new URL[path.size()]);
+            return path.toArray(new URL[path.size()]);
         }
     }
 
@@ -200,9 +200,9 @@
      * @param name the resource 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) {
-        return new Enumeration() {
+        return new Enumeration<URL>() {
             private int index = 0;
             private URL url = null;
 
@@ -225,7 +225,7 @@
                 return next();
             }
 
-            public Object nextElement() {
+            public URL nextElement() {
                 if (!next()) {
                     throw new NoSuchElementException();
                 }
@@ -247,9 +247,9 @@
      * @param name the resource 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) {
-        return new Enumeration() {
+        return new Enumeration<Resource>() {
             private int index = 0;
             private Resource res = null;
 
@@ -272,7 +272,7 @@
                 return next();
             }
 
-            public Object nextElement() {
+            public Resource nextElement() {
                 if (!next()) {
                     throw new NoSuchElementException();
                 }
@@ -283,7 +283,7 @@
         };
     }
 
-    public Enumeration getResources(final String name) {
+    public Enumeration<Resource> getResources(final String name) {
         return getResources(name, true);
     }
 
@@ -302,7 +302,7 @@
                 if (urls.empty()) {
                     return null;
                 } else {
-                    url = (URL)urls.pop();
+                    url = urls.pop();
                 }
             }
             // Skip this URL if it already has a Loader. (Loader
@@ -329,7 +329,7 @@
             loaders.add(loader);
             lmap.put(url, loader);
         }
-        return (Loader)loaders.get(index);
+        return loaders.get(index);
     }
 
     /*
@@ -337,9 +337,9 @@
      */
     private Loader getLoader(final URL url) throws IOException {
         try {
-            return (Loader)java.security.AccessController.doPrivileged
-                (new java.security.PrivilegedExceptionAction() {
-                public Object run() throws IOException {
+            return java.security.AccessController.doPrivileged(
+                new java.security.PrivilegedExceptionAction<Loader>() {
+                public Loader run() throws IOException {
                     String file = url.getFile();
                     if (file != null && file.endsWith("/")) {
                         if ("file".equals(url.getProtocol())) {
@@ -561,13 +561,14 @@
         private JarIndex index;
         private MetaIndex metaIndex;
         private URLStreamHandler handler;
-        private HashMap lmap;
+        private HashMap<URL, Loader> lmap;
 
         /*
          * Creates a new JarLoader for the specified URL referring to
          * a JAR file.
          */
-        JarLoader(URL url, URLStreamHandler jarHandler, HashMap loaderMap)
+        JarLoader(URL url, URLStreamHandler jarHandler,
+                  HashMap<URL, Loader> loaderMap)
             throws IOException
         {
             super(new URL("jar", "", -1, url + "!/", jarHandler));
@@ -615,8 +616,8 @@
             if (jar == null) {
                 try {
                     java.security.AccessController.doPrivileged(
-                        new java.security.PrivilegedExceptionAction() {
-                            public Object run() throws IOException {
+                        new java.security.PrivilegedExceptionAction<Void>() {
+                            public Void run() throws IOException {
                                 if (DEBUG) {
                                     System.err.println("Opening " + csu);
                                     Thread.dumpStack();
@@ -732,9 +733,9 @@
 
             String entryName;
             ZipEntry entry;
-            Enumeration enum_ = jar.entries();
+            Enumeration<JarEntry> enum_ = jar.entries();
             while (enum_.hasMoreElements()) {
-                entry = (ZipEntry)enum_.nextElement();
+                entry = enum_.nextElement();
                 entryName = entry.getName();
                 if((pos = entryName.lastIndexOf("/")) != -1)
                     entryName = entryName.substring(0, pos);
@@ -778,7 +779,7 @@
             if (index == null)
                 return null;
 
-            HashSet visited = new HashSet();
+            HashSet<URL> visited = new HashSet<URL>();
             return getResource(name, check, visited);
         }
 
@@ -790,7 +791,7 @@
          * non-existent resource
          */
         Resource getResource(final String name, boolean check,
-                Set visited) {
+                             Set<URL> visited) {
 
             Resource res;
             Object[] jarFiles;
@@ -819,10 +820,9 @@
                             /* no loader has been set up for this jar file
                              * before
                              */
-                            newLoader = (JarLoader)
-                                AccessController.doPrivileged(
-                                    new PrivilegedExceptionAction() {
-                                    public Object run() throws IOException {
+                            newLoader = AccessController.doPrivileged(
+                                new PrivilegedExceptionAction<JarLoader>() {
+                                    public JarLoader run() throws IOException {
                                         return new JarLoader(url, handler,
                                             lmap);
                                     }
--- a/jdk/src/share/classes/sun/net/NetProperties.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/net/NetProperties.java	Mon Mar 10 15:07:09 2008 -0700
@@ -42,8 +42,8 @@
     static private Properties props = new Properties();
     static {
         AccessController.doPrivileged(
-            new PrivilegedAction() {
-                public Object run() {
+            new PrivilegedAction<Void>() {
+                public Void run() {
                     loadDefaultProperties();
                     return null;
                 }});
--- a/jdk/src/share/classes/sun/net/NetworkClient.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/net/NetworkClient.java	Mon Mar 10 15:07:09 2008 -0700
@@ -64,8 +64,8 @@
         final String encs[] = { null };
 
         AccessController.doPrivileged(
-                new PrivilegedAction() {
-                    public Object run() {
+                new PrivilegedAction<Void>() {
+                    public Void run() {
                         vals[0] = Integer.getInteger("sun.net.client.defaultReadTimeout", 0).intValue();
                         vals[1] = Integer.getInteger("sun.net.client.defaultConnectTimeout", 0).intValue();
                         encs[0] = System.getProperty("file.encoding", "ISO8859_1");
@@ -152,9 +152,9 @@
         Socket s;
         if (proxy != null) {
             if (proxy.type() == Proxy.Type.SOCKS) {
-                s = (Socket) AccessController.doPrivileged(
-                               new PrivilegedAction() {
-                                   public Object run() {
+                s = AccessController.doPrivileged(
+                    new PrivilegedAction<Socket>() {
+                        public Socket run() {
                                        return new Socket(proxy);
                                    }});
             } else
--- a/jdk/src/share/classes/sun/net/ftp/FtpClient.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/net/ftp/FtpClient.java	Mon Mar 10 15:07:09 2008 -0700
@@ -117,8 +117,8 @@
     public static int getFtpProxyPort() {
         final int result[] = {80};
         java.security.AccessController.doPrivileged(
-          new java.security.PrivilegedAction() {
-            public Object run() {
+            new java.security.PrivilegedAction<Void>() {
+                public Void run() {
 
                 String tmp = System.getProperty("ftp.proxyPort");
                 if (tmp == null) {
@@ -343,9 +343,9 @@
         Socket s;
         if (proxy != null) {
             if (proxy.type() == Proxy.Type.SOCKS) {
-                s = (Socket) AccessController.doPrivileged(
-                                            new PrivilegedAction() {
-                              public Object run() {
+                s = AccessController.doPrivileged(
+                    new PrivilegedAction<Socket>() {
+                        public Socket run() {
                                   return new Socket(proxy);
                               }});
             } else
--- a/jdk/src/share/classes/sun/net/spi/DefaultProxySelector.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/net/spi/DefaultProxySelector.java	Mon Mar 10 15:07:09 2008 -0700
@@ -82,9 +82,9 @@
 
     static {
         final String key = "java.net.useSystemProxies";
-        Boolean b = (Boolean) AccessController.doPrivileged(
-            new PrivilegedAction() {
-                public Object run() {
+        Boolean b = AccessController.doPrivileged(
+            new PrivilegedAction<Boolean>() {
+                public Boolean run() {
                     return NetProperties.getBoolean(key);
                 }});
         if (b != null && b.booleanValue()) {
@@ -197,9 +197,9 @@
          * System properties it does help having only 1 call to doPrivileged.
          * Be mindful what you do in here though!
          */
-        Proxy p = (Proxy) AccessController.doPrivileged(
-            new PrivilegedAction() {
-                public Object run() {
+        Proxy p = AccessController.doPrivileged(
+            new PrivilegedAction<Proxy>() {
+                public Proxy run() {
                     int i, j;
                     String phost =  null;
                     int pport = 0;
--- a/jdk/src/share/classes/sun/net/www/MessageHeader.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/net/www/MessageHeader.java	Mon Mar 10 15:07:09 2008 -0700
@@ -138,7 +138,7 @@
         return null;
     }
 
-    class HeaderIterator implements Iterator {
+    class HeaderIterator implements Iterator<String> {
         int index = 0;
         int next = -1;
         String key;
@@ -165,7 +165,7 @@
                 return false;
             }
         }
-        public Object next() {
+        public String next() {
             synchronized (lock) {
                 if (haveNext) {
                     haveNext = false;
@@ -187,17 +187,17 @@
      * return an Iterator that returns all values of a particular
      * key in sequence
      */
-    public Iterator multiValueIterator (String k) {
+    public Iterator<String> multiValueIterator (String k) {
         return new HeaderIterator (k, this);
     }
 
-    public synchronized Map getHeaders() {
+    public synchronized Map<String, List<String>> getHeaders() {
         return getHeaders(null);
     }
 
-    public synchronized Map getHeaders(String[] excludeList) {
+    public synchronized Map<String, List<String>> getHeaders(String[] excludeList) {
         boolean skipIt = false;
-        Map m = new HashMap();
+        Map<String, List<String>> m = new HashMap<String, List<String>>();
         for (int i = nkeys; --i >= 0;) {
             if (excludeList != null) {
                 // check if the key is in the excludeList.
@@ -211,9 +211,9 @@
                 }
             }
             if (!skipIt) {
-                List l = (List)m.get(keys[i]);
+                List<String> l = m.get(keys[i]);
                 if (l == null) {
-                    l = new ArrayList();
+                    l = new ArrayList<String>();
                     m.put(keys[i], l);
                 }
                 l.add(values[i]);
@@ -223,11 +223,8 @@
             }
         }
 
-        Set keySet = m.keySet();
-        for (Iterator i = keySet.iterator(); i.hasNext();) {
-            Object key = i.next();
-            List l = (List)m.get(key);
-            m.put(key, Collections.unmodifiableList(l));
+        for (String key : m.keySet()) {
+            m.put(key, Collections.unmodifiableList(m.get(key)));
         }
 
         return Collections.unmodifiableMap(m);
--- a/jdk/src/share/classes/sun/net/www/MimeTable.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/net/www/MimeTable.java	Mon Mar 10 15:07:09 2008 -0700
@@ -37,18 +37,20 @@
 
 public class MimeTable implements FileNameMap {
     /** Keyed by content type, returns MimeEntries */
-    private Hashtable entries = new Hashtable();
+    private Hashtable<String, MimeEntry> entries
+        = new Hashtable<String, MimeEntry>();
 
     /** Keyed by file extension (with the .), returns MimeEntries */
-    private Hashtable extensionMap = new Hashtable();
+    private Hashtable<String, MimeEntry> extensionMap
+        = new Hashtable<String, MimeEntry>();
 
     // Will be reset if in the platform-specific data file
     private static String tempFileTemplate;
 
     static {
         java.security.AccessController.doPrivileged(
-                                   new java.security.PrivilegedAction() {
-            public Object run() {
+            new java.security.PrivilegedAction<Void>() {
+                public Void run() {
                 tempFileTemplate =
                     System.getProperty("content.types.temp.file.template",
                                        "/tmp/%s");
@@ -60,7 +62,8 @@
                     "/usr/etc/mailcap",
                     "/usr/local/etc/mailcap",
                     System.getProperty("hotjava.home",
-                                       "/usr/local/hotjava") + "/lib/mailcap",
+                                           "/usr/local/hotjava")
+                        + "/lib/mailcap",
                 };
                 return null;
             }
@@ -83,8 +86,8 @@
     public static MimeTable getDefaultTable() {
         if (defaultInstance == null) {
             java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction() {
-                public Object run() {
+                new java.security.PrivilegedAction<Void>() {
+                    public Void run() {
                     defaultInstance = new MimeTable();
                     URLConnection.setFileNameMap(defaultInstance);
                     return null;
@@ -130,7 +133,7 @@
     }
 
     public synchronized MimeEntry remove(String type) {
-        MimeEntry entry = (MimeEntry)entries.get(type);
+        MimeEntry entry = entries.get(type);
         return remove(entry);
     }
 
@@ -142,16 +145,16 @@
             }
         }
 
-        return (MimeEntry)entries.remove(entry.getType());
+        return entries.remove(entry.getType());
     }
 
     public synchronized MimeEntry find(String type) {
-        MimeEntry entry = (MimeEntry)entries.get(type);
+        MimeEntry entry = entries.get(type);
         if (entry == null) {
             // try a wildcard lookup
-            Enumeration e = entries.elements();
+            Enumeration<MimeEntry> e = entries.elements();
             while (e.hasMoreElements()) {
-                MimeEntry wild = (MimeEntry)e.nextElement();
+                MimeEntry wild = e.nextElement();
                 if (wild.matches(type)) {
                     return wild;
                 }
@@ -191,13 +194,13 @@
      * with it.
      */
     public synchronized MimeEntry findByExt(String fileExtension) {
-        return (MimeEntry)extensionMap.get(fileExtension);
+        return extensionMap.get(fileExtension);
     }
 
     public synchronized MimeEntry findByDescription(String description) {
-        Enumeration e = elements();
+        Enumeration<MimeEntry> e = elements();
         while (e.hasMoreElements()) {
-            MimeEntry entry = (MimeEntry)e.nextElement();
+            MimeEntry entry = e.nextElement();
             if (description.equals(entry.getDescription())) {
                 return entry;
             }
@@ -211,7 +214,7 @@
         return tempFileTemplate;
     }
 
-    public synchronized Enumeration elements() {
+    public synchronized Enumeration<MimeEntry> elements() {
         return entries.elements();
     }
 
@@ -269,7 +272,7 @@
         }
 
         // now, parse the mime-type spec's
-        Enumeration types = entries.propertyNames();
+        Enumeration<?> types = entries.propertyNames();
         while (types.hasMoreElements()) {
             String type = (String)types.nextElement();
             String attrs = entries.getProperty(type);
@@ -392,9 +395,9 @@
 
     public Properties getAsProperties() {
         Properties properties = new Properties();
-        Enumeration e = elements();
+        Enumeration<MimeEntry> e = elements();
         while (e.hasMoreElements()) {
-            MimeEntry entry = (MimeEntry)e.nextElement();
+            MimeEntry entry = e.nextElement();
             properties.put(entry.getType(), entry.toProperty());
         }
 
--- a/jdk/src/share/classes/sun/net/www/http/HttpClient.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/net/www/http/HttpClient.java	Mon Mar 10 15:07:09 2008 -0700
@@ -230,9 +230,9 @@
         setConnectTimeout(to);
 
         // get the cookieHandler if there is any
-        cookieHandler = (CookieHandler)java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction() {
-                public Object run() {
+        cookieHandler = java.security.AccessController.doPrivileged(
+            new java.security.PrivilegedAction<CookieHandler>() {
+                public CookieHandler run() {
                     return CookieHandler.getDefault();
                 }
             });
@@ -297,7 +297,7 @@
         HttpClient ret = null;
         /* see if one's already around */
         if (useCache) {
-            ret = (HttpClient) kac.get(url, null);
+            ret = kac.get(url, null);
             if (ret != null) {
                 if ((ret.proxy != null && ret.proxy.equals(p)) ||
                     (ret.proxy == null && p == null)) {
@@ -389,7 +389,7 @@
      * cache).
      */
     public void closeIdleConnection() {
-        HttpClient http = (HttpClient) kac.get(url, null);
+        HttpClient http = kac.get(url, null);
         if (http != null) {
             http.closeServer();
         }
@@ -447,8 +447,8 @@
     {
         try {
             java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedExceptionAction() {
-                public Object run() throws IOException {
+                new java.security.PrivilegedExceptionAction<Void>() {
+                    public Void run() throws IOException {
                     openServer(server.getHostString(), server.getPort());
                     return null;
                 }
@@ -477,9 +477,8 @@
     {
         try {
             java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedExceptionAction() {
-                public Object run() throws IOException
-                {
+                new java.security.PrivilegedExceptionAction<Void>() {
+                    public Void run() throws IOException {
                     superOpenServer(proxyHost, proxyPort);
                     return null;
                 }
@@ -686,7 +685,7 @@
                     // So we do put the cast in as a workaround until
                     // it is resolved.
                     if (uri != null)
-                        cookieHandler.put(uri, (Map<java.lang.String,java.util.List<java.lang.String>>)responses.getHeaders());
+                        cookieHandler.put(uri, responses.getHeaders());
                 }
 
                 /* decide if we're keeping alive:
--- a/jdk/src/share/classes/sun/net/www/http/KeepAliveCache.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/net/www/http/KeepAliveCache.java	Mon Mar 10 15:07:09 2008 -0700
@@ -38,7 +38,9 @@
  * @author Stephen R. Pietrowicz (NCSA)
  * @author Dave Brown
  */
-public class KeepAliveCache extends ConcurrentHashMap implements Runnable {
+public class KeepAliveCache
+    extends ConcurrentHashMap<KeepAliveKey, ClientVector>
+    implements Runnable {
     private static final long serialVersionUID = -2937172892064557949L;
 
     /* maximum # keep-alive connections to maintain at once
@@ -88,12 +90,12 @@
              * back from the server.  If I'm connected through a Netscape proxy
              * to a server that sent me a keep-alive
              * time of 15 sec, the proxy unilaterally terminates my connection
-             * The robustness to to get around this is in HttpClient.parseHTTP()
+             * The robustness to get around this is in HttpClient.parseHTTP()
              */
             final KeepAliveCache cache = this;
             java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction() {
-                public Object run() {
+                new java.security.PrivilegedAction<Void>() {
+                public Void run() {
                    // We want to create the Keep-Alive-Timer in the
                     // system threadgroup
                     ThreadGroup grp = Thread.currentThread().getThreadGroup();
@@ -112,7 +114,7 @@
         }
 
         KeepAliveKey key = new KeepAliveKey(url, obj);
-        ClientVector v = (ClientVector)super.get(key);
+        ClientVector v = super.get(key);
 
         if (v == null) {
             int keepAliveTimeout = http.getKeepAliveTimeout();
@@ -125,10 +127,10 @@
         }
     }
 
-    /* remove an obsolete HttpClient from it's VectorCache */
+    /* remove an obsolete HttpClient from its VectorCache */
     public synchronized void remove (HttpClient h, Object obj) {
         KeepAliveKey key = new KeepAliveKey(h.url, obj);
-        ClientVector v = (ClientVector)super.get(key);
+        ClientVector v = super.get(key);
         if (v != null) {
             v.remove(h);
             if (v.empty()) {
@@ -137,7 +139,7 @@
         }
     }
 
-    /* called by a clientVector thread when all it's connections have timed out
+    /* called by a clientVector thread when all its connections have timed out
      * and that vector of connections should be removed.
      */
     synchronized void removeVector(KeepAliveKey k) {
@@ -147,10 +149,10 @@
     /**
      * Check to see if this URL has a cached HttpClient
      */
-    public synchronized Object get(URL url, Object obj) {
+    public synchronized HttpClient get(URL url, Object obj) {
 
         KeepAliveKey key = new KeepAliveKey(url, obj);
-        ClientVector v = (ClientVector)super.get(key);
+        ClientVector v = super.get(key);
         if (v == null) { // nothing in cache yet
             return null;
         }
@@ -180,17 +182,16 @@
 
                 long currentTime = System.currentTimeMillis();
 
-                Iterator itr = keySet().iterator();
-                ArrayList keysToRemove = new ArrayList();
+                ArrayList<KeepAliveKey> keysToRemove
+                    = new ArrayList<KeepAliveKey>();
 
-                while (itr.hasNext()) {
-                    KeepAliveKey key = (KeepAliveKey)itr.next();
-                    ClientVector v = (ClientVector)get(key);
+                for (KeepAliveKey key : keySet()) {
+                    ClientVector v = get(key);
                     synchronized (v) {
                         int i;
 
                         for (i = 0; i < v.size(); i++) {
-                            KeepAliveEntry e = (KeepAliveEntry)v.elementAt(i);
+                            KeepAliveEntry e = v.elementAt(i);
                             if ((currentTime - e.idleStartTime) > v.nap) {
                                 HttpClient h = e.hc;
                                 h.closeServer();
@@ -205,9 +206,9 @@
                         }
                     }
                 }
-                itr = keysToRemove.iterator();
-                while (itr.hasNext()) {
-                    removeVector((KeepAliveKey)itr.next());
+
+                for (KeepAliveKey key : keysToRemove) {
+                    removeVector(key);
                 }
             }
         } while (size() > 0);
@@ -234,7 +235,7 @@
  */
 
 
-class ClientVector extends java.util.Stack {
+class ClientVector extends java.util.Stack<KeepAliveEntry> {
     private static final long serialVersionUID = -8680532108106489459L;
 
     // sleep time in milliseconds, before cache clear
@@ -254,7 +255,7 @@
             HttpClient hc = null;
             long currentTime = System.currentTimeMillis();
             do {
-                KeepAliveEntry e = (KeepAliveEntry)pop();
+                KeepAliveEntry e = pop();
                 if ((currentTime - e.idleStartTime) > nap) {
                     e.hc.closeServer();
                 } else {
--- a/jdk/src/share/classes/sun/net/www/http/KeepAliveStream.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/net/www/http/KeepAliveStream.java	Mon Mar 10 15:07:09 2008 -0700
@@ -174,8 +174,8 @@
 
         if (startCleanupThread) {
             java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction() {
-                public Object run() {
+                new java.security.PrivilegedAction<Void>() {
+                public Void run() {
                     // We want to create the Keep-Alive-SocketCleaner in the
                     // system threadgroup
                     ThreadGroup grp = Thread.currentThread().getThreadGroup();
--- a/jdk/src/share/classes/sun/net/www/http/KeepAliveStreamCleaner.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/net/www/http/KeepAliveStreamCleaner.java	Mon Mar 10 15:07:09 2008 -0700
@@ -59,19 +59,19 @@
 
     static {
         final String maxDataKey = "http.KeepAlive.remainingData";
-        int maxData = ((Integer) AccessController.doPrivileged(
-            new PrivilegedAction() {
-                public Object run() {
-                    return new Integer(NetProperties.getInteger(maxDataKey, MAX_DATA_REMAINING));
-                }})).intValue() * 1024;
+        int maxData = AccessController.doPrivileged(
+            new PrivilegedAction<Integer>() {
+                public Integer run() {
+                    return NetProperties.getInteger(maxDataKey, MAX_DATA_REMAINING);
+                }}).intValue() * 1024;
         MAX_DATA_REMAINING = maxData;
 
         final String maxCapacityKey = "http.KeepAlive.queuedConnections";
-        int maxCapacity = ((Integer) AccessController.doPrivileged(
-            new PrivilegedAction() {
-                public Object run() {
-                    return new Integer(NetProperties.getInteger(maxCapacityKey, MAX_CAPACITY));
-                }})).intValue();
+        int maxCapacity = AccessController.doPrivileged(
+            new PrivilegedAction<Integer>() {
+                public Integer run() {
+                    return NetProperties.getInteger(maxCapacityKey, MAX_CAPACITY);
+                }}).intValue();
         MAX_CAPACITY = maxCapacity;
 
     }
--- a/jdk/src/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java	Mon Mar 10 15:07:09 2008 -0700
@@ -215,12 +215,11 @@
         Proxy p = null;
         if (instProxy == null) { // no per connection proxy specified
             /**
-             * Do we have to use a proxie?
+             * Do we have to use a proxy?
              */
-            ProxySelector sel = (ProxySelector)
-                java.security.AccessController.doPrivileged(
-                        new java.security.PrivilegedAction() {
-                            public Object run() {
+            ProxySelector sel = java.security.AccessController.doPrivileged(
+                new java.security.PrivilegedAction<ProxySelector>() {
+                    public ProxySelector run() {
                                 return ProxySelector.getDefault();
                             }
                             });
--- a/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Mon Mar 10 15:07:09 2008 -0700
@@ -144,8 +144,8 @@
 
     static {
         maxRedirects = java.security.AccessController.doPrivileged(
-                new sun.security.action.GetIntegerAction("http.maxRedirects",
-                defaultmaxRedirects)).intValue();
+            new sun.security.action.GetIntegerAction(
+                "http.maxRedirects", defaultmaxRedirects)).intValue();
         version = java.security.AccessController.doPrivileged(
                     new sun.security.action.GetPropertyAction("java.version"));
         String agent = java.security.AccessController.doPrivileged(
@@ -291,10 +291,9 @@
                             final String scheme,
                             final URL url,
                             final RequestorType authType) {
-        return (PasswordAuthentication)
-            java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction() {
-                public Object run() {
+        return java.security.AccessController.doPrivileged(
+            new java.security.PrivilegedAction<PasswordAuthentication>() {
+                public PasswordAuthentication run() {
                     return Authenticator.requestPasswordAuthentication(
                         host, addr, port, protocol,
                         prompt, scheme, url, authType);
@@ -559,15 +558,15 @@
         responses = new MessageHeader();
         this.handler = handler;
         instProxy = p;
-        cookieHandler = (CookieHandler)java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction() {
-            public Object run() {
+        cookieHandler = java.security.AccessController.doPrivileged(
+            new java.security.PrivilegedAction<CookieHandler>() {
+                public CookieHandler run() {
                 return CookieHandler.getDefault();
             }
         });
-        cacheHandler = (ResponseCache)java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction() {
-            public Object run() {
+        cacheHandler = java.security.AccessController.doPrivileged(
+            new java.security.PrivilegedAction<ResponseCache>() {
+                public ResponseCache run() {
                 return ResponseCache.getDefault();
             }
         });
@@ -650,8 +649,8 @@
         final boolean result[] = {false};
 
         java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction() {
-            public Object run() {
+            new java.security.PrivilegedAction<Void>() {
+                public Void run() {
                 try {
                     InetAddress a1 = InetAddress.getByName(h1);
                     InetAddress a2 = InetAddress.getByName(h2);
@@ -729,10 +728,10 @@
                 /**
                  * Do we have to use a proxy?
                  */
-                ProxySelector sel = (ProxySelector)
+                ProxySelector sel =
                     java.security.AccessController.doPrivileged(
-                             new java.security.PrivilegedAction() {
-                                 public Object run() {
+                        new java.security.PrivilegedAction<ProxySelector>() {
+                            public ProxySelector run() {
                                      return ProxySelector.getDefault();
                                  }
                              });
@@ -908,25 +907,23 @@
 
             URI uri = ParseUtil.toURI(url);
             if (uri != null) {
-                Map cookies = cookieHandler.get(uri, requests.getHeaders(EXCLUDE_HEADERS));
+                Map<String, List<String>> cookies
+                    = cookieHandler.get(
+                        uri, requests.getHeaders(EXCLUDE_HEADERS));
                 if (!cookies.isEmpty()) {
-                    Set s = cookies.entrySet();
-                    Iterator k_itr = s.iterator();
-                    while (k_itr.hasNext()) {
-                        Map.Entry entry = (Map.Entry)k_itr.next();
-                        String key = (String)entry.getKey();
+                    for (Map.Entry<String, List<String>> entry :
+                             cookies.entrySet()) {
+                        String key = entry.getKey();
                         // ignore all entries that don't have "Cookie"
                         // or "Cookie2" as keys
                         if (!"Cookie".equalsIgnoreCase(key) &&
                             !"Cookie2".equalsIgnoreCase(key)) {
                             continue;
                         }
-                        List l = (List)entry.getValue();
+                        List<String> l = entry.getValue();
                         if (l != null && !l.isEmpty()) {
-                            Iterator v_itr = l.iterator();
                             StringBuilder cookieValue = new StringBuilder();
-                            while (v_itr.hasNext()) {
-                                String value = (String)v_itr.next();
+                            for (String value : l) {
                                 cookieValue.append(value).append(';');
                             }
                             // strip off the ending ;-sign
@@ -1363,23 +1360,20 @@
      * original exception and with the same message. Right now,
      * there is no convenient APIs for doing so.
      */
-    private IOException getChainedException(IOException rememberedException) {
+    private IOException getChainedException(final IOException rememberedException) {
         try {
-            final IOException originalException = rememberedException;
-            final Class[] cls = new Class[1];
-            cls[0] = String.class;
-            final String[] args = new String[1];
-            args[0] = originalException.getMessage();
-            IOException chainedException = (IOException)
-                java.security.AccessController.doPrivileged
-                (new java.security.PrivilegedExceptionAction() {
-                        public Object run()
-                            throws Exception {
-                            Constructor ctr = originalException.getClass().getConstructor(cls);
-                            return (IOException)ctr.newInstance((Object[])args);
+            final Object[] args = { rememberedException.getMessage() };
+            IOException chainedException =
+                java.security.AccessController.doPrivileged(
+                    new java.security.PrivilegedExceptionAction<IOException>() {
+                        public IOException run() throws Exception {
+                            return (IOException)
+                                rememberedException.getClass()
+                                .getConstructor(new Class[] { String.class })
+                                .newInstance(args);
                         }
                     });
-            chainedException.initCause(originalException);
+            chainedException.initCause(rememberedException);
             return chainedException;
         } catch (Exception ignored) {
             return rememberedException;
@@ -1629,10 +1623,9 @@
                     InetAddress addr = null;
                     try {
                         final String finalHost = host;
-                        addr = (InetAddress)
-                            java.security.AccessController.doPrivileged
-                                (new java.security.PrivilegedExceptionAction() {
-                                public Object run()
+                        addr = java.security.AccessController.doPrivileged(
+                            new java.security.PrivilegedExceptionAction<InetAddress>() {
+                                public InetAddress run()
                                     throws java.net.UnknownHostException {
                                     return InetAddress.getByName(finalHost);
                                 }
@@ -2174,7 +2167,7 @@
      * @return a Map of header fields
      * @since 1.4
      */
-    public Map getHeaderFields() {
+    public Map<String, List<String>> getHeaderFields() {
         try {
             getInputStream();
         } catch (IOException e) {}
@@ -2286,7 +2279,7 @@
      * @throws IllegalStateException if already connected
      * @since 1.4
      */
-    public Map getRequestProperties() {
+    public Map<String, List<String>> getRequestProperties() {
         if (connected)
             throw new IllegalStateException("Already connected");
 
@@ -2367,20 +2360,15 @@
         return method;
     }
 
-    private MessageHeader mapToMessageHeader(Map map) {
+    private MessageHeader mapToMessageHeader(Map<String, List<String>> map) {
         MessageHeader headers = new MessageHeader();
         if (map == null || map.isEmpty()) {
             return headers;
         }
-        Set entries = map.entrySet();
-        Iterator itr1 = entries.iterator();
-        while (itr1.hasNext()) {
-            Map.Entry entry = (Map.Entry)itr1.next();
-            String key = (String)entry.getKey();
-            List values = (List)entry.getValue();
-            Iterator itr2 = values.iterator();
-            while (itr2.hasNext()) {
-                String value = (String)itr2.next();
+        for (Map.Entry<String, List<String>> entry : map.entrySet()) {
+            String key = entry.getKey();
+            List<String> values = entry.getValue();
+            for (String value : values) {
                 if (key == null) {
                     headers.prepend(key, value);
                 } else {
--- a/jdk/src/share/classes/sun/net/www/protocol/jar/URLJarFile.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/net/www/protocol/jar/URLJarFile.java	Mon Mar 10 15:07:09 2008 -0700
@@ -55,7 +55,7 @@
 
     private Manifest superMan;
     private Attributes superAttr;
-    private Map superEntries;
+    private Map<String, Attributes> superEntries;
 
     static JarFile getJarFile(URL url) throws IOException {
         return getJarFile(url, null);
@@ -146,12 +146,10 @@
 
         // now deep copy the manifest entries
         if (superEntries != null) {
-            Map entries = man.getEntries();
-            Iterator it = superEntries.keySet().iterator();
-            while (it.hasNext()) {
-                Object key = it.next();
-                Attributes at = (Attributes)superEntries.get(key);
-                entries.put(key, at.clone());
+            Map<String, Attributes> entries = man.getEntries();
+            for (String key : superEntries.keySet()) {
+                Attributes at = superEntries.get(key);
+                entries.put(key, (Attributes) at.clone());
             }
         }
 
@@ -213,9 +211,9 @@
             final InputStream in =  url.openConnection().getInputStream();
 
             try {
-                result = (JarFile)
-                    AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                        public Object run() throws IOException {
+                result = AccessController.doPrivileged(
+                    new PrivilegedExceptionAction<JarFile>() {
+                        public JarFile run() throws IOException {
                             OutputStream out = null;
                             File tmpFile = null;
                             try {
@@ -273,9 +271,9 @@
 
         public Attributes getAttributes() throws IOException {
             if (URLJarFile.this.isSuperMan()) {
-                Map e = URLJarFile.this.superEntries;
+                Map<String, Attributes> e = URLJarFile.this.superEntries;
                 if (e != null) {
-                    Attributes a = (Attributes)e.get(getName());
+                    Attributes a = e.get(getName());
                     if (a != null)
                         return  (Attributes)a.clone();
                 }
--- a/jdk/src/share/classes/sun/nio/ch/Reflect.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/Reflect.java	Mon Mar 10 15:07:09 2008 -0700
@@ -43,8 +43,8 @@
     }
 
     private static void setAccessible(final AccessibleObject ao) {
-        AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                public Void run() {
                     ao.setAccessible(true);
                     return null;
                 }});
@@ -54,7 +54,7 @@
                                          Class[] paramTypes)
     {
         try {
-            Class cl = Class.forName(className);
+            Class<?> cl = Class.forName(className);
             Constructor c = cl.getDeclaredConstructor(paramTypes);
             setAccessible(c);
             return c;
@@ -82,7 +82,7 @@
                                Class[] paramTypes)
     {
         try {
-            Class cl = Class.forName(className);
+            Class<?> cl = Class.forName(className);
             Method m = cl.getDeclaredMethod(methodName, paramTypes);
             setAccessible(m);
             return m;
--- a/jdk/src/share/classes/sun/nio/ch/SocketAdaptor.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/SocketAdaptor.java	Mon Mar 10 15:07:09 2008 -0700
@@ -242,9 +242,9 @@
             throw new SocketException("Socket input is shutdown");
         if (socketInputStream == null) {
             try {
-                socketInputStream = (InputStream)AccessController.doPrivileged(
-                    new PrivilegedExceptionAction() {
-                        public Object run() throws IOException {
+                socketInputStream = AccessController.doPrivileged(
+                    new PrivilegedExceptionAction<InputStream>() {
+                        public InputStream run() throws IOException {
                             return new SocketInputStream();
                         }
                     });
@@ -264,9 +264,9 @@
             throw new SocketException("Socket output is shutdown");
         OutputStream os = null;
         try {
-            os = (OutputStream)
-                AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                    public Object run() throws IOException {
+            os = AccessController.doPrivileged(
+                new PrivilegedExceptionAction<OutputStream>() {
+                    public OutputStream run() throws IOException {
                         return Channels.newOutputStream(sc);
                     }
                 });
--- a/jdk/src/share/classes/sun/nio/ch/Util.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/Util.java	Mon Mar 10 15:07:09 2008 -0700
@@ -49,20 +49,21 @@
     private static final int TEMP_BUF_POOL_SIZE = 3;
 
     // Per-thread soft cache of the last temporary direct buffer
-    private static ThreadLocal[] bufferPool;
+    private static ThreadLocal<SoftReference<ByteBuffer>>[] bufferPool;
 
     static {
-        bufferPool = new ThreadLocal[TEMP_BUF_POOL_SIZE];
+        bufferPool = (ThreadLocal<SoftReference<ByteBuffer>>[])
+            new ThreadLocal[TEMP_BUF_POOL_SIZE];
         for (int i=0; i<TEMP_BUF_POOL_SIZE; i++)
-            bufferPool[i] = new ThreadLocal();
+            bufferPool[i] = new ThreadLocal<SoftReference<ByteBuffer>>();
     }
 
     static ByteBuffer getTemporaryDirectBuffer(int size) {
         ByteBuffer buf = null;
         // Grab a buffer if available
         for (int i=0; i<TEMP_BUF_POOL_SIZE; i++) {
-            SoftReference ref = (SoftReference)(bufferPool[i].get());
-            if ((ref != null) && ((buf = (ByteBuffer)ref.get()) != null) &&
+            SoftReference<ByteBuffer> ref = bufferPool[i].get();
+            if ((ref != null) && ((buf = ref.get()) != null) &&
                 (buf.capacity() >= size)) {
                 buf.rewind();
                 buf.limit(size);
@@ -80,18 +81,18 @@
             return;
         // Put it in an empty slot if such exists
         for (int i=0; i<TEMP_BUF_POOL_SIZE; i++) {
-            SoftReference ref = (SoftReference)(bufferPool[i].get());
+            SoftReference<ByteBuffer> ref = bufferPool[i].get();
             if ((ref == null) || (ref.get() == null)) {
-                bufferPool[i].set(new SoftReference(buf));
+                bufferPool[i].set(new SoftReference<ByteBuffer>(buf));
                 return;
             }
         }
         // Otherwise replace a smaller one in the cache if such exists
         for (int i=0; i<TEMP_BUF_POOL_SIZE; i++) {
-            SoftReference ref = (SoftReference)(bufferPool[i].get());
-            ByteBuffer inCacheBuf = (ByteBuffer)ref.get();
+            SoftReference<ByteBuffer> ref = bufferPool[i].get();
+            ByteBuffer inCacheBuf = ref.get();
             if ((inCacheBuf == null) || (buf.capacity() > inCacheBuf.capacity())) {
-                bufferPool[i].set(new SoftReference(buf));
+                bufferPool[i].set(new SoftReference<ByteBuffer>(buf));
                 return;
             }
         }
@@ -120,10 +121,12 @@
     }
 
     // Per-thread cached selector
-    private static ThreadLocal localSelector = new ThreadLocal();
+    private static ThreadLocal<SoftReference<SelectorWrapper>> localSelector
+        = new ThreadLocal<SoftReference<SelectorWrapper>>();
     // Hold a reference to the selWrapper object to prevent it from
     // being cleaned when the temporary selector wrapped is on lease.
-    private static ThreadLocal localSelectorWrapper = new ThreadLocal();
+    private static ThreadLocal<SelectorWrapper> localSelectorWrapper
+        = new ThreadLocal<SelectorWrapper>();
 
     // When finished, invoker must ensure that selector is empty
     // by cancelling any related keys and explicitly releasing
@@ -131,15 +134,16 @@
     static Selector getTemporarySelector(SelectableChannel sc)
         throws IOException
     {
-        SoftReference ref = (SoftReference)localSelector.get();
+        SoftReference<SelectorWrapper> ref = localSelector.get();
         SelectorWrapper selWrapper = null;
         Selector sel = null;
         if (ref == null
-            || ((selWrapper = (SelectorWrapper) ref.get()) == null)
+            || ((selWrapper = ref.get()) == null)
             || ((sel = selWrapper.get()) == null)
             || (sel.provider() != sc.provider())) {
             sel = sc.provider().openSelector();
-            localSelector.set(new SoftReference(new SelectorWrapper(sel)));
+            localSelector.set(new SoftReference<SelectorWrapper>(
+                                  new SelectorWrapper(sel)));
         } else {
             localSelectorWrapper.set(selWrapper);
         }
@@ -235,10 +239,10 @@
     private static volatile Constructor directByteBufferConstructor = null;
 
     private static void initDBBConstructor() {
-        AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                public Void run() {
                     try {
-                        Class cl = Class.forName("java.nio.DirectByteBuffer");
+                        Class<?> cl = Class.forName("java.nio.DirectByteBuffer");
                         Constructor ctor = cl.getDeclaredConstructor(
                             new Class[] { int.class,
                                           long.class,
@@ -282,10 +286,10 @@
     private static volatile Constructor directByteBufferRConstructor = null;
 
     private static void initDBBRConstructor() {
-        AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                public Void run() {
                     try {
-                        Class cl = Class.forName("java.nio.DirectByteBufferR");
+                        Class<?> cl = Class.forName("java.nio.DirectByteBufferR");
                         Constructor ctor = cl.getDeclaredConstructor(
                             new Class[] { int.class,
                                           long.class,
--- a/jdk/src/share/classes/sun/reflect/ClassDefiner.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/reflect/ClassDefiner.java	Mon Mar 10 15:07:09 2008 -0700
@@ -54,9 +54,9 @@
     static Class defineClass(String name, byte[] bytes, int off, int len,
                              final ClassLoader parentClassLoader)
     {
-        ClassLoader newLoader = (ClassLoader)
-            AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
+        ClassLoader newLoader = AccessController.doPrivileged(
+            new PrivilegedAction<ClassLoader>() {
+                public ClassLoader run() {
                         return new DelegatingClassLoader(parentClassLoader);
                     }
                 });
--- a/jdk/src/share/classes/sun/reflect/MethodAccessorGenerator.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/reflect/MethodAccessorGenerator.java	Mon Mar 10 15:07:09 2008 -0700
@@ -392,11 +392,12 @@
         // same namespace as the target class. Since the generated code
         // is privileged anyway, the protection domain probably doesn't
         // matter.
-        return (MagicAccessorImpl)
-            AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
+        return AccessController.doPrivileged(
+            new PrivilegedAction<MagicAccessorImpl>() {
+                public MagicAccessorImpl run() {
                         try {
-                            return ClassDefiner.defineClass
+                        return (MagicAccessorImpl)
+                        ClassDefiner.defineClass
                                 (generatedName,
                                  bytes,
                                  0,
--- a/jdk/src/share/classes/sun/reflect/ReflectionFactory.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/reflect/ReflectionFactory.java	Mon Mar 10 15:07:09 2008 -0700
@@ -84,8 +84,8 @@
      * <code>AccessController.doPrivileged</code>.
      */
     public static final class GetReflectionFactoryAction
-        implements PrivilegedAction {
-        public Object run() {
+        implements PrivilegedAction<ReflectionFactory> {
+        public ReflectionFactory run() {
             return getReflectionFactory();
         }
     }
@@ -164,7 +164,7 @@
     public ConstructorAccessor newConstructorAccessor(Constructor c) {
         checkInitted();
 
-        Class declaringClass = c.getDeclaringClass();
+        Class<?> declaringClass = c.getDeclaringClass();
         if (Modifier.isAbstract(declaringClass.getModifiers())) {
             return new InstantiationExceptionConstructorAccessorImpl(null);
         }
@@ -204,9 +204,9 @@
 
     /** Creates a new java.lang.reflect.Field. Access checks as per
         java.lang.reflect.AccessibleObject are not overridden. */
-    public Field newField(Class declaringClass,
+    public Field newField(Class<?> declaringClass,
                           String name,
-                          Class type,
+                          Class<?> type,
                           int modifiers,
                           int slot,
                           String signature,
@@ -223,11 +223,11 @@
 
     /** Creates a new java.lang.reflect.Method. Access checks as per
         java.lang.reflect.AccessibleObject are not overridden. */
-    public Method newMethod(Class declaringClass,
+    public Method newMethod(Class<?> declaringClass,
                             String name,
-                            Class[] parameterTypes,
-                            Class returnType,
-                            Class[] checkedExceptions,
+                            Class<?>[] parameterTypes,
+                            Class<?> returnType,
+                            Class<?>[] checkedExceptions,
                             int modifiers,
                             int slot,
                             String signature,
@@ -250,9 +250,9 @@
 
     /** Creates a new java.lang.reflect.Constructor. Access checks as
         per java.lang.reflect.AccessibleObject are not overridden. */
-    public Constructor newConstructor(Class declaringClass,
-                                      Class[] parameterTypes,
-                                      Class[] checkedExceptions,
+    public Constructor newConstructor(Class<?> declaringClass,
+                                      Class<?>[] parameterTypes,
+                                      Class<?>[] checkedExceptions,
                                       int modifiers,
                                       int slot,
                                       String signature,
@@ -310,7 +310,7 @@
     /** Makes a copy of the passed constructor. The returned
         constructor is a "child" of the passed one; see the comments
         in Constructor.java for details. */
-    public Constructor copyConstructor(Constructor arg) {
+    public <T> Constructor<T> copyConstructor(Constructor<T> arg) {
         return langReflectAccess().copyConstructor(arg);
     }
 
@@ -321,7 +321,7 @@
     //
 
     public Constructor newConstructorForSerialization
-        (Class classToInstantiate, Constructor constructorToCall)
+        (Class<?> classToInstantiate, Constructor constructorToCall)
     {
         // Fast path
         if (constructorToCall.getDeclaringClass() == classToInstantiate) {
@@ -366,8 +366,9 @@
         run, before the system properties are set up. */
     private static void checkInitted() {
         if (initted) return;
-        AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+        AccessController.doPrivileged(
+            new PrivilegedAction<Void>() {
+                public Void run() {
                     // Tests to ensure the system properties table is fully
                     // initialized. This is needed because reflection code is
                     // called very early in the initialization process (before
--- a/jdk/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java	Mon Mar 10 15:07:09 2008 -0700
@@ -273,8 +273,8 @@
     private Method[] getMemberMethods() {
         if (memberMethods == null) {
             final Method[] mm = type.getDeclaredMethods();
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+            AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                public Void run() {
                     AccessibleObject.setAccessible(mm, true);
                     return null;
                 }
--- a/jdk/src/share/classes/sun/reflect/misc/MethodUtil.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/reflect/misc/MethodUtil.java	Mon Mar 10 15:07:09 2008 -0700
@@ -67,7 +67,7 @@
         super();
     }
 
-    public static Method getMethod(Class cls, String name, Class[] args)
+    public static Method getMethod(Class<?> cls, String name, Class[] args)
         throws NoSuchMethodException {
         ReflectUtil.checkPackageAccess(cls);
         return cls.getMethod(name, args);
@@ -89,7 +89,7 @@
         if (System.getSecurityManager() == null) {
             return cls.getMethods();
         }
-        Map sigs = new HashMap();
+        Map<Signature, Method> sigs = new HashMap<Signature, Method>();
         while (cls != null) {
             boolean done = getInternalPublicMethods(cls, sigs);
             if (done) {
@@ -98,14 +98,14 @@
             getInterfaceMethods(cls, sigs);
             cls = cls.getSuperclass();
         }
-        Collection c = sigs.values();
-        return (Method[]) c.toArray(new Method[c.size()]);
+        return sigs.values().toArray(new Method[sigs.size()]);
     }
 
     /*
      * Process the immediate interfaces of this class or interface.
      */
-    private static void getInterfaceMethods(Class cls, Map sigs) {
+    private static void getInterfaceMethods(Class cls,
+                                            Map<Signature, Method> sigs) {
         Class[] intfs = cls.getInterfaces();
         for (int i=0; i < intfs.length; i++) {
             Class intf = intfs[i];
@@ -120,7 +120,8 @@
      *
      * Process the methods in this class or interface
      */
-    private static boolean getInternalPublicMethods(Class cls, Map sigs) {
+    private static boolean getInternalPublicMethods(Class cls,
+                                                    Map<Signature, Method> sigs) {
         Method[] methods = null;
         try {
             /*
@@ -178,7 +179,7 @@
         return done;
     }
 
-    private static void addMethod(Map sigs, Method method) {
+    private static void addMethod(Map<Signature, Method> sigs, Method method) {
         Signature signature = new Signature(method);
         if (!sigs.containsKey(signature)) {
             sigs.put(signature, method);
@@ -186,7 +187,7 @@
             /*
              * Superclasses beat interfaces.
              */
-            Method old = (Method)sigs.get(signature);
+            Method old = sigs.get(signature);
             if (old.getDeclaringClass().isInterface()) {
                 sigs.put(signature, method);
             }
@@ -280,17 +281,15 @@
     }
 
     private static Method getTrampoline() {
-        Method tramp = null;
-
         try {
-            tramp = (Method) AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                public Object run() throws Exception {
-                    Class[] types;
-                    Class t = getTrampolineClass();
-                    Method b;
-
-                    types = new Class[] {Method.class, Object.class, Object[].class};
-                    b = t.getDeclaredMethod("invoke", types);
+            return AccessController.doPrivileged(
+                new PrivilegedExceptionAction<Method>() {
+                    public Method run() throws Exception {
+                        Class<?> t = getTrampolineClass();
+                        Class[] types = {
+                            Method.class, Object.class, Object[].class
+                        };
+                        Method b = t.getDeclaredMethod("invoke", types);
                     ((AccessibleObject)b).setAccessible(true);
                     return b;
                 }
@@ -298,7 +297,6 @@
         } catch (Exception e) {
             throw new InternalError("bouncer cannot be found");
         }
-        return tramp;
     }
 
 
--- a/jdk/src/share/classes/sun/rmi/log/ReliableLog.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/log/ReliableLog.java	Mon Mar 10 15:07:09 2008 -0700
@@ -140,8 +140,8 @@
         throws IOException
     {
         super();
-        this.Debug = ((Boolean) AccessController.doPrivileged(
-            new GetBooleanAction("sun.rmi.log.debug"))).booleanValue();
+        this.Debug = AccessController.doPrivileged(
+            new GetBooleanAction("sun.rmi.log.debug")).booleanValue();
         dir = new File(dirPath);
         if (!(dir.exists() && dir.isDirectory())) {
             // create directory
@@ -333,8 +333,8 @@
     private static Constructor<? extends LogFile>
         getLogClassConstructor() {
 
-        String logClassName =  ((String) AccessController.doPrivileged(
-            new GetPropertyAction("sun.rmi.log.class")));
+        String logClassName = AccessController.doPrivileged(
+            new GetPropertyAction("sun.rmi.log.class"));
         if (logClassName != null) {
             try {
                 ClassLoader loader =
--- a/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -66,8 +66,10 @@
 
     /* indicate compatibility with JDK 1.1.x version of class */
     private static final long serialVersionUID = 4666870661827494597L;
-    private Hashtable bindings = new Hashtable(101);
-    private static Hashtable allowedAccessCache = new Hashtable(3);
+    private Hashtable<String, Remote> bindings
+        = new Hashtable<String, Remote>(101);
+    private static Hashtable<InetAddress, InetAddress> allowedAccessCache
+        = new Hashtable<InetAddress, InetAddress>(3);
     private static RegistryImpl registry;
     private static ObjID id = new ObjID(ObjID.REGISTRY_ID);
 
@@ -119,7 +121,7 @@
         throws RemoteException, NotBoundException
     {
         synchronized (bindings) {
-            Remote obj = (Remote)bindings.get(name);
+            Remote obj = bindings.get(name);
             if (obj == null)
                 throw new NotBoundException(name);
             return obj;
@@ -136,7 +138,7 @@
     {
         checkAccess("Registry.bind");
         synchronized (bindings) {
-            Remote curr = (Remote)bindings.get(name);
+            Remote curr = bindings.get(name);
             if (curr != null)
                 throw new AlreadyBoundException(name);
             bindings.put(name, obj);
@@ -153,7 +155,7 @@
     {
         checkAccess("Registry.unbind");
         synchronized (bindings) {
-            Remote obj = (Remote)bindings.get(name);
+            Remote obj = bindings.get(name);
             if (obj == null)
                 throw new NotBoundException(name);
             bindings.remove(name);
@@ -203,10 +205,9 @@
             InetAddress clientHost;
 
             try {
-                clientHost = (InetAddress)
-                    java.security.AccessController.doPrivileged(
-                        new java.security.PrivilegedExceptionAction() {
-                        public Object run()
+                clientHost = java.security.AccessController.doPrivileged(
+                    new java.security.PrivilegedExceptionAction<InetAddress>() {
+                        public InetAddress run()
                             throws java.net.UnknownHostException
                         {
                             return InetAddress.getByName(clientHostName);
@@ -228,8 +229,8 @@
                     final InetAddress finalClientHost = clientHost;
 
                     java.security.AccessController.doPrivileged(
-                        new java.security.PrivilegedExceptionAction() {
-                            public Object run() throws java.io.IOException {
+                        new java.security.PrivilegedExceptionAction<Void>() {
+                            public Void run() throws java.io.IOException {
                                 /*
                                  * if a ServerSocket can be bound to the client's
                                  * address then that address must be local
--- a/jdk/src/share/classes/sun/rmi/rmic/RemoteClass.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/rmic/RemoteClass.java	Mon Mar 10 15:07:09 2008 -0700
@@ -103,7 +103,7 @@
      * in the array).
      */
     public ClassDefinition[] getRemoteInterfaces() {
-        return (ClassDefinition[]) remoteInterfaces.clone();
+        return remoteInterfaces.clone();
     }
 
     /**
@@ -118,7 +118,7 @@
      * stub/skeleton protocol.
      */
     public Method[] getRemoteMethods() {
-        return (Method[]) remoteMethods.clone();
+        return remoteMethods.clone();
     }
 
     /**
@@ -204,8 +204,8 @@
          * chain, add each directly-implemented interface that
          * somehow extends Remote to a list.
          */
-        Vector remotesImplemented =     // list of remote interfaces found
-            new Vector();
+        Vector<ClassDefinition> remotesImplemented = // list of remote interfaces found
+            new Vector<ClassDefinition>();
         for (ClassDefinition classDef = implClassDef;
              classDef != null;)
             {
@@ -307,13 +307,13 @@
          * Now we collect the methods from all of the remote interfaces
          * into a hashtable.
          */
-        Hashtable methods = new Hashtable();
+        Hashtable<String, Method> methods = new Hashtable<String, Method>();
         boolean errors = false;
-        for (Enumeration enumeration = remotesImplemented.elements();
+        for (Enumeration<ClassDefinition> enumeration
+                 = remotesImplemented.elements();
              enumeration.hasMoreElements();)
             {
-                ClassDefinition interfaceDef =
-                    (ClassDefinition) enumeration.nextElement();
+                ClassDefinition interfaceDef = enumeration.nextElement();
                 if (!collectRemoteMethods(interfaceDef, methods))
                     errors = true;
             }
@@ -336,10 +336,10 @@
          */
         String[] orderedKeys = new String[methods.size()];
         int count = 0;
-        for (Enumeration enumeration = methods.elements();
+        for (Enumeration<Method> enumeration = methods.elements();
              enumeration.hasMoreElements();)
             {
-                Method m = (Method) enumeration.nextElement();
+                Method m = enumeration.nextElement();
                 String key = m.getNameAndDescriptor();
                 int i;
                 for (i = count; i > 0; --i) {
@@ -353,7 +353,7 @@
             }
         remoteMethods = new Method[methods.size()];
         for (int i = 0; i < remoteMethods.length; i++) {
-            remoteMethods[i] = (Method) methods.get(orderedKeys[i]);
+            remoteMethods[i] = methods.get(orderedKeys[i]);
             /***** <DEBUG> */
             if (env.verbose()) {
                 System.out.print("[found remote method <" + i + ">: " +
@@ -388,7 +388,7 @@
      * or false if an error occurred.
      */
     private boolean collectRemoteMethods(ClassDefinition interfaceDef,
-                                         Hashtable table)
+                                         Hashtable<String, Method> table)
     {
         if (!interfaceDef.isInterface()) {
             throw new Error(
@@ -529,7 +529,7 @@
                          * the new method (see bugid 4070653).
                          */
                         String key = newMethod.getNameAndDescriptor();
-                        Method oldMethod = (Method) table.get(key);
+                        Method oldMethod = table.get(key);
                         if (oldMethod != null) {
                             newMethod = newMethod.mergeWith(oldMethod);
                             if (newMethod == null) {
@@ -684,7 +684,7 @@
          * methods that can be legally thrown in each of them.
          */
         public ClassDeclaration[] getExceptions() {
-            return (ClassDeclaration[]) exceptions.clone();
+            return exceptions.clone();
         }
 
         /**
@@ -789,7 +789,8 @@
                                     getNameAndDescriptor());
                 }
 
-            Vector legalExceptions = new Vector();
+            Vector<ClassDeclaration> legalExceptions
+                = new Vector<ClassDeclaration>();
             try {
                 collectCompatibleExceptions(
                                             other.exceptions, exceptions, legalExceptions);
@@ -814,7 +815,7 @@
          */
         private void collectCompatibleExceptions(ClassDeclaration[] from,
                                                  ClassDeclaration[] with,
-                                                 Vector list)
+                                                 Vector<ClassDeclaration> list)
             throws ClassNotFound
         {
             for (int i = 0; i < from.length; i++) {
--- a/jdk/src/share/classes/sun/rmi/rmic/newrmic/jrmp/RemoteClass.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/rmic/newrmic/jrmp/RemoteClass.java	Mon Mar 10 15:07:09 2008 -0700
@@ -121,7 +121,7 @@
      * in the array).
      **/
     ClassDoc[] remoteInterfaces() {
-        return (ClassDoc[]) remoteInterfaces.clone();
+        return remoteInterfaces.clone();
     }
 
     /**
@@ -136,7 +136,7 @@
      * stub/skeleton protocol.
      **/
     Method[] remoteMethods() {
-        return (Method[]) remoteMethods.clone();
+        return remoteMethods.clone();
     }
 
     /**
@@ -559,7 +559,7 @@
          * methods that can be legally thrown by all of them.
          **/
         ClassDoc[] exceptionTypes() {
-            return (ClassDoc[]) exceptionTypes.clone();
+            return exceptionTypes.clone();
         }
 
         /**
--- a/jdk/src/share/classes/sun/rmi/runtime/Log.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/runtime/Log.java	Mon Mar 10 15:07:09 2008 -0700
@@ -71,7 +71,7 @@
     private static final LogFactory logFactory;
     static {
         boolean useOld =
-            Boolean.valueOf((String) java.security.AccessController.
+            Boolean.valueOf(java.security.AccessController.
                 doPrivileged(new sun.security.action.GetPropertyAction(
                     "sun.rmi.log.useOld"))).booleanValue();
 
@@ -179,17 +179,16 @@
     private static class LoggerLog extends Log {
 
         /* alternate console handler for RMI loggers */
-        private static final Handler alternateConsole = (Handler)
+        private static final Handler alternateConsole =
                 java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedAction() {
-                        public Object run() {
+                new java.security.PrivilegedAction<Handler>() {
+                    public Handler run() {
                             InternalStreamHandler alternate =
                                 new InternalStreamHandler(System.err);
                             alternate.setLevel(Level.ALL);
                             return alternate;
                         }
-                    }
-                );
+                });
 
         /** handler to which messages are copied */
         private InternalStreamHandler copyHandler = null;
@@ -206,8 +205,8 @@
 
             if (level != null){
                 java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedAction() {
-                        public Object run() {
+                    new java.security.PrivilegedAction<Void>() {
+                        public Void run() {
                             if (!logger.isLoggable(level)) {
                                 logger.setLevel(level);
                             }
--- a/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java	Mon Mar 10 15:07:09 2008 -0700
@@ -70,7 +70,7 @@
 
     /** RMI class loader log level */
     static final int logLevel = LogStream.parseLevel(
-        (String) java.security.AccessController.doPrivileged(
+        java.security.AccessController.doPrivileged(
             new GetPropertyAction("sun.rmi.loader.logLevel")));
 
     /* loader system log */
@@ -83,7 +83,7 @@
      */
     private static String codebaseProperty = null;
     static {
-        String prop = (String) java.security.AccessController.doPrivileged(
+        String prop = java.security.AccessController.doPrivileged(
             new GetPropertyAction("java.rmi.server.codebase"));
         if (prop != null && prop.trim().length() > 0) {
             codebaseProperty = prop;
@@ -94,8 +94,8 @@
     private static URL[] codebaseURLs = null;
 
     /** table of class loaders that use codebase property for annotation */
-    private static final Map codebaseLoaders =
-        Collections.synchronizedMap(new IdentityHashMap(5));
+    private static final Map<ClassLoader, Void> codebaseLoaders =
+        Collections.synchronizedMap(new IdentityHashMap<ClassLoader, Void>(5));
     static {
         for (ClassLoader codebaseLoader = ClassLoader.getSystemClassLoader();
              codebaseLoader != null;
@@ -111,10 +111,12 @@
      * references, so this table does not prevent loaders from being
      * garbage collected.
      */
-    private static final HashMap loaderTable = new HashMap(5);
+    private static final HashMap<LoaderKey, LoaderEntry> loaderTable
+        = new HashMap<LoaderKey, LoaderEntry>(5);
 
     /** reference queue for cleared class loader entries */
-    private static final ReferenceQueue refQueue = new ReferenceQueue();
+    private static final ReferenceQueue<Loader> refQueue
+        = new ReferenceQueue<Loader>();
 
     /*
      * Disallow anyone from creating one of these.
@@ -757,7 +759,7 @@
         throws MalformedURLException
     {
         synchronized (pathToURLsCache) {
-            Object[] v = (Object[]) pathToURLsCache.get(path);
+            Object[] v = pathToURLsCache.get(path);
             if (v != null) {
                 return ((URL[])v[0]);
             }
@@ -769,13 +771,14 @@
         }
         synchronized (pathToURLsCache) {
             pathToURLsCache.put(path,
-                                new Object[] {urls, new SoftReference(path)});
+                                new Object[] {urls, new SoftReference<String>(path)});
         }
         return urls;
     }
 
     /** map from weak(key=string) to [URL[], soft(key)] */
-    private static final Map pathToURLsCache = new WeakHashMap(5);
+    private static final Map<String, Object[]> pathToURLsCache
+        = new WeakHashMap<String, Object[]>(5);
 
     /**
      * Convert an array of URL objects into a corresponding string
@@ -853,9 +856,9 @@
              * in the table of RMI class loaders.
              */
             LoaderKey key = new LoaderKey(urls, parent);
-            entry = (LoaderEntry) loaderTable.get(key);
+            entry = loaderTable.get(key);
 
-            if (entry == null || (loader = (Loader) entry.get()) == null) {
+            if (entry == null || (loader = entry.get()) == null) {
                 /*
                  * If entry was in table but it's weak reference was cleared,
                  * remove it from the table and mark it as explicitly cleared,
@@ -876,9 +879,9 @@
                  * necessary to load classes from its codebase URL path.
                  */
                 AccessControlContext acc = getLoaderAccessControlContext(urls);
-                loader = (Loader) java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedAction() {
-                        public Object run() {
+                loader = java.security.AccessController.doPrivileged(
+                    new java.security.PrivilegedAction<Loader>() {
+                        public Loader run() {
                             return new Loader(urls, parent);
                         }
                     }, acc);
@@ -954,7 +957,7 @@
      * loader key for the loader so that the mapping can be removed from
      * the table efficiently when the weak reference is cleared.
      */
-    private static class LoaderEntry extends WeakReference {
+    private static class LoaderEntry extends WeakReference<Loader> {
 
         public LoaderKey key;
 
@@ -983,10 +986,10 @@
          * getAccessControlContext() in the sun.applet.AppletPanel class.
          */
         // begin with permissions granted to all code in current policy
-        PermissionCollection perms = (PermissionCollection)
+        PermissionCollection perms =
             java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction() {
-                public Object run() {
+                new java.security.PrivilegedAction<PermissionCollection>() {
+                public PermissionCollection run() {
                     CodeSource codesource = new CodeSource(null,
                         (java.security.cert.Certificate[]) null);
                     Policy p = java.security.Policy.getPolicy();
--- a/jdk/src/share/classes/sun/rmi/server/MarshalInputStream.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/server/MarshalInputStream.java	Mon Mar 10 15:07:09 2008 -0700
@@ -59,18 +59,20 @@
      * as cached at class initialization time.
      */
     private static final boolean useCodebaseOnlyProperty =
-        ((Boolean) java.security.AccessController.doPrivileged(
+        java.security.AccessController.doPrivileged(
             new sun.security.action.GetBooleanAction(
-                "java.rmi.server.useCodebaseOnly"))).booleanValue();
+                "java.rmi.server.useCodebaseOnly")).booleanValue();
 
     /** table to hold sun classes to which access is explicitly permitted */
-    protected static Map permittedSunClasses = new HashMap(3);
+    protected static Map<String, Class<?>> permittedSunClasses
+        = new HashMap<String, Class<?>>(3);
 
     /** if true, don't try superclass first in resolveClass() */
     private boolean skipDefaultResolveClass = false;
 
     /** callbacks to make when done() called: maps Object to Runnable */
-    private final Map doneCallbacks = new HashMap(3);
+    private final Map<Object, Runnable> doneCallbacks
+        = new HashMap<Object, Runnable>(3);
 
     /**
      * if true, load classes (if not available locally) only from the
@@ -130,7 +132,7 @@
      * with that key.
      */
     public Runnable getDoneCallback(Object key) {
-        return (Runnable) doneCallbacks.get(key);       // not thread-safe
+        return doneCallbacks.get(key);                 // not thread-safe
     }
 
     /**
@@ -153,9 +155,9 @@
      * the superclass's close method.
      */
     public void done() {
-        Iterator iter = doneCallbacks.values().iterator();
+        Iterator<Runnable> iter = doneCallbacks.values().iterator();
         while (iter.hasNext()) {                        // not thread-safe
-            Runnable callback = (Runnable) iter.next();
+            Runnable callback = iter.next();
             callback.run();
         }
         doneCallbacks.clear();
@@ -276,8 +278,7 @@
             name = perm.getName();
         }
 
-        Class resolvedClass =
-            (Class) permittedSunClasses.get(className);
+        Class<?> resolvedClass = permittedSunClasses.get(className);
 
         // if class not permitted, throw the SecurityException
         if ((name == null) ||
--- a/jdk/src/share/classes/sun/rmi/server/MarshalOutputStream.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/server/MarshalOutputStream.java	Mon Mar 10 15:07:09 2008 -0700
@@ -64,8 +64,8 @@
         super(out);
         this.useProtocolVersion(protocolVersion);
         java.security.AccessController.doPrivileged(
-                                    new java.security.PrivilegedAction() {
-            public Object run() {
+            new java.security.PrivilegedAction<Void>() {
+                public Void run() {
                 enableReplaceObject(true);
                 return null;
             }
--- a/jdk/src/share/classes/sun/rmi/server/Util.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/server/Util.java	Mon Mar 10 15:07:09 2008 -0700
@@ -67,7 +67,7 @@
 
     /** "server" package log level */
     static final int logLevel = LogStream.parseLevel(
-        (String) AccessController.doPrivileged(
+        AccessController.doPrivileged(
             new GetPropertyAction("sun.rmi.server.logLevel")));
 
     /** server reference log */
@@ -76,13 +76,13 @@
 
     /** cached value of property java.rmi.server.ignoreStubClasses */
     private static final boolean ignoreStubClasses =
-        ((Boolean) AccessController.doPrivileged(
-            new GetBooleanAction("java.rmi.server.ignoreStubClasses"))).
+        AccessController.doPrivileged(
+            new GetBooleanAction("java.rmi.server.ignoreStubClasses")).
             booleanValue();
 
     /** cache of  impl classes that have no corresponding stub class */
-    private static final Map withoutStubs =
-        Collections.synchronizedMap(new WeakHashMap(11));
+    private static final Map<Class<?>, Void> withoutStubs =
+        Collections.synchronizedMap(new WeakHashMap<Class<?>, Void>(11));
 
     /** parameter types for stub constructor */
     private static final Class[] stubConsParamTypes = { RemoteRef.class };
@@ -207,9 +207,9 @@
      * @throws  NullPointerException if remoteClass is null
      */
     private static Class[] getRemoteInterfaces(Class remoteClass) {
-        ArrayList list = new ArrayList();
+        ArrayList<Class<?>> list = new ArrayList<Class<?>>();
         getRemoteInterfaces(list, remoteClass);
-        return (Class []) list.toArray(new Class[list.size()]);
+        return list.toArray(new Class<?>[list.size()]);
     }
 
     /**
@@ -220,7 +220,7 @@
      *          any illegal remote interfaces
      * @throws  NullPointerException if the specified class or list is null
      */
-    private static void getRemoteInterfaces(ArrayList list, Class cl) {
+    private static void getRemoteInterfaces(ArrayList<Class<?>> list, Class cl) {
         Class superclass = cl.getSuperclass();
         if (superclass != null) {
             getRemoteInterfaces(list, superclass);
@@ -254,7 +254,7 @@
      * @throws IllegalArgumentException if m is an illegal remote method
      */
     private static void checkMethod(Method m) {
-        Class[] ex = m.getExceptionTypes();
+        Class<?>[] ex = m.getExceptionTypes();
         for (int i = 0; i < ex.length; i++) {
             if (ex[i].isAssignableFrom(RemoteException.class))
                 return;
@@ -283,7 +283,7 @@
          * pickle methods
          */
         try {
-            Class stubcl =
+            Class<?> stubcl =
                 Class.forName(stubname, false, remoteClass.getClassLoader());
             Constructor cons = stubcl.getConstructor(stubConsParamTypes);
             return (RemoteStub) cons.newInstance(new Object[] { ref });
--- a/jdk/src/share/classes/sun/rmi/server/WeakClassHashMap.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/server/WeakClassHashMap.java	Mon Mar 10 15:07:09 2008 -0700
@@ -69,7 +69,7 @@
         synchronized (valueCell) {
             V value = null;
             if (valueCell.ref != null) {
-                value = (V) valueCell.ref.get();
+                value = valueCell.ref.get();
             }
             if (value == null) {
                 value = computeValue(remoteClass);
--- a/jdk/src/share/classes/sun/rmi/transport/DGCClient.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/transport/DGCClient.java	Mon Mar 10 15:07:09 2008 -0700
@@ -85,21 +85,21 @@
 
     /** lease duration to request (usually ignored by server) */
     private static final long leaseValue =              // default 10 minutes
-        ((Long) AccessController.doPrivileged(
+        AccessController.doPrivileged(
             new GetLongAction("java.rmi.dgc.leaseValue",
-                              600000))).longValue();
+                              600000)).longValue();
 
     /** maximum interval between retries of failed clean calls */
     private static final long cleanInterval =           // default 3 minutes
-        ((Long) AccessController.doPrivileged(
+        AccessController.doPrivileged(
             new GetLongAction("sun.rmi.dgc.cleanInterval",
-                              180000))).longValue();
+                              180000)).longValue();
 
     /** maximum interval between complete garbage collections of local heap */
     private static final long gcInterval =              // default 1 hour
-        ((Long) AccessController.doPrivileged(
+        AccessController.doPrivileged(
             new GetLongAction("sun.rmi.dgc.client.gcInterval",
-                              3600000))).longValue();
+                              3600000)).longValue();
 
     /** minimum retry count for dirty calls that fail */
     private static final int dirtyFailureRetries = 5;
@@ -243,7 +243,7 @@
             } catch (RemoteException e) {
                 throw new Error("internal error creating DGC stub");
             }
-            renewCleanThread = (Thread) AccessController.doPrivileged(
+            renewCleanThread =  AccessController.doPrivileged(
                 new NewThreadAction(new RenewCleanThread(),
                                     "RenewClean-" + endpoint, true));
             renewCleanThread.start();
@@ -473,8 +473,9 @@
             if (newRenewTime < renewTime) {
                 renewTime = newRenewTime;
                 if (interruptible) {
-                    AccessController.doPrivileged(new PrivilegedAction() {
-                        public Object run() {
+                    AccessController.doPrivileged(
+                        new PrivilegedAction<Void>() {
+                            public Void run() {
                             renewCleanThread.interrupt();
                             return null;
                         }
--- a/jdk/src/share/classes/sun/rmi/transport/Target.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/transport/Target.java	Mon Mar 10 15:07:09 2008 -0700
@@ -321,7 +321,7 @@
             Remote obj = getImpl();
             if (obj instanceof Unreferenced) {
                 final Unreferenced unrefObj = (Unreferenced) obj;
-                final Thread t = (Thread)
+                final Thread t =
                     java.security.AccessController.doPrivileged(
                         new NewThreadAction(new Runnable() {
                             public void run() {
@@ -334,8 +334,8 @@
                  * for threads that may invoke user code (see bugid 4171278).
                  */
                 java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedAction() {
-                    public Object run() {
+                    new java.security.PrivilegedAction<Void>() {
+                        public Void run() {
                         t.setContextClassLoader(ccl);
                         return null;
                     }
--- a/jdk/src/share/classes/sun/rmi/transport/Transport.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/transport/Transport.java	Mon Mar 10 15:07:09 2008 -0700
@@ -53,7 +53,7 @@
     static final int logLevel = LogStream.parseLevel(getLogLevel());
 
     private static String getLogLevel() {
-        return (String) java.security.AccessController.doPrivileged(
+        return java.security.AccessController.doPrivileged(
             new sun.security.action.GetPropertyAction("sun.rmi.transport.logLevel"));
     }
 
@@ -171,8 +171,8 @@
                     currentTransport.set(this);
                     try {
                         java.security.AccessController.doPrivileged(
-                                new java.security.PrivilegedExceptionAction() {
-                            public Object run() throws IOException {
+                            new java.security.PrivilegedExceptionAction<Void>() {
+                            public Void run() throws IOException {
                                 checkAcceptPermission(acc);
                                 disp.dispatch(impl, call);
                                 return null;
--- a/jdk/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java	Mon Mar 10 15:07:09 2008 -0700
@@ -89,8 +89,8 @@
 
     static {
         java.security.AccessController.doPrivileged(
-                            new java.security.PrivilegedAction() {
-            public Object run() {
+            new java.security.PrivilegedAction<Void>() {
+            public Void run() {
                 ContentLength =
                     Integer.getInteger("CONTENT_LENGTH", 0).intValue();
                 QueryString = System.getProperty("QUERY_STRING", "");
--- a/jdk/src/share/classes/sun/rmi/transport/proxy/HttpSendSocket.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/transport/proxy/HttpSendSocket.java	Mon Mar 10 15:07:09 2008 -0700
@@ -78,7 +78,7 @@
      * property at the moment that the socket was created.
      */
     private String lineSeparator =
-        (String) java.security.AccessController.doPrivileged(
+        java.security.AccessController.doPrivileged(
             new sun.security.action.GetPropertyAction("line.separator"));
 
     /**
--- a/jdk/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java	Mon Mar 10 15:07:09 2008 -0700
@@ -50,7 +50,7 @@
     static int logLevel = LogStream.parseLevel(getLogLevel());
 
     private static String getLogLevel() {
-        return (String) java.security.AccessController.doPrivileged(
+        return java.security.AccessController.doPrivileged(
             new sun.security.action.GetPropertyAction("sun.rmi.transport.proxy.logLevel"));
     }
 
@@ -63,15 +63,15 @@
     private static long connectTimeout = getConnectTimeout();
 
     private static long getConnectTimeout() {
-        return ((Long) java.security.AccessController.doPrivileged(
+        return java.security.AccessController.doPrivileged(
                 new GetLongAction("sun.rmi.transport.proxy.connectTimeout",
-                                  15000))).longValue(); // default: 15 seconds
+                              15000)).longValue(); // default: 15 seconds
     }
 
     /** whether to fallback to HTTP on general connect failures */
-    private static final boolean eagerHttpFallback = ((Boolean)
+    private static final boolean eagerHttpFallback =
         java.security.AccessController.doPrivileged(new GetBooleanAction(
-            "sun.rmi.transport.proxy.eagerHttpFallback"))).booleanValue();
+            "sun.rmi.transport.proxy.eagerHttpFallback")).booleanValue();
 
     /** table of hosts successfully connected to and the factory used */
     private Hashtable successTable = new Hashtable();
@@ -100,14 +100,14 @@
 
         try {
             String proxyHost;
-            proxyHost = (String) java.security.AccessController.doPrivileged(
+            proxyHost = java.security.AccessController.doPrivileged(
                 new sun.security.action.GetPropertyAction("http.proxyHost"));
 
             if (proxyHost == null)
-                proxyHost=(String)java.security.AccessController.doPrivileged(
+                proxyHost = java.security.AccessController.doPrivileged(
                     new sun.security.action.GetPropertyAction("proxyHost"));
 
-            Boolean tmp = (Boolean)java.security.AccessController.doPrivileged(
+            Boolean tmp = java.security.AccessController.doPrivileged(
                 new sun.security.action.GetBooleanAction("java.rmi.server.disableHttp"));
 
             if (!tmp.booleanValue() &&
@@ -178,10 +178,8 @@
         try {
             synchronized (connector) {
 
-                Thread t = (Thread)
-                    java.security.AccessController.doPrivileged(
-                        new NewThreadAction(connector, "AsyncConnector",
-                                            true));
+                Thread t = java.security.AccessController.doPrivileged(
+                    new NewThreadAction(connector, "AsyncConnector", true));
                 t.start();
 
                 try {
--- a/jdk/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java	Mon Mar 10 15:07:09 2008 -0700
@@ -49,7 +49,7 @@
     static int logLevel = LogStream.parseLevel(getLogLevel());
 
     private static String getLogLevel() {
-        return (String) java.security.AccessController.doPrivileged(
+        return java.security.AccessController.doPrivileged(
             new sun.security.action.GetPropertyAction("sun.rmi.transport.tcp.multiplex.logLevel"));
     }
 
--- a/jdk/src/share/classes/sun/security/jgss/GSSManagerImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/security/jgss/GSSManagerImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -83,7 +83,7 @@
     public Oid[] getNamesForMech(Oid mech)
         throws GSSException {
         MechanismFactory factory = list.getMechFactory(mech);
-        return (Oid[])factory.getNameTypes().clone();
+        return factory.getNameTypes().clone();
     }
 
     public Oid[] getMechsForName(Oid nameType){
--- a/jdk/src/share/classes/sun/security/jgss/krb5/InitSecContextToken.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/security/jgss/krb5/InitSecContextToken.java	Mon Mar 10 15:07:09 2008 -0700
@@ -103,8 +103,7 @@
         apReq = new KrbApReq(apReqBytes, keys, addr);
         //debug("\nReceived AP-REQ and authenticated it.\n");
 
-        EncryptionKey sessionKey
-            = (EncryptionKey) apReq.getCreds().getSessionKey();
+        EncryptionKey sessionKey = apReq.getCreds().getSessionKey();
 
         /*
           System.out.println("\n\nSession key from service ticket is: " +
--- a/jdk/src/share/classes/sun/security/ssl/CipherSuite.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/CipherSuite.java	Mon Mar 10 15:07:09 2008 -0700
@@ -191,7 +191,7 @@
         if (s == null) {
             throw new IllegalArgumentException("Name must not be null");
         }
-        CipherSuite c = (CipherSuite)nameMap.get(s);
+        CipherSuite c = nameMap.get(s);
         if ((c == null) || (c.allowed == false)) {
             throw new IllegalArgumentException("Unsupported ciphersuite " + s);
         }
@@ -395,7 +395,7 @@
         }
 
         private static synchronized boolean isAvailable(BulkCipher cipher) {
-            Boolean b = (Boolean)availableCache.get(cipher);
+            Boolean b = availableCache.get(cipher);
             if (b == null) {
                 try {
                     SecretKey key = new SecretKeySpec
--- a/jdk/src/share/classes/sun/security/ssl/DHCrypt.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/DHCrypt.java	Mon Mar 10 15:07:09 2008 -0700
@@ -132,8 +132,7 @@
         }
         try {
             KeyFactory factory = JsseJce.getKeyFactory("DH");
-            return (DHPublicKeySpec)factory.getKeySpec
-                                            (key, DHPublicKeySpec.class);
+            return factory.getKeySpec(key, DHPublicKeySpec.class);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
--- a/jdk/src/share/classes/sun/security/ssl/JsseJce.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/JsseJce.java	Mon Mar 10 15:07:09 2008 -0700
@@ -343,8 +343,7 @@
         }
         try {
             KeyFactory factory = JsseJce.getKeyFactory("RSA");
-            return (RSAPublicKeySpec)factory.getKeySpec
-                                                (key, RSAPublicKeySpec.class);
+            return factory.getKeySpec(key, RSAPublicKeySpec.class);
         } catch (Exception e) {
             throw (RuntimeException)new RuntimeException().initCause(e);
         }
--- a/jdk/src/share/classes/sun/security/ssl/ProtocolList.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/ProtocolList.java	Mon Mar 10 15:07:09 2008 -0700
@@ -98,7 +98,7 @@
                 protocolNames[i++] = version.name;
             }
         }
-        return (String[])protocolNames.clone();
+        return protocolNames.clone();
     }
 
     public String toString() {
--- a/jdk/src/share/classes/sun/security/ssl/SSLSessionImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/SSLSessionImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -458,7 +458,7 @@
                         + " for Kerberos cipher suites");
         }
         if (peerCerts != null) {
-            return (X509Certificate [])peerCerts.clone();
+            return peerCerts.clone();
         } else {
             throw new SSLPeerUnverifiedException("peer not authenticated");
         }
@@ -489,7 +489,7 @@
         if (peerCerts == null) {
             throw new SSLPeerUnverifiedException("peer not authenticated");
         }
-        return ((X500Principal)peerCerts[0].getSubjectX500Principal());
+        return peerCerts[0].getSubjectX500Principal();
     }
 
     /**
@@ -508,7 +508,7 @@
                         (KerberosPrincipal)localPrincipal);
         }
         return (localCerts == null ? null :
-            (X500Principal)localCerts[0].getSubjectX500Principal());
+                localCerts[0].getSubjectX500Principal());
     }
 
     /**
--- a/jdk/src/share/classes/sun/security/ssl/SessionId.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/SessionId.java	Mon Mar 10 15:07:09 2008 -0700
@@ -64,7 +64,7 @@
     /** Returns the bytes in the ID.  May be an empty array.  */
     byte [] getId ()
     {
-        return (byte []) sessionId.clone ();
+        return sessionId.clone ();
     }
 
     /** Returns the ID as a string */
--- a/jdk/src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java	Mon Mar 10 15:07:09 2008 -0700
@@ -172,7 +172,7 @@
         if (cred == null) {
             return null;
         } else {
-            return (X509Certificate[])cred.certificates.clone();
+            return cred.certificates.clone();
         }
     }
 
@@ -255,7 +255,7 @@
         String[] aliases;
 
         if (issuers == null || issuers.length == 0) {
-            aliases = (String[])serverAliasCache.get(keyType);
+            aliases = serverAliasCache.get(keyType);
             if (aliases == null) {
                 aliases = getServerAliases(keyType, issuers);
                 // Cache the result (positive and negative lookups)
@@ -388,7 +388,7 @@
             }
         }
 
-        String[] aliasStrings = (String[])aliases.toArray(STRING0);
+        String[] aliasStrings = aliases.toArray(STRING0);
         return ((aliasStrings.length == 0) ? null : aliasStrings);
     }
 
--- a/jdk/src/share/classes/sun/security/x509/CertificatePolicySet.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/security/x509/CertificatePolicySet.java	Mon Mar 10 15:07:09 2008 -0700
@@ -87,7 +87,7 @@
         DerOutputStream tmp = new DerOutputStream();
 
         for (int i = 0; i < ids.size(); i++) {
-            ((CertificatePolicyId)ids.elementAt(i)).encode(tmp);
+            ids.elementAt(i).encode(tmp);
         }
         out.write(DerValue.tag_Sequence,tmp);
     }
--- a/jdk/src/share/classes/sun/security/x509/X509Cert.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/security/x509/X509Cert.java	Mon Mar 10 15:07:09 2008 -0700
@@ -516,7 +516,7 @@
      * Null is returned in the case of a partially constructed cert.
      */
     public byte []      getSignedCert ()
-        { return (byte[])signedCert.clone(); }
+        { return signedCert.clone(); }
 
 
     /**
--- a/jdk/src/share/classes/sun/tools/jar/JarVerifierStream.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/tools/jar/JarVerifierStream.java	Mon Mar 10 15:07:09 2008 -0700
@@ -32,7 +32,6 @@
 import java.security.cert.Certificate;
 import java.security.AccessController;
 import java.security.cert.X509Certificate;
-import java.security.Identity;
 import java.security.PublicKey;
 import java.security.Principal;
 import sun.security.provider.SystemIdentity;
@@ -49,7 +48,8 @@
 public class JarVerifierStream extends ZipInputStream {
 
     private JarEntry current;
-    private Hashtable verified = new Hashtable();
+    private Hashtable<String, Vector<SystemIdentity>> verified
+        = new Hashtable<String, Vector<SystemIdentity>>();
     private JarInputStream jis;
     private sun.tools.jar.Manifest man = null;
 
@@ -120,7 +120,7 @@
         if (current != null) {
             Certificate[] certs = current.getCertificates();
             if (certs != null) {
-                Vector ids = getIds(certs);
+                Vector<SystemIdentity> ids = getIds(certs);
                 if (ids != null) {
                     verified.put(current.getName(), ids);
                 }
@@ -189,7 +189,7 @@
 
     static class CertCache {
         Certificate [] certs;
-        Vector ids;
+        Vector<SystemIdentity> ids;
 
         boolean equals(Certificate[] certs) {
                 if (this.certs == null) {
@@ -229,21 +229,21 @@
         }
     }
 
-    private ArrayList certCache = null;
+    private ArrayList<CertCache> certCache = null;
 
 
     /**
      * Returns the Identity vector for the given array of Certificates
      */
-    protected Vector getIds(Certificate[] certs) {
+    protected Vector<SystemIdentity> getIds(Certificate[] certs) {
         if (certs == null)
             return null;
 
         if (certCache == null)
-            certCache = new ArrayList();
+            certCache = new ArrayList<CertCache>();
         CertCache cc;
         for (int i = 0; i < certCache.size(); i++) {
-            cc = (CertCache) certCache.get(i);
+            cc = certCache.get(i);
             if (cc.equals(certs)) {
                 return cc.ids;
             }
@@ -265,8 +265,8 @@
                         new sun.security.x509.X509Cert(encoded);
                     try {
                         AccessController.doPrivileged(
-                         new java.security.PrivilegedExceptionAction() {
-                            public Object run()
+                         new java.security.PrivilegedExceptionAction<Void>() {
+                            public Void run()
                                 throws java.security.KeyManagementException
                             {
                                 id.addCertificate(oldC);
@@ -278,7 +278,7 @@
                             pae.getException();
                     }
                     if (cc.ids == null)
-                        cc.ids = new Vector();
+                        cc.ids = new Vector<SystemIdentity>();
                     cc.ids.addElement(id);
                 } catch (java.security.KeyManagementException kme) {
                     // ignore if we can't create Identity
--- a/jdk/src/share/classes/sun/tools/native2ascii/N2AFilter.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/sun/tools/native2ascii/N2AFilter.java	Mon Mar 10 15:07:09 2008 -0700
@@ -42,7 +42,7 @@
 
     public void write(char b) throws IOException {
         char[] buf = new char[1];
-        buf[0] = (char)b;
+        buf[0] = b;
         write(buf, 0, 1);
     }
 
--- a/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java	Mon Mar 10 15:07:09 2008 -0700
@@ -52,14 +52,10 @@
      * Sync interval in seconds.
      */
     private static final int SYNC_INTERVAL = Math.max(1,
-        Integer.parseInt((String)
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
-                    return System.getProperty("java.util.prefs.syncInterval",
-                                              "30");
-                }
-        })));
-
+        Integer.parseInt(
+            AccessController.doPrivileged(
+                new sun.security.action.GetPropertyAction(
+                    "java.util.prefs.syncInterval", "30"))));
 
     /**
      * Returns logger for error messages. Backing store exceptions are logged at
@@ -103,8 +99,8 @@
     }
 
     private static void setupUserRoot() {
-        AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+            public Void run() {
                 userRootDir =
                       new File(System.getProperty("java.util.prefs.userRoot",
                       System.getProperty("user.home")), ".java/.userPrefs");
@@ -164,9 +160,9 @@
     }
 
     private static void setupSystemRoot() {
-        AccessController.doPrivileged( new PrivilegedAction() {
-            public Object run() {
-                String systemPrefsDirName = (String)
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+            public Void run() {
+                String systemPrefsDirName =
                   System.getProperty("java.util.prefs.systemRoot","/etc/.java");
                 systemRootDir =
                      new File(systemPrefsDirName, ".systemPrefs");
@@ -322,7 +318,7 @@
      * corresponding disk file (prefsFile) by the sync operation.  The initial
      * value is read *without* acquiring the file-lock.
      */
-    private Map prefsCache = null;
+    private Map<String, String> prefsCache = null;
 
     /**
      * The last modification time of the file backing this node at the time
@@ -358,7 +354,7 @@
      * log against that map.  The resulting map is then written back
      * to the disk.
      */
-    final List changeLog = new ArrayList();
+    final List<Change> changeLog = new ArrayList<Change>();
 
     /**
      * Represents a change to a preference.
@@ -424,7 +420,7 @@
      */
     private void replayChanges() {
         for (int i = 0, n = changeLog.size(); i<n; i++)
-            ((Change)changeLog.get(i)).replay();
+            changeLog.get(i).replay();
     }
 
     private static Timer syncTimer = new Timer(true); // Daemon Thread
@@ -438,8 +434,8 @@
         }, SYNC_INTERVAL*1000, SYNC_INTERVAL*1000);
 
         // Add shutdown hook to flush cached prefs on normal termination
-        AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+            public Void run() {
                 Runtime.getRuntime().addShutdownHook(new Thread() {
                     public void run() {
                         syncTimer.cancel();
@@ -503,15 +499,15 @@
         dir  = new File(parent.dir, dirName(name));
         prefsFile = new File(dir, "prefs.xml");
         tmpFile  = new File(dir, "prefs.tmp");
-        AccessController.doPrivileged( new PrivilegedAction() {
-            public Object run() {
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+            public Void run() {
                 newNode = !dir.exists();
                 return null;
             }
         });
         if (newNode) {
             // These 2 things guarantee node will get wrtten at next flush/sync
-            prefsCache = new TreeMap();
+            prefsCache = new TreeMap<String, String>();
             nodeCreate = new NodeCreate();
             changeLog.add(nodeCreate);
         }
@@ -529,7 +525,7 @@
 
     protected String getSpi(String key) {
         initCacheIfNecessary();
-        return (String) prefsCache.get(key);
+        return prefsCache.get(key);
     }
 
     protected void removeSpi(String key) {
@@ -554,7 +550,7 @@
             loadCache();
         } catch(Exception e) {
             // assert lastSyncTime == 0;
-            prefsCache = new TreeMap();
+            prefsCache = new TreeMap<String, String>();
         }
     }
 
@@ -568,9 +564,10 @@
      */
     private void loadCache() throws BackingStoreException {
         try {
-            AccessController.doPrivileged( new PrivilegedExceptionAction() {
-                public Object run() throws BackingStoreException {
-                    Map m = new TreeMap();
+            AccessController.doPrivileged(
+                new PrivilegedExceptionAction<Void>() {
+                public Void run() throws BackingStoreException {
+                    Map<String, String> m = new TreeMap<String, String>();
                     long newLastSyncTime = 0;
                     try {
                         newLastSyncTime = prefsFile.lastModified();
@@ -584,7 +581,7 @@
                             prefsFile.renameTo( new File(
                                                     prefsFile.getParentFile(),
                                                   "IncorrectFormatPrefs.xml"));
-                            m = new TreeMap();
+                            m = new TreeMap<String, String>();
                         } else if (e instanceof FileNotFoundException) {
                         getLogger().warning("Prefs file removed in background "
                                            + prefsFile.getPath());
@@ -614,8 +611,9 @@
      */
     private void writeBackCache() throws BackingStoreException {
         try {
-            AccessController.doPrivileged( new PrivilegedExceptionAction() {
-                public Object run() throws BackingStoreException {
+            AccessController.doPrivileged(
+                new PrivilegedExceptionAction<Void>() {
+                public Void run() throws BackingStoreException {
                     try {
                         if (!dir.exists() && !dir.mkdirs())
                             throw new BackingStoreException(dir +
@@ -641,15 +639,14 @@
 
     protected String[] keysSpi() {
         initCacheIfNecessary();
-        return (String[])
-            prefsCache.keySet().toArray(new String[prefsCache.size()]);
+        return prefsCache.keySet().toArray(new String[prefsCache.size()]);
     }
 
     protected String[] childrenNamesSpi() {
-        return (String[])
-            AccessController.doPrivileged( new PrivilegedAction() {
-                public Object run() {
-                    List result = new ArrayList();
+        return AccessController.doPrivileged(
+            new PrivilegedAction<String[]>() {
+                public String[] run() {
+                    List<String> result = new ArrayList<String>();
                     File[] dirContents = dir.listFiles();
                     if (dirContents != null) {
                         for (int i = 0; i < dirContents.length; i++)
@@ -685,8 +682,9 @@
      */
     protected void removeNodeSpi() throws BackingStoreException {
         try {
-            AccessController.doPrivileged( new PrivilegedExceptionAction() {
-                public Object run() throws BackingStoreException {
+            AccessController.doPrivileged(
+                new PrivilegedExceptionAction<Void>() {
+                public Void run() throws BackingStoreException {
                     if (changeLog.contains(nodeCreate)) {
                         changeLog.remove(nodeCreate);
                         nodeCreate = null;
@@ -731,8 +729,9 @@
            if (!lockFile(shared))
                throw(new BackingStoreException("Couldn't get file lock."));
            final Long newModTime =
-                (Long) AccessController.doPrivileged( new PrivilegedAction() {
-               public Object run() {
+                AccessController.doPrivileged(
+                    new PrivilegedAction<Long>() {
+               public Long run() {
                    long nmt;
                    if (isUserNode()) {
                        nmt = userRootModFile.lastModified();
@@ -746,8 +745,8 @@
            });
            try {
                super.sync();
-               AccessController.doPrivileged( new PrivilegedAction() {
-                   public Object run() {
+               AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                   public Void run() {
                    if (isUserNode()) {
                        userRootModTime = newModTime.longValue() + 1000;
                        userRootModFile.setLastModified(userRootModTime);
@@ -766,8 +765,9 @@
 
     protected void syncSpi() throws BackingStoreException {
         try {
-            AccessController.doPrivileged( new PrivilegedExceptionAction() {
-                public Object run() throws BackingStoreException {
+            AccessController.doPrivileged(
+                new PrivilegedExceptionAction<Void>() {
+                public Void run() throws BackingStoreException {
                     syncSpiPrivileged();
                     return null;
                 }
@@ -794,7 +794,7 @@
         } else if (lastSyncTime != 0 && !dir.exists()) {
             // This node was removed in the background.  Playback any changes
             // against a virgin (empty) Map.
-            prefsCache = new TreeMap();
+            prefsCache = new TreeMap<String, String>();
             replayChanges();
         }
         if (!changeLog.isEmpty()) {
--- a/jdk/src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java	Mon Mar 10 15:07:09 2008 -0700
@@ -217,8 +217,7 @@
                         Updator u = null;
                         while ((u = updateList.poll()) != null) {
                             // First add pollfd struct to clear out this fd
-                            putPollFD(updatePollArray, index, u.fd,
-                                      (short)POLLREMOVE);
+                            putPollFD(updatePollArray, index, u.fd, POLLREMOVE);
                             index++;
                             // Now add pollfd to update this fd, if necessary
                             if (u.mask != POLLREMOVE) {
--- a/jdk/src/solaris/classes/sun/security/provider/NativePRNG.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/solaris/classes/sun/security/provider/NativePRNG.java	Mon Mar 10 15:07:09 2008 -0700
@@ -71,8 +71,9 @@
     private static final RandomIO INSTANCE = initIO();
 
     private static RandomIO initIO() {
-        Object o = AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
+        return AccessController.doPrivileged(
+            new PrivilegedAction<RandomIO>() {
+                public RandomIO run() {
                 File randomFile = new File(NAME_RANDOM);
                 if (randomFile.exists() == false) {
                     return null;
@@ -88,7 +89,6 @@
                 }
             }
         });
-        return (RandomIO)o;
     }
 
     // return whether the NativePRNG is available
--- a/jdk/src/windows/classes/sun/security/mscapi/SunMSCAPI.java	Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/windows/classes/sun/security/mscapi/SunMSCAPI.java	Mon Mar 10 15:07:09 2008 -0700
@@ -48,8 +48,8 @@
     private static final String INFO = "Sun's Microsoft Crypto API provider";
 
     static {
-        AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+            public Void run() {
                 System.loadLibrary("sunmscapi");
                 return null;
             }