United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6712743 pack200: should default to 150.7 pack format for classfiles without any classes.
JDK-6712743 : pack200: should default to 150.7 pack format for classfiles without any classes.

Details
Type:
Enhancement
Submit Date:
2008-06-10
Status:
Closed
Updated Date:
2011-05-26
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
core-libs
OS:
generic,windows_xp,windows_7
Sub-Component:
java.util.jar
CPU:
x86,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
6u10,6u23,7
Fixed Versions:

Related Reports
Duplicate:
Duplicate:
Relates:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.6.0_10-beta"
Java(TM) SE Runtime Environment (build 1.6.0_10-beta-b24)
Java HotSpot(TM) Client VM (build 11.0-b12, mixed mode, sharing)

Reproducible with other Java 6 verisons, e.g. Update 6 as well.

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
Java 5 cannot unpack .jar.pack.gz files created with Java 6.  In my case I tested with Java 6 Update 10 [build 24] and Java 5 Update 15 with the command line utilities, but others have reproduced this with Java 6 Update 6 and Java 5 Update 11.  Moreover the issue has been seen with Java 5 Web Start clients of a Java 6 server.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use Java 6's pack200 utility to create a .jar.pack.gz file from a jar.  Use Java 5's unpack200 to try to unpack it.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Pack200 files created in Java 6 should be readable in Java 5 -- at the very least with a "-target 1.5" option or some such.
ACTUAL -
It is apparently impossible to create pack200 files with Java 6 that can be used with Java 5!

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Corrupted pack file: magic/ver = CAFED00D/160.1 should be CAFED00D/150.7

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Create all pack200 files with Java 5 -- which means installing an additional JDK on one's server, having one's server app know this location, etc.

Overall this is a real issue specifically for Java 6 Update 10 as it really hurts the ease of Java client deployment!

                                    

Comments
EVALUATION

The trouble here is that Jar-file does not contain any classes so the 1.6 pack200
generates a java6 compatible class, one can add a dummy class compiled with -target 5. Simple annotating JARs which are devoid of any classes should not use pack200
and instead rely on http-compression using gzip.
The above behavior and deployment strategies are described here:
http://java.sun.com/javase/6/docs/technotes/guides/deployment/deployment-guide/pack200.html

See the workaround section for more info.
                                     
2008-06-10
WORK AROUND

add a null class as shown below compiled with -target 5.

The test script:
% cat doit
#!/bin/sh -x

echo "create a failure case"
echo "Junk" > junk
jar cvf foo.jar junk
/usr/jdk/instances/jdk1.6.0/bin/pack200 foo.jar.pack.gz foo.jar
/usr/jdk/instances/jdk1.5.0/bin/unpack200 foo.jar.pack.gz bar.jar


echo "demonstrate how to fix this"
printf "public class Foo{}" > Foo.java
/usr/jdk/instances/jdk1.6.0/bin/javac -target 5 Foo.java
jar uvf foo.jar Foo.class

rm -f bar.jar
/usr/jdk/instances/jdk1.6.0/bin/pack200 foo.jar.pack.gz foo.jar
/usr/jdk/instances/jdk1.5.0/bin/unpack200 foo.jar.pack.gz bar.jar

if [ -f bar.jar ]; then
  printf "It worked\n"
fi

% ./doit
+ echo create a failure case 
create a failure case
+ echo Junk 
+ jar cvf foo.jar junk 
added manifest
adding: junk(in = 5) (out= 7)(deflated -40%)
+ /usr/jdk/instances/jdk1.6.0/bin/pack200 foo.jar.pack.gz foo.jar 
+ /usr/jdk/instances/jdk1.5.0/bin/unpack200 foo.jar.pack.gz bar.jar 
Corrupted pack file: magic/ver = CAFED00D/160.1 should be CAFED00D/150.7

+ echo demonstrate how to fix this 
demonstrate how to fix this
+ printf public class Foo{} 
+ /usr/jdk/instances/jdk1.6.0/bin/javac -target 5 Foo.java 
+ jar uvf foo.jar Foo.class 
adding: Foo.class(in = 180) (out= 152)(deflated 15%)
+ rm -f bar.jar 
+ /usr/jdk/instances/jdk1.6.0/bin/pack200 foo.jar.pack.gz foo.jar 
+ /usr/jdk/instances/jdk1.5.0/bin/unpack200 foo.jar.pack.gz bar.jar 
+ [ -f bar.jar ] 
+ printf It worked\n 
It worked
                                     
2008-06-10



Hardware and Software, Engineered to Work Together