Monday, June 07, 2004

Yahoo using Google adsense?

A friend sent an Email that Yahoo web hosting ad appears on my blog as part of Google Ads. Here is the Yahoo web hosting ad:

Film deal for 'Baghdad blogger'

Film deal for Baghdad blogger. Salam Pax, whose real name has never been revealed, spent months writing an often bleakly humorous weblog which detailed the fears and hardships of Iraqi citizens. The diary began as a way for the 29-year-old architectural student to keep in touch with his friend Raed in Jordan. "It was just simple things about what was happening in Baghdad so he could stay in touch with what was happening," he told the BBC's Today programme last year. Salam Pax began a fortnightly column in The Guardian newspaper in May last year.


Wednesday, June 02, 2004

Debugging thread related hangs in the JVM

Moazam Raja blogged on Debugging thread related hangs in the JVM. This is nice a read. Also make sure to check out code names for all J2SE versions here.

Microsoft granted patent for double click

United States Patent: 6,727,830 abstract: A method and system are provided for extending the functionality of application buttons on a limited resource computing device. Alternative application functions are launched based on the length of time an application button is pressed. A default function for an application is launched if the button is pressed for a short, i.e., normal, period of time. An alternative function of the application is launched if the button is pressed for a long, (e.g., at least one second), period of time. Still another function can be launched if the application button is pressed multiple times within a short period of time, e.g., double click.

Get ready to pay M$ every time you write a UI with double click :-)

Tuesday, March 02, 2004

General: AOP and AOM

Aspect Oriented Programming might be doom but according to Dilbert Aspect Oriented Management works Great :-)


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.