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.

Wednesday, January 28, 2004

General: Look who is making money

From Register's IT giants criticised for running third world 'sweatshops'


In Thailand, a worker making hard drives for Dell is paid the equivalent of £2.50 per day. Michael Dell, the CEO of Dell, earned £134,000 per day last year.

Michael Dell is making (more than) 50 thousand times an ordinary employee in the company. May be he deserves it for building a company which provided employment for 39,100 :-)

Thursday, December 11, 2003

J2SE: J2SE 1.5 Early Access on Dec15th?

Rick Ross mentioned J2SE 1.5 Early Access may be available by Dec 15th (Atmost by 22nd) on JavaLobby news posts here.

Here is the snippet of the news post:


On a completely separate note, we have been receiving a good deal of email lately asking for details on the upcoming early access release of the preliminary J2SE 1.5 binaries. I spoke today with the product line manager at Sun directly responsible for this, and she confirmed that they are pushing as hard as they can to get the release out the door for Javalobby members. The latest word is that the target date is December 15, but that in no case will it be later than December 22 when Sun begins its holiday break. The purpose of this early access release is for Javalobby members to help provide valuable testing and uncover and remaining bugs in the J2SE 1.5 code, so please keep in mind that this is PRE-RELEASE code and that you cannot expect it to be perfect. I'm excited that Sun is making this opportunity available exclusively to Javalobby members, so I hope you'll make the most of it and help improve Java in the process.


Note to Rick: Javalobby news emails are ending up in bulk folder for Yahoo users. You might want to do something about it. I read the news 2 days late while checking out bulk folder.

Wednesday, December 10, 2003

Java Desktop System is here

Java Desktop System is available for purchase at SUN's site. for $50. Check out the cool Looking Glass Demo by Jonathan Schwartz.

Star Office PC

Also SUN made Solaris x86 Free. Download it here.