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

Jar utility should store compressed entry size information in LOC headers

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.2.1, 1.4.0, 1.4.1
    • tools
    • jar
    • generic, x86, sparc
    • generic, solaris_8, windows_2000



      Name: gm110360 Date: 02/05/2003


      FULL PRODUCT VERSION :
      Solaris:
      java version "1.3.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
      Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)

      Windows:
      java version "1.4.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
      Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)

      java version "1.3.1_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_04-b02)
      Java HotSpot(TM) Client VM (build 1.3.1_04-b02, mixed mode)


      FULL OPERATING SYSTEM VERSION :
      SunOS dev280r1 5.8 Generic_108528-13 sun4u sparc SUNW,Sun-
      Fire-280R

      ADDITIONAL OPERATING SYSTEMS :
      Windows NT Version 4.00.1381


      A DESCRIPTION OF THE PROBLEM :
      If a jar file is created using the JDK jar utility, the
      getSize and getCompressedSize methods of the JarEntry (and
      ZipEntry) class return -1 (unknown.)

      The methods report the correct sizes if the archive is a
      zip file (created with Info-ZIP zip or other popular third-
      party compression utility.)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. create a sample text file with some content and name it:
      afile.txt
      2. jar cvf test.jar afile.txt
      3. Compile and run the sample code below against test.jar

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expect the program to display:

      Size is: size

      where size is the actual file size, but instead the program
      will display:

      Size is: -1

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.jar.*;
      import java.io.*;


      public class Main{

      public static void main(String [] args){
      JarInputStream in = null;

      if(args.length != 1){
      System.err.println("Exiting...");
      System.exit(1);
      }
      else{
      try{
      in = new JarInputStream(new FileInputStream(args
      [0]));
      while(in.available()>0){
      JarEntry current = in.getNextJarEntry();
      if(current != null){
      System.out.println("Size
      is : "+ current.getSize());
      }
      }
      }
      catch(Exception e){
      System.err.println("Caught exception "+ e);
      }
      finally{
      try{
      in.close();
      }
      catch(Exception e){
      //do nothing - we don't care!
      }
      }
      }
      }
      }

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

            sherman Xueming Shen
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: