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

javac cannot handle large jar files

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • 7
    • 7
    • tools
    • generic
    • generic

      Peter Ahe wrote: (edited:jjg)
      > Hi Jon!
      >
      > We have discovered a bug in javac's zip file optimization. I looks like
      > an issue with jar files with more than 64k entries. The workaround we
      > found was to add "-J-DuseJavaUtilZip=false" to the list of options.
      >
      > Cheers,
      > Peter
      >
      > $ javac MakeJar.java && java MakeJar foo.jar
      > $ cd foo
      > $ javac -J-showversion -J-DuseJavaUtilZip=false -cp ../foo.jar Foo.java
      > java version "1.7.0-ea"
      > Java(TM) SE Runtime Environment (build 1.7.0-ea-b57)
      > Java HotSpot(TM) Client VM (build 16.0-b02, mixed mode, sharing)
      >
      > $ javac -J-showversion -cp ../foo.jar Foo.java
      > java version "1.7.0-ea"
      > Java(TM) SE Runtime Environment (build 1.7.0-ea-b57)
      > Java HotSpot(TM) Client VM (build 16.0-b02, mixed mode, sharing)
      >
      > Foo.java:1: cannot find symbol
      > public class Foo extends MakeJar {}
      > ^
      > symbol: class MakeJar
      > 1 error
      >
      > $ head -10000 ../MakeJar.java Foo.java
      > ==> ../MakeJar.java <==
      > import java.io.File;
      > import java.io.FileOutputStream;
      > import java.io.InputStream;
      > import java.util.jar.JarOutputStream;
      > import java.util.zip.ZipEntry;
      >
      > public class MakeJar {
      > public static void main(String... args) throws Exception {
      > JarOutputStream s = new JarOutputStream(new FileOutputStream(new
      > File(args[0])));
      > for (int i = 0; i < 100000; i++) {
      > s.putNextEntry(new ZipEntry("" + i + ".txt"));
      > }
      > String classFileName = MakeJar.class.getSimpleName() + ".class";
      > s.putNextEntry(new ZipEntry(classFileName));
      > InputStream i = MakeJar.class.getResourceAsStream(classFileName);
      > byte[] bytes = new byte[i.available()];
      > i.read(bytes);
      > s.write(bytes);
      > s.close();
      > }
      > }
      >
      > ==> Foo.java <==
      > public class Foo extends MakeJar {}

            ksrini Kumar Srinivasan
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: