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

Using pack from java program corrupts ant.jar



    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 5.0u6
    • Fix Version/s: None
    • Component/s: deploy
    • Labels:


      When compressing/uncompressing jars using pack/unpack it breaks lib/ant.jar from Apache Ant 1.6.5. We use pack to compress unsigned jars from NetBeans IDE to decrease size of installer. After that I get following exception:

      ERROR - Ant is misconfigured and cannot be run.
      java.lang.ClassFormatError: Illegal field name " " in class org/apache/tools/ant/taskdefs/Antlib
              at java.lang.ClassLoader.defineClass1(Native Method)
              at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
              at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
              at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
              at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
              at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
              at org.apache.tools.ant.module.bridge.AntBridge$MaskedClassLoader.loadClass(AntBridge.java:622)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
              at java.lang.Class.forName0(Native Method)
              at java.lang.Class.forName(Class.java:242)
              at org.apache.tools.ant.module.bridge.AntBridge.createStuff(AntBridge.java:272)
              at org.apache.tools.ant.module.bridge.AntBridge.getStuff(AntBridge.java:242)
              at org.apache.tools.ant.module.bridge.AntBridge.getInterface(AntBridge.java:231)
              at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:287)
              at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:125)

      After some experiments I found it happens when I use property p.put(Packer.SEGMENT_LIMIT, "-1"); for packer. I will attach sample code I use for packing/unpacking ant.jar. When I do not use this property or use command line pack200 (even with -S-1 option) it does not happen.

      java version:
      java version "1.5.0_06"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

      I tried to simplify code sample as much as possible and I do not see any problem with it. It follows example given at Javadoc/available examples.
      Correction: Behavior is the same for command line pack200 when using -S-1 option ie. ant.jar is corrupted in the same way.
      There is another unclear thing: When I pack any jar using command line pack200 with default settings and try to unpack it using Unpacker from java I get following error message:
      java.io.IOException: Corrupted pack file: magic/ver = 1F8B0800/0.0 should be CAFED00D/150.7

              at com.sun.java.util.jar.pack.NativeUnpack.start(Native Method)
              at com.sun.java.util.jar.pack.NativeUnpack.run(NativeUnpack.java:168)
              at com.sun.java.util.jar.pack.NativeUnpack.run(NativeUnpack.java:217)
              at com.sun.java.util.jar.pack.UnpackerImpl.unpack(UnpackerImpl.java:104)
              at com.sun.java.util.jar.pack.UnpackerImpl.unpack(UnpackerImpl.java:127)
              at UnpackJar.unpackFile(UnpackJar.java:38)
              at UnpackJar.main(UnpackJar.java:27)

      It is not clear to me is wrong.
      I found it. pack200 uses gzip by default so my UnpackJar will not work with it. If I use pack200 -g it will be ok. Original problem is still there.
      Apache Ant is third party library. From ant.jar manifest it looks like it is compiled by JDK 1.4.1_02-b06
      I tried to recompile whole Apache Ant from sources by JDK 1.4.2_11 and it works fine (ie. if I pack/repack ant.jar even using property Packer.SEGMENT_LIMIT, "-1" it is ok). So it looks like problem is with classes compiled by JDK 1.4.1_02.
      I attached ant.jar compiled by JDK 1.4.2_11.


          Issue Links



              ngthomas Thomas Ng (Inactive)
              mslamasunw Marek Slama (Inactive)
              0 Vote for this issue
              2 Start watching this issue