changeset 10394:0f61d05e28f1

8042872: Fix raw and unchecked warnings in sun.applet Reviewed-by: darcy, herrick
author henryjen
date Mon, 23 Jun 2014 10:54:10 -0700
parents 802c5168d429
children fb3f4212427f
files src/share/classes/sun/applet/AppletClassLoader.java src/share/classes/sun/applet/AppletImageRef.java src/share/classes/sun/applet/AppletObjectInputStream.java src/share/classes/sun/applet/AppletPanel.java src/share/classes/sun/applet/AppletProps.java src/share/classes/sun/applet/AppletSecurity.java src/share/classes/sun/applet/AppletViewer.java src/share/classes/sun/applet/AppletViewerFactory.java src/share/classes/sun/applet/AppletViewerPanel.java src/share/classes/sun/applet/Main.java
diffstat 10 files changed, 138 insertions(+), 129 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/applet/AppletClassLoader.java	Thu Jul 10 15:27:02 2014 -0700
+++ b/src/share/classes/sun/applet/AppletClassLoader.java	Mon Jun 23 10:54:10 2014 -0700
@@ -137,7 +137,7 @@
      * Override loadClass so that class loading errors can be caught in
      * order to print better error messages.
      */
-    public synchronized Class loadClass(String name, boolean resolve)
+    public synchronized Class<?> loadClass(String name, boolean resolve)
         throws ClassNotFoundException
     {
         // First check if we have permission to access the package. This
@@ -166,7 +166,7 @@
      * Finds the applet class with the specified name. First searches
      * loaded JAR files then the applet code base for the class.
      */
-    protected Class findClass(String name) throws ClassNotFoundException {
+    protected Class<?> findClass(String name) throws ClassNotFoundException {
 
         int index = name.indexOf(';');
         String cookie = "";
@@ -192,9 +192,9 @@
         String encodedName = ParseUtil.encodePath(name.replace('.', '/'), false);
         final String path = (new StringBuffer(encodedName)).append(".class").append(cookie).toString();
         try {
-            byte[] b = (byte[]) AccessController.doPrivileged(
-                               new PrivilegedExceptionAction() {
-                public Object run() throws IOException {
+            byte[] b = AccessController.doPrivileged(
+                               new PrivilegedExceptionAction<byte[]>() {
+                public byte[] run() throws IOException {
                    try {
                         URL finalURL = new URL(base, path);
 
@@ -556,9 +556,10 @@
      * name. First checks loaded JAR files then the applet code base for all
      * available resources.
      */
-    public Enumeration findResources(String name) throws IOException {
+    @Override
+    public Enumeration<URL> findResources(String name) throws IOException {
 
-        final Enumeration e = super.findResources(name);
+        final Enumeration<URL> e = super.findResources(name);
 
         // 6215746:  Disable META-INF/* lookup from codebase in
         // applet/plugin classloader. [stanley.ho]
@@ -576,9 +577,9 @@
         }
 
         final URL url = u;
-        return new Enumeration() {
+        return new Enumeration<URL>() {
             private boolean done;
-            public Object nextElement() {
+            public URL nextElement() {
                 if (!done) {
                     if (e.hasMoreElements()) {
                         return e.nextElement();
@@ -601,7 +602,7 @@
      * attribute. The argument can either be the relative path
      * of the class file itself or just the name of the class.
      */
-    Class loadCode(String name) throws ClassNotFoundException {
+    Class<?> loadCode(String name) throws ClassNotFoundException {
         // first convert any '/' or native file separator to .
         name = name.replace('/', '.');
         name = name.replace(File.separatorChar, '.');
@@ -646,7 +647,7 @@
     public ThreadGroup getThreadGroup() {
       synchronized (threadGroupSynchronizer) {
         if (threadGroup == null || threadGroup.isDestroyed()) {
-            AccessController.doPrivileged(new PrivilegedAction() {
+            AccessController.doPrivileged(new PrivilegedAction<Object>() {
                 public Object run() {
                     threadGroup = new AppletThreadGroup(base + "-threadGroup");
                     // threadGroup.setDaemon(true);
@@ -770,8 +771,8 @@
 
 
     // Hash map to store applet compatibility info
-    private HashMap jdk11AppletInfo = new HashMap();
-    private HashMap jdk12AppletInfo = new HashMap();
+    private HashMap<String, Boolean> jdk11AppletInfo = new HashMap<>();
+    private HashMap<String, Boolean> jdk12AppletInfo = new HashMap<>();
 
     /**
      * Set applet target level as JDK 1.1.
@@ -780,7 +781,7 @@
      * @param bool true if JDK is targeted for JDK 1.1;
      *             false otherwise.
      */
-    void setJDK11Target(Class clazz, boolean bool)
+    void setJDK11Target(Class<?> clazz, boolean bool)
     {
          jdk11AppletInfo.put(clazz.toString(), Boolean.valueOf(bool));
     }
@@ -792,7 +793,7 @@
      * @param bool true if JDK is targeted for JDK 1.2;
      *             false otherwise.
      */
-    void setJDK12Target(Class clazz, boolean bool)
+    void setJDK12Target(Class<?> clazz, boolean bool)
     {
         jdk12AppletInfo.put(clazz.toString(), Boolean.valueOf(bool));
     }
@@ -805,9 +806,9 @@
      *         FALSE if applet is not;
      *         null if applet is unknown.
      */
-    Boolean isJDK11Target(Class clazz)
+    Boolean isJDK11Target(Class<?> clazz)
     {
-        return (Boolean) jdk11AppletInfo.get(clazz.toString());
+        return jdk11AppletInfo.get(clazz.toString());
     }
 
     /**
@@ -818,9 +819,9 @@
      *         FALSE if applet is not;
      *         null if applet is unknown.
      */
-    Boolean isJDK12Target(Class clazz)
+    Boolean isJDK12Target(Class<?> clazz)
     {
-        return (Boolean) jdk12AppletInfo.get(clazz.toString());
+        return jdk12AppletInfo.get(clazz.toString());
     }
 
     private static AppletMessageHandler mh =
--- a/src/share/classes/sun/applet/AppletImageRef.java	Thu Jul 10 15:27:02 2014 -0700
+++ b/src/share/classes/sun/applet/AppletImageRef.java	Mon Jun 23 10:54:10 2014 -0700
@@ -65,7 +65,7 @@
      * invoke reconstitute().
      */
     public synchronized void flush() {
-        SoftReference s = soft;
+        SoftReference<Image> s = soft;
         if (s != null) s.clear();
         soft = null;
     }
@@ -74,9 +74,9 @@
      * Sets the thing to the specified object.
      * @param thing the specified object
      */
-    public synchronized void setThing(Object thing) {
+    public synchronized void setThing(Image thing) {
         flush();
-        soft = new SoftReference(thing);
+        soft = new SoftReference<>(thing);
     }
 
     /**
--- a/src/share/classes/sun/applet/AppletObjectInputStream.java	Thu Jul 10 15:27:02 2014 -0700
+++ b/src/share/classes/sun/applet/AppletObjectInputStream.java	Mon Jun 23 10:54:10 2014 -0700
@@ -59,7 +59,7 @@
      * Make a primitive array class
      */
 
-    private Class primitiveType(char type) {
+    private Class<?> primitiveType(char type) {
         switch (type) {
         case 'B': return byte.class;
         case 'C': return char.class;
@@ -76,13 +76,13 @@
     /**
      * Use the given ClassLoader rather than using the system class
      */
-    protected Class resolveClass(ObjectStreamClass classDesc)
+    protected Class<?> resolveClass(ObjectStreamClass classDesc)
         throws IOException, ClassNotFoundException {
 
         String cname = classDesc.getName();
         if (cname.startsWith("[")) {
             // An array
-            Class component;            // component class
+            Class<?> component;            // component class
             int dcount;                 // dimension
             for (dcount=1; cname.charAt(dcount)=='['; dcount++) ;
             if (cname.charAt(dcount) == 'L') {
--- a/src/share/classes/sun/applet/AppletPanel.java	Thu Jul 10 15:27:02 2014 -0700
+++ b/src/share/classes/sun/applet/AppletPanel.java	Mon Jun 23 10:54:10 2014 -0700
@@ -179,7 +179,7 @@
 
         handler = new Thread(appletGroup, this, "thread " + nm);
         // set the context class loader for this thread
-        AccessController.doPrivileged(new PrivilegedAction() {
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
                 @Override
                 public Object run() {
                     handler.setContextClassLoader(loader);
@@ -253,7 +253,7 @@
     /**
      * AppletEvent Queue
      */
-    private Queue queue = null;
+    private Queue<Integer> queue = null;
 
 
     synchronized public void addAppletListener(AppletListener l) {
@@ -282,7 +282,7 @@
         synchronized(this) {
             if (queue == null) {
                 //System.out.println("SEND0= " + id);
-                queue = new Queue();
+                queue = new Queue<>();
             }
             Integer eventId = Integer.valueOf(id);
             queue.enqueue(eventId);
@@ -309,7 +309,7 @@
         while (queue == null || queue.isEmpty()) {
             wait();
         }
-        Integer eventId = (Integer)queue.dequeue();
+        Integer eventId = queue.dequeue();
         return new AppletEvent(this, eventId.intValue(), null);
     }
 
@@ -631,14 +631,15 @@
      * calls KeyboardFocusManager directly.
      */
     private Component getMostRecentFocusOwnerForWindow(Window w) {
-        Method meth = (Method)AccessController.doPrivileged(new PrivilegedAction() {
+        Method meth = AccessController.doPrivileged(
+            new PrivilegedAction<Method>() {
                 @Override
-                public Object run() {
+                public Method run() {
                     Method meth = null;
                     try {
                         meth = KeyboardFocusManager.class.getDeclaredMethod(
                                 "getMostRecentFocusOwner",
-                                new Class[]{Window.class});
+                                new Class<?>[]{Window.class});
                         meth.setAccessible(true);
                     } catch (Exception e) {
                         // Must never happen
@@ -988,7 +989,7 @@
     /**
      * The class loaders
      */
-    private static HashMap classloaders = new HashMap();
+    private static HashMap<String, AppletClassLoader> classloaders = new HashMap<>();
 
     /**
      * Flush a class loader.
@@ -1001,7 +1002,7 @@
      * Flush all class loaders.
      */
     public static synchronized void flushClassLoaders() {
-        classloaders = new HashMap();
+        classloaders = new HashMap<>();
     }
 
     /**
@@ -1018,14 +1019,14 @@
      * Get a class loader. Create in a restricted context
      */
     synchronized AppletClassLoader getClassLoader(final URL codebase, final String key) {
-        AppletClassLoader c = (AppletClassLoader)classloaders.get(key);
+        AppletClassLoader c = classloaders.get(key);
         if (c == null) {
             AccessControlContext acc =
                 getAccessControlContext(codebase);
-            c = (AppletClassLoader)
-                AccessController.doPrivileged(new PrivilegedAction() {
+            c = AccessController.doPrivileged(
+                    new PrivilegedAction<AppletClassLoader>() {
                         @Override
-                        public Object run() {
+                        public AppletClassLoader run() {
                             AppletClassLoader ac = createClassLoader(codebase);
                             /* Should the creation of the classloader be
                              * within the class synchronized block?  Since
@@ -1043,8 +1044,7 @@
                              * (which timeout when called from the browser).
                              */
                             synchronized (getClass()) {
-                                AppletClassLoader res =
-                                    (AppletClassLoader)classloaders.get(key);
+                                AppletClassLoader res = classloaders.get(key);
                                 if (res == null) {
                                     classloaders.put(key, ac);
                                     return ac;
@@ -1066,10 +1066,10 @@
      */
     private AccessControlContext getAccessControlContext(final URL codebase) {
 
-        PermissionCollection perms = (PermissionCollection)
-            AccessController.doPrivileged(new PrivilegedAction() {
+        PermissionCollection perms = AccessController.doPrivileged(
+                new PrivilegedAction<PermissionCollection>() {
                     @Override
-                    public Object run() {
+                    public PermissionCollection run() {
                         Policy p = java.security.Policy.getPolicy();
                         if (p != null) {
                             return p.getPermissions(new CodeSource(null,
@@ -1172,13 +1172,15 @@
         // critical section of the window list in AppContext.
         synchronized (Window.class)
         {
-            WeakReference weakRef = null;
+            WeakReference<Window> weakRef = null;
             // Remove frame from the Window list in wrong AppContext
             {
                 // Lookup current frame's AppContext
-                Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>)oldAppContext.get(Window.class);
+                @SuppressWarnings("unchecked")
+                Vector<WeakReference<Window>> windowList =
+                    (Vector<WeakReference<Window>>)oldAppContext.get(Window.class);
                 if (windowList != null) {
-                    for (WeakReference ref : windowList) {
+                    for (WeakReference<Window> ref : windowList) {
                         if (ref.get() == frame) {
                             weakRef = ref;
                             break;
@@ -1195,7 +1197,9 @@
 
             // Insert frame into the Window list in the applet's AppContext map
             {
-                Vector<WeakReference<Window>> windowList = (Vector)newAppContext.get(Window.class);
+                @SuppressWarnings("unchecked")
+                Vector<WeakReference<Window>> windowList =
+                    (Vector<WeakReference<Window>>)newAppContext.get(Window.class);
                 if (windowList == null) {
                     windowList = new Vector<WeakReference<Window>>();
                     newAppContext.put(Window.class, windowList);
@@ -1224,7 +1228,7 @@
         // synchronized on applet class object, so calling from
         // different instances of the same applet will be
         // serialized.
-        Class appletClass = applet.getClass();
+        Class<?> appletClass = applet.getClass();
 
         synchronized(appletClass)  {
             // Determine if the JDK level of an applet has been
--- a/src/share/classes/sun/applet/AppletProps.java	Thu Jul 10 15:27:02 2014 -0700
+++ b/src/share/classes/sun/applet/AppletProps.java	Mon Jun 23 10:54:10 2014 -0700
@@ -105,9 +105,9 @@
         String proxyPortValue = proxyPort.getText().trim();
 
         // Get properties
-        final Properties props = (Properties) AccessController.doPrivileged(
-             new PrivilegedAction() {
-                 public Object run() {
+        final Properties props = AccessController.doPrivileged(
+             new PrivilegedAction<Properties>() {
+                 public Properties run() {
                      return System.getProperties();
                  }
         });
@@ -148,7 +148,7 @@
         // Save properties
         try {
             reset();
-            AccessController.doPrivileged(new PrivilegedExceptionAction() {
+            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                 public Object run() throws IOException {
                     File dotAV = Main.theUserPropertiesFile;
                     FileOutputStream out = new FileOutputStream(dotAV);
--- a/src/share/classes/sun/applet/AppletSecurity.java	Thu Jul 10 15:27:02 2014 -0700
+++ b/src/share/classes/sun/applet/AppletSecurity.java	Mon Jun 23 10:54:10 2014 -0700
@@ -80,7 +80,7 @@
     }
 
     // Cache to store known restricted packages
-    private HashSet restrictedPackages = new HashSet();
+    private HashSet<String> restrictedPackages = new HashSet<>();
 
     /**
      * Reset from Properties
@@ -90,11 +90,11 @@
         // Clear cache
         restrictedPackages.clear();
 
-        AccessController.doPrivileged(new PrivilegedAction() {
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
             public Object run()
             {
                 // Enumerate system properties
-                Enumeration e = System.getProperties().propertyNames();
+                Enumeration<?> e = System.getProperties().propertyNames();
 
                 while (e.hasMoreElements())
                 {
@@ -130,7 +130,7 @@
             return (AppletClassLoader)loader;
 
         // if that fails, get all the classes on the stack and check them.
-        Class[] context = getClassContext();
+        Class<?>[] context = getClassContext();
         for (int i = 0; i < context.length; i++) {
             loader = context[i].getClassLoader();
             if (loader instanceof AppletClassLoader)
@@ -148,37 +148,38 @@
             final ClassLoader currentLoader = context[i].getClassLoader();
 
             if (currentLoader instanceof URLClassLoader) {
-                loader = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
+                loader = AccessController.doPrivileged(
+                    new PrivilegedAction<ClassLoader>() {
+                        public ClassLoader run() {
 
-                        AccessControlContext acc = null;
-                        ProtectionDomain[] pds = null;
+                            AccessControlContext acc = null;
+                            ProtectionDomain[] pds = null;
 
-                        try {
-                            acc = (AccessControlContext) facc.get(currentLoader);
-                            if (acc == null) {
-                                return null;
+                            try {
+                                acc = (AccessControlContext) facc.get(currentLoader);
+                                if (acc == null) {
+                                    return null;
+                                }
+
+                                pds = (ProtectionDomain[]) fcontext.get(acc);
+                                if (pds == null) {
+                                    return null;
+                                }
+                            } catch (Exception e) {
+                                throw new UnsupportedOperationException(e);
                             }
 
-                            pds = (ProtectionDomain[]) fcontext.get(acc);
-                            if (pds == null) {
-                                return null;
+                            for (int i=0; i<pds.length; i++) {
+                                ClassLoader cl = pds[i].getClassLoader();
+
+                                if (cl instanceof AppletClassLoader) {
+                                        return cl;
+                                }
                             }
-                        } catch (Exception e) {
-                            throw new UnsupportedOperationException(e);
+
+                            return null;
                         }
-
-                        for (int i=0; i<pds.length; i++) {
-                            ClassLoader cl = pds[i].getClassLoader();
-
-                            if (cl instanceof AppletClassLoader) {
-                                    return cl;
-                            }
-                        }
-
-                        return null;
-                    }
-                });
+                    });
 
                 if (loader != null) {
                     return (AppletClassLoader) loader;
@@ -282,9 +283,9 @@
         super.checkPackageAccess(pkgname);
 
         // now check the list of restricted packages
-        for (Iterator iter = restrictedPackages.iterator(); iter.hasNext();)
+        for (Iterator<String> iter = restrictedPackages.iterator(); iter.hasNext();)
         {
-            String pkg = (String) iter.next();
+            String pkg = iter.next();
 
             // Prevent matching "sun" and "sunir" even if they
             // starts with similar beginning characters
--- a/src/share/classes/sun/applet/AppletViewer.java	Thu Jul 10 15:27:02 2014 -0700
+++ b/src/share/classes/sun/applet/AppletViewer.java	Mon Jun 23 10:54:10 2014 -0700
@@ -94,7 +94,7 @@
 
     @Override
     public AppletViewer createAppletViewer(int x, int y,
-                                           URL doc, Hashtable atts) {
+                                           URL doc, Hashtable<String, String> atts) {
         return new AppletViewer(x, y, doc, atts, System.out, this);
     }
 
@@ -156,7 +156,7 @@
     /**
      * Create the applet viewer.
      */
-    public AppletViewer(int x, int y, URL doc, Hashtable atts,
+    public AppletViewer(int x, int y, URL doc, Hashtable<String, String> atts,
                         PrintStream statusMsgStream, AppletViewerFactory factory) {
         this.factory = factory;
         this.statusMsgStream = statusMsgStream;
@@ -350,7 +350,7 @@
      *             s.  Whitespace not stripped.
      */
     private String [] splitSeparator(String sep, String s) {
-        Vector v = new Vector();
+        Vector<String> v = new Vector<>();
         int tokenStart = 0;
         int tokenEnd   = 0;
 
@@ -370,7 +370,7 @@
      * Methods for java.applet.AppletContext
      */
 
-    private static Map audioClips = new HashMap();
+    private static Map<URL, AudioClip> audioClips = new HashMap<>();
 
     /**
      * Get an audio clip.
@@ -379,7 +379,7 @@
     public AudioClip getAudioClip(URL url) {
         checkConnect(url);
         synchronized (audioClips) {
-            AudioClip clip = (AudioClip)audioClips.get(url);
+            AudioClip clip = audioClips.get(url);
             if (clip == null) {
                 audioClips.put(url, clip = new AppletAudioClip(url));
             }
@@ -387,7 +387,7 @@
         }
     }
 
-    private static Map imageRefs = new HashMap();
+    private static Map<URL, AppletImageRef> imageRefs = new HashMap<>();
 
     /**
      * Get an image.
@@ -403,7 +403,7 @@
     static Image getCachedImage(URL url) {
         // System.getSecurityManager().checkConnection(url.getHost(), url.getPort());
         synchronized (imageRefs) {
-            AppletImageRef ref = (AppletImageRef)imageRefs.get(url);
+            AppletImageRef ref = imageRefs.get(url);
             if (ref == null) {
                 ref = new AppletImageRef(url);
                 imageRefs.put(url, ref);
@@ -419,7 +419,7 @@
         imageRefs.clear();
     }
 
-    static Vector appletPanels = new Vector();
+    static Vector<AppletPanel> appletPanels = new Vector<>();
 
     /**
      * Get an applet by name.
@@ -430,8 +430,8 @@
         name = name.toLowerCase();
         SocketPermission panelSp =
             new SocketPermission(panel.getCodeBase().getHost(), "connect");
-        for (Enumeration e = appletPanels.elements() ; e.hasMoreElements() ;) {
-            AppletPanel p = (AppletPanel)e.nextElement();
+        for (Enumeration<AppletPanel> e = appletPanels.elements() ; e.hasMoreElements() ;) {
+            AppletPanel p = e.nextElement();
             String param = p.getParameter("name");
             if (param != null) {
                 param = param.toLowerCase();
@@ -455,14 +455,14 @@
      * applets on this page.
      */
     @Override
-    public Enumeration getApplets() {
+    public Enumeration<Applet> getApplets() {
         AppletSecurity security = (AppletSecurity)System.getSecurityManager();
-        Vector v = new Vector();
+        Vector<Applet> v = new Vector<>();
         SocketPermission panelSp =
             new SocketPermission(panel.getCodeBase().getHost(), "connect");
 
-        for (Enumeration e = appletPanels.elements() ; e.hasMoreElements() ;) {
-            AppletPanel p = (AppletPanel)e.nextElement();
+        for (Enumeration<AppletPanel> e = appletPanels.elements() ; e.hasMoreElements() ;) {
+            AppletPanel p = e.nextElement();
             if (p.getDocumentBase().equals(panel.getDocumentBase())) {
 
                 SocketPermission sp =
@@ -509,7 +509,7 @@
     }
 
     @Override
-    public Iterator getStreamKeys(){
+    public Iterator<String> getStreamKeys(){
         // We do nothing.
         return null;
     }
@@ -517,7 +517,7 @@
     /**
      * System parameters.
      */
-    static Hashtable systemParam = new Hashtable();
+    static Hashtable<String, String> systemParam = new Hashtable<>();
 
     static {
         systemParam.put("codebase", "codebase");
@@ -533,32 +533,32 @@
     /**
      * Print the HTML tag.
      */
-    public static void printTag(PrintStream out, Hashtable atts) {
+    public static void printTag(PrintStream out, Hashtable<String, String> atts) {
         out.print("<applet");
 
-        String v = (String)atts.get("codebase");
+        String v = atts.get("codebase");
         if (v != null) {
             out.print(" codebase=\"" + v + "\"");
         }
 
-        v = (String)atts.get("code");
+        v = atts.get("code");
         if (v == null) {
             v = "applet.class";
         }
         out.print(" code=\"" + v + "\"");
-        v = (String)atts.get("width");
+        v = atts.get("width");
         if (v == null) {
             v = "150";
         }
         out.print(" width=" + v);
 
-        v = (String)atts.get("height");
+        v = atts.get("height");
         if (v == null) {
             v = "100";
         }
         out.print(" height=" + v);
 
-        v = (String)atts.get("name");
+        v = atts.get("name");
         if (v != null) {
             out.print(" name=\"" + v + "\"");
         }
@@ -568,8 +568,8 @@
         int len = atts.size();
         String params[] = new String[len];
         len = 0;
-        for (Enumeration e = atts.keys() ; e.hasMoreElements() ;) {
-            String param = (String)e.nextElement();
+        for (Enumeration<String> e = atts.keys() ; e.hasMoreElements() ;) {
+            String param = e.nextElement();
             int i = 0;
             for (; i < len ; i++) {
                 if (params[i].compareTo(param) >= 0) {
@@ -649,7 +649,7 @@
      * Save the applet to a well known file (for now) as a serialized object
      */
     void appletSave() {
-        AccessController.doPrivileged(new PrivilegedAction() {
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
 
             @Override
             public Object run() {
@@ -702,8 +702,10 @@
     void appletClone() {
         Point p = location();
         updateAtts();
+        @SuppressWarnings("unchecked")
+        Hashtable<String, String> tmp = (Hashtable<String, String>) panel.atts.clone();
         factory.createAppletViewer(p.x + XDELTA, p.y + YDELTA,
-                                   panel.documentURL, (Hashtable)panel.atts.clone());
+                                   panel.documentURL, tmp);
     }
 
     /**
@@ -884,8 +886,8 @@
             @Override
             public void run()
             {
-                for (Enumeration e = appletPanels.elements() ; e.hasMoreElements() ;) {
-                    AppletPanel p = (AppletPanel)e.nextElement();
+                for (Enumeration<AppletPanel> e = appletPanels.elements() ; e.hasMoreElements() ;) {
+                    AppletPanel p = e.nextElement();
                     appletShutdown(p);
                 }
                 appletSystemExit();
@@ -1016,8 +1018,8 @@
     /**
      * Scan tag
      */
-    public static Hashtable scanTag(Reader in) throws IOException {
-        Hashtable atts = new Hashtable();
+    public static Hashtable<String, String> scanTag(Reader in) throws IOException {
+        Hashtable<String, String> atts = new Hashtable<>();
         skipSpace(in);
         while (c >= 0 && c != '>') {
             String att = scanIdentifier(in);
@@ -1122,7 +1124,7 @@
         url = conn.getURL();
 
         int ydisp = 1;
-        Hashtable atts = null;
+        Hashtable<String, String> atts = null;
 
         while(true) {
             c = in.read();
@@ -1172,12 +1174,12 @@
                 else {
                     String nm = scanIdentifier(in);
                     if (nm.equalsIgnoreCase("param")) {
-                        Hashtable t = scanTag(in);
-                        String att = (String)t.get("name");
+                        Hashtable<String, String> t = scanTag(in);
+                        String att = t.get("name");
                         if (att == null) {
                             statusMsgStream.println(requiresNameWarning);
                         } else {
-                            String val = (String)t.get("value");
+                            String val = t.get("value");
                             if (val == null) {
                                 statusMsgStream.println(requiresNameWarning);
                             } else if (atts != null) {
@@ -1235,13 +1237,13 @@
                     }
                     else if (nm.equalsIgnoreCase("app")) {
                         statusMsgStream.println(appNotLongerSupportedWarning);
-                        Hashtable atts2 = scanTag(in);
-                        nm = (String)atts2.get("class");
+                        Hashtable<String, String> atts2 = scanTag(in);
+                        nm = atts2.get("class");
                         if (nm != null) {
                             atts2.remove("class");
                             atts2.put("code", nm + ".class");
                         }
-                        nm = (String)atts2.get("src");
+                        nm = atts2.get("src");
                         if (nm != null) {
                             atts2.remove("src");
                             atts2.put("codebase", nm);
--- a/src/share/classes/sun/applet/AppletViewerFactory.java	Thu Jul 10 15:27:02 2014 -0700
+++ b/src/share/classes/sun/applet/AppletViewerFactory.java	Mon Jun 23 10:54:10 2014 -0700
@@ -35,7 +35,8 @@
 
 public
 interface AppletViewerFactory {
-        public AppletViewer createAppletViewer(int x, int y, URL doc, Hashtable atts);
+        public AppletViewer createAppletViewer(int x, int y, URL doc,
+                                               Hashtable<String, String> atts);
         public MenuBar getBaseMenuBar();
         public boolean isStandalone();
 }
--- a/src/share/classes/sun/applet/AppletViewerPanel.java	Thu Jul 10 15:27:02 2014 -0700
+++ b/src/share/classes/sun/applet/AppletViewerPanel.java	Mon Jun 23 10:54:10 2014 -0700
@@ -59,7 +59,7 @@
     /**
      * The attributes of the applet.
      */
-    Hashtable atts;
+    Hashtable<String, String> atts;
 
     /*
      * JDK 1.1 serialVersionUID
@@ -69,7 +69,7 @@
     /**
      * Construct an applet viewer and start the applet.
      */
-    AppletViewerPanel(URL documentURL, Hashtable atts) {
+    AppletViewerPanel(URL documentURL, Hashtable<String, String> atts) {
         this.documentURL = documentURL;
         this.atts = atts;
 
@@ -105,7 +105,7 @@
      * Get an applet parameter.
      */
     public String getParameter(String name) {
-        return (String)atts.get(name.toLowerCase());
+        return atts.get(name.toLowerCase());
     }
 
     /**
--- a/src/share/classes/sun/applet/Main.java	Thu Jul 10 15:27:02 2014 -0700
+++ b/src/share/classes/sun/applet/Main.java	Mon Jun 23 10:54:10 2014 -0700
@@ -84,7 +84,7 @@
     /**
      * The list of valid URLs passed in to AppletViewer.
      */
-    private static Vector urlList = new Vector(1);
+    private static Vector<URL> urlList = new Vector<>(1);
 
     // This is used in init().  Getting rid of this is desirable but depends
     // on whether the property that uses it is necessary/standard.
@@ -153,7 +153,7 @@
                 // XXX 5/17 this parsing method should be changed/fixed so that
                 // it doesn't do both parsing of the html file and launching of
                 // the AppletPanel
-                AppletViewer.parse((URL) urlList.elementAt(i), encoding);
+                AppletViewer.parse(urlList.elementAt(i), encoding);
             } catch (IOException e) {
                 System.err.println(lookup("main.err.io", e.getMessage()));
                 return 1;
@@ -307,10 +307,10 @@
         // 2) Reflection removes any build dependency between appletviewer
         // and jdb.
         try {
-            Class c = Class.forName("com.sun.tools.example.debug.tty.TTY", true,
+            Class<?> c = Class.forName("com.sun.tools.example.debug.tty.TTY", true,
                                     ClassLoader.getSystemClassLoader());
             Method m = c.getDeclaredMethod("main",
-                                           new Class[] { String[].class });
+                                           new Class<?>[] { String[].class });
             m.invoke(null, new Object[] { newArgs });
         } catch (ClassNotFoundException cnfe) {
             System.err.println(lookup("main.debug.cantfinddebug"));
@@ -367,7 +367,7 @@
         // Read in the System properties.  If something is going to be
         // over-written, warn about it.
         Properties sysProps = System.getProperties();
-        for (Enumeration e = sysProps.propertyNames(); e.hasMoreElements(); ) {
+        for (Enumeration<?> e = sysProps.propertyNames(); e.hasMoreElements(); ) {
             String key = (String) e.nextElement();
             String val = sysProps.getProperty(key);
             String oldVal;