Technologies based on Sun's Java platform.

Java, Copy Constructors, and clone()

The need to copy objects come up frequently in object-oriented programming. The are many times when an object needs to be copied, so a new object with the same state can be modified.

There are several solutions for this. Which one is best? That's, unfortunately, debatable.


Java 6, font anti-aliasing, and brain-dead API...

One of the big features that Java 6 added was the ability to use subpixel anti-aliasing when rendering fonts. This greatly improves the way fonts look on LCD screens, making it far more readable. By default, Swing now uses these AA settings.

Unfortunately, for what I can only imagine must be backwards compatibility reasons, text rendered by user components in Java still uses no font anti-aliasing. (Period.)

Fortunately there's API that allows you to enable subpixel rendering.


Worthless Error Messages

This error message is just priceless:

Problem Occurred: Reason: org/eclipse/ui/IWorkbenchPreferencePage

I love the title. It's really wonderful. "Problem occurred." You know, I did figure that out. I figured it out because an error message is being displayed.

"Unable to create the selected preference page" - this is basically the only helpful message for users on the entire box. And it's not very helpful because once you close the dialog, the same text appears in the preferences dialog anyway, making the error dialog practically worthless.


Singletons and Double-Checked Locking in Java

I've seen the double-checked singleton pattern before, and at first thought it would work. It's an attempt to reduce the penalty of requiring synchronized access to obtain a singleton.

Essentially the pattern is as follows:

public class Singleton {
    private static Singleton instance;

    public static Singleton getInstance() {
        if (instance == null) {
            synchronized(Singleton.class) {
                if (instance == null) {
                    instance = new Singleton();
        return instance;

WTF Indeed

This thread on The Daily WTF is rather depressing. Essentially, the original poster is complaining about the following code:


Eclipse Error

So I'm trying to build an Eclipse application using Eclipse's ANT toolset. This would allow me to build an Eclipse application from the command line without having to go through the Eclipse GUI.

But whenever I try and run the build script, I get the following errors (path names changed):


Where's Java SE 6?

I seem to recall Sun announcing they were going to open source Java, with some hints that Java 6 would be released open source around October.

Well, it's October. Actually, it's late October.

Where's Java SE 6, open or not? Java SE 6, Beta 2 has been available for months, since May if I recall correctly. (A beta, at least, if not beta 2 itself.)

It's fall 2006. Where's Java SE 6? Why have there been no status updates? When are they going to release it?


UUID Library

I've created a library for generating UUIDs with Java, based on RFC 4122. If you're using Java 1.6, this will use a hardware MAC address to generate a UUID as specified in the RFC. If not, it uses a randomly generated number for the node.

Note that while Java 1.5 added a UUID class, this library uses its own UUID class.

Update: Version 0.9.1 no longer requires Java 1.6 to compile and now runs under Java 1.5. You may also now choose whether or not to use your MAC address as the node value using the built-in generator under Java 1.6.



Subscribe to RSS - Java