Life of a java disciple




J2EE Blogs:

J2ME Blogs:

.NET Blogs:

Important Links:

International Users:


















This page is powered by Blogger. Isn't yours?
Friday, February 06, 2004
 

J2SE1.5: javax.pack is awesome but ..


javax.pack.Pack200 which transforms JAR file to or from a packed stream in Pack200 format is really awsome. When Pack200 is used over rt.jar with the default example code below, its size is reduced from 35,804,926 bytes to 10,114,786 bytes. There is one gotcha though. P200 in J2SE1.5beta writes to System.out. Here are the messages written to System.out when rt.jar is compressed:

*** Error at input offset 343 of java/lang/Deprecated.class{*}
Warning: Passing class file uncompressed due to unrecognized attribute: java/lang/Deprecated.class
javax.pack.Attribute$FormatException: class.RuntimeVisibleAnnotations: passing attribute bitwise in java/lang/Deprecated
*** Error at input offset 267 of java/lang/Overrides.class{*}
Warning: Passing class file uncompressed due to unrecognized attribute: java/lang/Overrides.class
javax.pack.Attribute$FormatException: class.RuntimeVisibleAnnotations: passing attribute bitwise in java/lang/Overrides
*** Error at input offset 322 of java/lang/annotation/Documented.class{*}
Warning: Passing class file uncompressed due to unrecognized attribute: java/lang/annotation/Documented.class
javax.pack.Attribute$FormatException: class.RuntimeVisibleAnnotations: passing attribute bitwise in java/lang/annotation/Documented
*** Error at input offset 439 of java/lang/annotation/Inherited.class{*}
Warning: Passing class file uncompressed due to unrecognized attribute: java/lang/annotation/Inherited.class
javax.pack.Attribute$FormatException: class.RuntimeVisibleAnnotations: passing attribute bitwise in java/lang/annotation/Inherited
*** Error at input offset 457 of java/lang/annotation/Retention.class{*}
Warning: Passing class file uncompressed due to unrecognized attribute: java/lang/annotation/Retention.class
javax.pack.Attribute$FormatException: class.RuntimeVisibleAnnotations: passing attribute bitwise in java/lang/annotation/Retention
*** Error at input offset 451 of java/lang/annotation/Target.class{*}
Warning: Passing class file uncompressed due to unrecognized attribute: java/lang/annotation/Target.class
javax.pack.Attribute$FormatException: class.RuntimeVisibleAnnotations: passing attribute bitwise in java/lang/annotation/Target


But these doesn't really seem to be the errors though when P200.unpack is used on the packed rt.jar, the file generated is identical to original rt.jar. Hopefully this spitting to System.out will go away in final realease.

Code to Pack a Jar file:

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import java.util.jar.JarFile;
import javax.pack.Pack200;

public class Pack200Test {

public static void main( String args[]) throws IOException {

Pack200 p200 = new Pack200();

// Initialize the state by setting the desired properties
Map p = p200.getProperties();
p.put(Pack200.PACK_EFFORT, "7");
p.put(Pack200.PACK_SEGMENT_LIMIT, "-1");
p.put(Pack200.PACK_KEEP_FILE_ORDER, Pack200.FALSE);
p.put(Pack200.PACK_MODIFICATION_TIME, Pack200.LATEST);
p.put(Pack200.PACK_DEFLATE_HINT, Pack200.FALSE);
p.put(Pack200.PACK_STRIP_DEBUG, Pack200.FALSE);
p.put(Pack200.PACK_UNKNOWN_ATTRIBUTE, Pack200.ERROR);

//Pack the jar file
JarFile jar = new JarFile(args[0]);
FileOutputStream out = new FileOutputStream(args[1]);
p200.pack(jar, out);

}

}


Code for Unpacking a jar file:

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import java.util.jar.JarOutputStream;
import javax.pack.Pack200;

public class UnPack200Test {

public static void main( String args[]) throws IOException {

Pack200 p200 = new Pack200();

// Initialize the state by setting the desired properties
Map p = p200.getProperties();
p.put(Pack200.PACK_EFFORT, "7");
p.put(Pack200.PACK_SEGMENT_LIMIT, "-1");
p.put(Pack200.PACK_KEEP_FILE_ORDER, Pack200.FALSE);
p.put(Pack200.PACK_MODIFICATION_TIME, Pack200.LATEST);
p.put(Pack200.PACK_DEFLATE_HINT, Pack200.FALSE);
p.put(Pack200.PACK_STRIP_DEBUG, Pack200.FALSE);
p.put(Pack200.PACK_UNKNOWN_ATTRIBUTE, Pack200.ERROR);

//Unpack the jar file
File file = new File(args[0]);
JarOutputStream out = new JarOutputStream(new FileOutputStream(args[1]));
p200.unpack(file, out);

}

}



Thursday, February 05, 2004
 

J2SE1.5: First of its kind


atleast in one aspect. i.e un deprecating. This is probably the first release where a method is undeprecated.

The method public static String getenv(String name) in the class java.lang.System which has been deprecated since JDK1.1.x days is undeprecated with J2SE1.5. The docs of the undeprecated method can be found here. Also rightly a new Generics based getenv method is being added.


 

SPAM: We need your Debit Card PIN number


This mail is being circulated today. I recieved this mail to my yahoo account.


_Dear citibank_ _Client_,

This_ leter was seent by_the CITI_bank server to
veerify your _email_ adderss_.
You mmust clpemote this pcresos by clicking on_the_link
beelow and enttering in the smmall window your Citi-Bank
_Debit card number and PIN that you use_ in the Atm_Machine.
This is done - for_your pocrettion -T- becourse some of our
memmbers no lneogr have acescs to their email adredesss
and we must verify it.

(I removed the link here for Security reasons)
To veerify _your _EMAIL_ address and access your _Citibank
account, clik on_the_link beelow.

Kh8vHt1w



Check the spelling mistakes to avoid Yahoo spam blockers. But bad for them I am not a CitiBank customer :-)



Monday, February 02, 2004
 

Oracle: 10G - Wait is over


Oracle made 10G downloads available for both Solaris 64 bit and HP-UX. You can find the downloads here. The Register reports Price cut is on the way.