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

opening jar file with large manifest might throw NegativeArraySizeException

    XMLWordPrintable

    Details

      Backports

        Description

        Create a jar file with a manifest of size 2GB. This can be done, for example, with the following commands:

        $ mkdir META-INF
        $ dd if=/dev/zero of=META-INF/MANIFEST.MF bs=1m count=2048
        $ zip -r foo.jar META-INF

        (Note that the resulting jar file will have a malformed manifest.)

        Then open the jar file, either by putting it on the classpath, or by opening it using the JarFile API and reading the manifest:

        $ java -cp foo.jar X
        Error: A JNI error has occurred, please check your installation and try again
        Exception in thread "main" java.lang.NegativeArraySizeException

        jshell> new java.util.jar.JarFile("foo.jar").getManifest()
        | Exception java.lang.NegativeArraySizeException: -2147483648

        If the manifest is too large to be read into memory, OutOfMemoryError should be thrown instead.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                jpai Jaikiran Pai
                Reporter:
                smarks Stuart Marks
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: