src/share/classes/java/util/jar/JarFile.java

Print this page
rev 4802 : 7117249: fix warnings in java.util.jar, .logging, .prefs, .zip
Reviewed-by: alanb, dholmes, forax, sherman, smarks
Contributed-by: London Java Community and Michael Barker <mikeb01@gmail.com>

@@ -181,11 +181,11 @@
                         jv = new JarVerifier(b);
                     }
                 } else {
                     man = new Manifest(super.getInputStream(manEntry));
                 }
-                manRef = new SoftReference(man);
+                manRef = new SoftReference<>(man);
             }
         }
         return man;
     }
 

@@ -231,17 +231,17 @@
 
     /**
      * Returns an enumeration of the zip file entries.
      */
     public Enumeration<JarEntry> entries() {
-        final Enumeration enum_ = super.entries();
+        final Enumeration<? extends ZipEntry> enum_ = super.entries();
         return new Enumeration<JarEntry>() {
             public boolean hasMoreElements() {
                 return enum_.hasMoreElements();
             }
             public JarFileEntry nextElement() {
-                ZipEntry ze = (ZipEntry)enum_.nextElement();
+                ZipEntry ze = enum_.nextElement();
                 return new JarFileEntry(ze);
             }
         };
     }
 

@@ -606,21 +606,21 @@
         if (jv != null) {
             return jv.entries2(this, super.entries());
         }
 
         // screen out entries which are never signed
-        final Enumeration enum_ = super.entries();
+        final Enumeration<? extends ZipEntry> enum_ = super.entries();
         return new Enumeration<JarEntry>() {
 
             ZipEntry entry;
 
             public boolean hasMoreElements() {
                 if (entry != null) {
                     return true;
                 }
                 while (enum_.hasMoreElements()) {
-                    ZipEntry ze = (ZipEntry) enum_.nextElement();
+                    ZipEntry ze = enum_.nextElement();
                     if (JarVerifier.isSigningRelated(ze.getName())) {
                         continue;
                     }
                     entry = ze;
                     return true;

@@ -647,20 +647,20 @@
 
         /*
          * JAR file has no signed content. Is there a non-signing
          * code source?
          */
-        Enumeration unsigned = unsignedEntryNames();
+        Enumeration<String> unsigned = unsignedEntryNames();
         if (unsigned.hasMoreElements()) {
             return new CodeSource[]{JarVerifier.getUnsignedCS(url)};
         } else {
             return null;
         }
     }
 
     private Enumeration<String> unsignedEntryNames() {
-        final Enumeration entries = entries();
+        final Enumeration<JarEntry> entries = entries();
         return new Enumeration<String>() {
 
             String name;
 
             /*

@@ -671,11 +671,11 @@
                 if (name != null) {
                     return true;
                 }
                 while (entries.hasMoreElements()) {
                     String value;
-                    ZipEntry e = (ZipEntry) entries.nextElement();
+                    ZipEntry e = entries.nextElement();
                     value = e.getName();
                     if (e.isDirectory() || JarVerifier.isSigningRelated(value)) {
                         continue;
                     }
                     name = value;

@@ -724,13 +724,13 @@
         if (jv != null) {
             jv.setEagerValidation(eager);
         }
     }
 
-    List getManifestDigests() {
+    List<Object> getManifestDigests() {
         ensureInitialization();
         if (jv != null) {
             return jv.getManifestDigests();
         }
-        return new ArrayList();
+        return new ArrayList<Object>();
     }
 }