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

JarInputStream cannot read empty jars

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.2.0
    • 1.2.0
    • tools
    • jar
    • 1.2fcs
    • sparc
    • solaris_2.5
    • Verified



      Name: mgC56079 Date: 08/14/98



      Here is the test: create an ampty jar with JarOutputStream.
      Try to open it with JarInputStream. This will result in a NullPointerException.

      === JarIS.java ======
      import java.util.jar.*;
      import java.io.*;

      public class JarIS {

        public static void main(String args[]) {
          ByteArrayOutputStream out=new ByteArrayOutputStream();
          try {
            new JarOutputStream(out);
            JarInputStream is = new JarInputStream(new ByteArrayInputStream(out.toByteArray()));
          }
          catch (IOException e) {
            System.out.println("unexpected IOException");
          }
          System.out.println("passed");


        }

      }
      ==== sample run ====
      % java -Djava.compiler=None JarIS
      Warning: JIT compiler "None" not found. Will use interpreter.
      Exception in thread "main" java.lang.NullPointerException
      at java.util.jar.JarInputStream.<init>(JarInputStream.java:67)
      at java.util.jar.JarInputStream.<init>(JarInputStream.java:50)
      at JarIS.main(JarIS.java:10)


      ======================================================================

            zlisunw Zhenghua Li (Inactive)
            mgorshen Mikhail Gorshenev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: