Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6190518

Support Zip files with more than 64k entries

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • 6
    • 1.4.2, 6
    • core-libs
    • x86, sparc
    • linux, solaris_2.6

      JarFile class is not working properly on a large jar file.
        - Entries past a certain point in the file do not get found.
        - Does not list entries above a certain number

      The "jar" command itself works fine on this big jar file.

      1) JarTest.java

      Looks for BackupHistory.xml which is the last entry in file,
       and never finds it.

      javac JarTest.java
      java
      JarTest Main_COR_Session_FULL_8SEP2004_043614_1.jar

      Output:
      zip is null
      Exception in thread "main" java.lang.NullPointerException
              at java.util.zip.ZipFile.getInputStream(ZipFile.java:201)
              at java.util.jar.JarFile.getInputStream(JarFile.java:359)
              at JarTest.main(JarTest.java:29)


      2) ListJar.java

      List contents of jar file using enumeration jar.entries()
      FAILS - only lists 41633 entries, instead of 107169 entries

      javac ListJar.java
      java
      ListJar Main_COR_Session_FULL_8SEP2004_043614_1.jar > biglist

      wc -l biglist
         => 41633 biglist

      jar tvf <bigjarfile>
        => 107169 entries

      3) ListJar2.java

      List Jar file contents using ZipInputStream and getNextEntry
      WORKS - lists all entries

      javac ListJar2.java
      java
      ListJar2 Main_COR_Session_FULL_8SEP2004_043614_1.jar > correctbiglist

       wc -l correctbiglist
        => 107170 correctbiglist (includes filename at top)


      **************************************************************
      import java.util.*;
      import java.util.zip.*;
      import java.util.jar.*;
      import java.io.*;

      // Look up entry in huge JarFile. BackupHistory.xml is at end. Doesn't find it.

      public class JarTest {

       public static void main(String[] args) throws Exception {

          String jarFile = args[0];

          JarFile jar = new JarFile(jarFile);

          // not work - can't find this entry even though it's there in the huge Jar file.
          String jarEntry = "BackupHistory.xml";

          ZipEntry zip = jar.getEntry(jarEntry);
          if (zip == null)
              System.out.println ("zip is null");

          InputStream in = jar.getInputStream(zip);

          System.out.println ("getInputStream returns " + in);
        }
      }
      **************************************************************
      import java.util.*;
      import java.util.zip.*;
      import java.util.jar.*;
      import java.io.*;

      // List contents of JarFile using jar.entries() enumeration
      // FAILS - only lists 41633 entries, instead of 107169

      public class ListJar {
        public static void main(String[] args) throws Exception {
          String jarFile = args[0];

          JarFile jar = new JarFile(jarFile);

          Enumeration enum = null;

          enum = jar.entries();

          ZipEntry entry;

          while(enum.hasMoreElements()){

              entry = (ZipEntry)enum.nextElement();

              String entryName = entry.getName();

              System.out.println(" " + entryName);

          }
        }
      }
      **********************************************************
      import java.util.*;
      import java.util.zip.*;
      import java.util.jar.*;
      import java.io.*;

      // List Jar file contents using ZipInputStream and getNextEntry
      // WORKS - lists all entries

      public class ListJar2 {
        public static void main(String[] args) throws Exception {

              String jarFile = args[0];
              System.out.println("Jar File = '" + jarFile + "'");

              String jarEntry = "BackupHistory.xml";

              FileInputStream in = new FileInputStream(jarFile);
              if (in == null) {System.out.println("FileInputStream 'in' is null");};

              ZipInputStream zip = new ZipInputStream(in);
              if (zip == null) {System.out.println("ZipInputStream 'zip' is null");};

              ZipEntry entry;
              while ((entry = zip.getNextEntry()) != null) {
                  String entryName = entry.getName();
                  System.out.println(" " + entryName);
              }
          }
      }
      **********************************************************

      Please note that the Main_COR_Session_FULL_8SEP2004_043614_1.jar is jar file of 806510725 bytes. It is located at:

      /java/jle_build/sko/hp/jarfile_bug/Main_COR_Session_FULL_8SEP2004_043614_1.jar

      ###@###.### 11/4/04 01:44 GMT
      ###@###.### 11/4/04 01:54 GMT
      ###@###.### 11/4/04 01:54 GMT

            martin Martin Buchholz
            ksoshals Kirill Soshalskiy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: