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

ZipFile constructor causes VM crash instead of NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.2.1
    • tools
    • None
    • jar
    • generic
    • generic

      Running the program "foo" below causes the following:

      java -classic -Xcheck:jni foo

      FATAL ERROR in native method: JNI received a null string
              at java.util.zip.ZipFile.open(Native Method)
              at java.util.zip.ZipFile.<init>(ZipFile.java:69)
              at foo.main(foo.java:7)

      The native method ends up calling jni_GetStringLength with a null argument, which causes a VM crash if -Xcheck:jni is not enabled.

      See bug #4219367 for a more complete list of ZipFile constructor tests.

      ----------------------------------------------------------------------------

      import java.util.zip.*;

      public class foo {
        public static void main(String[] args) {
          try {
            String name = null;
            ZipFile zf = new ZipFile(name);
          } catch (Exception e) {
            if ( e instanceof NullPointerException ) {
              System.out.println ("Expected NullPointerException thrown");
              return;
            } else {
              System.out.println ("Exception thrown, but not the expected NullPointerException");
              e.printStackTrace();
              return;
            }
          }
          System.out.println ("NullPointerException was not thrown");
        }
      }

            zlisunw Zhenghua Li (Inactive)
            sgrarupsunw Steffen Grarup (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: