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

Unable to retrieve file data from nested jar files.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • tools
    • jar
    • x86
    • windows_2000



      Name: gm110360 Date: 05/08/2002


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)


      FULL OPERATING SYSTEM VERSION :

      Microsoft Windows 2000 [Version 5.00.2195]


      A DESCRIPTION OF THE PROBLEM :
      I am trying to retrieve the byte code of classes that are
      nested 1,2,...n levels deep inside of nested jar, ear and
      war files.

      However, I run into problems when trying to retrieve data
      from compressed nested jar, ear and war files. The clasfile
      data gets truncated or entries are not listed. The problem
      dissappears when I use jar files that are not compressed.

      I discovered that when I run the following code on a jar
      that contains compressed entries, I can retrieve the
      compressed size of all jar entries that are not inside of
      nested jars. However if a jar entry is nested, I always
      get –1 as the compression size.


      JarFile jarFile = new JarFile("myapp.ear");
      JarEntry entry1 = jarFile.getJarEntry("myapp.war");

      // always correct size compressed/ not compressed
      int size1 = entry1.getCompressedSize();

      JarInputStream(jarFile.getInputStream(entry))
      JarEntry entry2 = inputStream.getNextJarEntry();

      // always -1 if compressed
      int size2 = entry2.getCompressedSize();


      I figure whether the nested entries are compressed or not,
      the right size should be returned. Is this a bug in the
      java API or is there a better way to go about retrieving
      the byte code of classes that are nested 1,2,...n levels
      deep inside of nested jar, ear and war files?


      ~Nathan
      ###@###.###



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the following code:

      JarFile jarFile = new JarFile("myapp.ear");
      JarEntry entry1 = jarFile.getJarEntry("myapp.war");

      // always correct size compressed/ not compressed
      int size1 = entry1.getCompressedSize();

      JarInputStream inputStream = JarInputStream
      (jarFile.getInputStream(entry));

      JarEntry entry2 = inputStream.getNextJarEntry();

      // always -1 if compressed
      int size2 = entry2.getCompressedSize();

      2. Try to write entry2 out to a file. It will always be
      corrupt and of the wrong size!?!




      EXPECTED VERSUS ACTUAL BEHAVIOR :
      I should always get the correct compressed size and valid
      data when calling jarInputStream.getNextJarEntry() or
      jarEntry2.getCompressedSize(); However, I never do.


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      JarEntry=org/jdom/adapters/AbstractDOMAdapter.class;compressed size=-1;decom
      pressed size=-1
      closing entry...
          JarEntry=org/jdom/adapters/CrimsonDOMAdapter.class;compressed size=-1;decomp
      ressed size=-1
      closing entry...
          JarEntry=org/jdom/adapters/DOMAdapter.class;compressed size=-1;decompressed
      size=-1
      closing entry...
          JarEntry=org/jdom/adapters/OracleV1DOMAdapter.class;compressed size=-1;decom
      pressed size=-1
      closing entry...
          JarEntry=org/jdom/adapters/OracleV2DOMAdapter.class;compressed size=-1;decom
      pressed size=-1

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      JarFile jarFile = new JarFile("myapp.ear");
      JarEntry entry1 = jarFile.getJarEntry("myapp.war");

      // always correct size compressed/ not compressed
      int size1 = entry1.getCompressedSize();

      JarInputStream inputStream = JarInputStream(jarFile.getInputStream(entry1));

      JarEntry entry2 = inputStream.getNextJarEntry("myClass.class");

      // always -1 if compressed
      int size2 = entry2.getCompressedSize();


      ---------- END SOURCE ----------
      (Review ID: 146284)
      ======================================================================

            kkladkosunw Konstantin Kladko (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: