< prev index next >

src/java.base/share/classes/com/sun/java/util/jar/pack/PackerImpl.java

Print this page

        

@@ -270,26 +270,10 @@
                 pkg.default_options |= opt;
         }
 
         // (Done collecting options from props.)
 
-        boolean isClassFile(String name) {
-            if (!name.endsWith(".class"))  return false;
-            for (String prefix = name; ; ) {
-                if (passFiles.contains(prefix))  return false;
-                int chop = prefix.lastIndexOf('/');
-                if (chop < 0)  break;
-                prefix = prefix.substring(0, chop);
-            }
-            return true;
-        }
-
-        boolean isMetaInfFile(String name) {
-            return name.startsWith("/" + Utils.METAINF) ||
-                        name.startsWith(Utils.METAINF);
-        }
-
         // Get a new package, based on the old one.
         private void makeNextPackage() {
             pkg.reset();
         }
 

@@ -330,10 +314,33 @@
                 }
             }
             InFile(JarEntry je) {
                 this(null, je);
             }
+            boolean isClassFile() {
+                if (!name.endsWith(".class")) {
+                    return false;
+                }
+                for (String prefix = name;;) {
+                    if (passFiles.contains(prefix)) {
+                        return false;
+                    }
+                    int chop = prefix.lastIndexOf('/');
+                    if (chop < 0) {
+                        break;
+                    }
+                    prefix = prefix.substring(0, chop);
+                }
+                return true;
+            }
+            boolean isMetaInfFile() {
+                return name.startsWith("/" + Utils.METAINF)
+                        || name.startsWith(Utils.METAINF);
+            }
+            boolean mustProcess() {
+                return !isMetaInfFile() && isClassFile();
+            }
             long getInputLength() {
                 long len = (je != null)? je.getSize(): f.length();
                 assert(len >= 0) : this+".len="+len;
                 // Bump size by pathname length and modtime/def-hint bytes.
                 return Math.max(0, len) + name.length() + 5;

@@ -389,11 +396,11 @@
                 String name = inFile.name;
                 Package.File bits = readFile(name, in);
                 Package.File file = null;
                 // (5078608) : discount the resource files in META-INF
                 // from segment computation.
-                long inflen = (isMetaInfFile(name))
+                long inflen = (inFile.isMetaInfFile())
                               ? 0L
                               : inFile.getInputLength();
 
                 if ((segmentSize += inflen) > segmentLimit) {
                     segmentSize -= inflen;

@@ -404,11 +411,11 @@
                     Utils.log.fine("Reading " + name);
                 }
 
                 assert(je.isDirectory() == name.endsWith("/"));
 
-                if (isClassFile(name)) {
+                if (inFile.mustProcess()) {
                     file = readClass(name, bits.getInputStream());
                 }
                 if (file == null) {
                     file = bits;
                     pkg.addFile(file);

@@ -427,11 +434,11 @@
 
             int numDone = 0;
             for (InFile inFile : inFiles) {
                 String name      = inFile.name;
                 // (5078608) : discount the resource files completely from segmenting
-                long inflen = (isMetaInfFile(name))
+                long inflen = (inFile.isMetaInfFile())
                                ? 0L
                                : inFile.getInputLength() ;
                 if ((segmentSize += inflen) > segmentLimit) {
                     segmentSize -= inflen;
                     // Estimate number of remaining segments:

@@ -445,11 +452,11 @@
                 }
                 InputStream strm = inFile.getInputStream();
                 if (verbose > 1)
                     Utils.log.fine("Reading " + name);
                 Package.File file = null;
-                if (isClassFile(name)) {
+                if (inFile.mustProcess()) {
                     file = readClass(name, strm);
                     if (file == null) {
                         strm.close();
                         strm = inFile.getInputStream();
                     }
< prev index next >