I finally switched over to Java 1.5 for my coding work. Herewith a couple of things I found moderately surprising. For Java hounds only.

ProcessBuilder · The main reason I made the switch is that I need to launch some carefully-orchestrated processes (JVM’s, but whatever), and the docs say that Runtime.exec() is deprecated in favor of ProcessBuilder.

Good enough, Runtime certainly had problems; but when I first scanned the ProcessBuilder docs I had some severe mental dislocation. To start with, it didn’t seem to have any setter methods, and I definitely wanted to set the directory and so on. You just have to read the docs carefully:

FILE directory() Returns this process builder’s working directory.
ProcessBuilder directory(File directory) Sets this process builder’s working directory.

Once you dig it, it’s elegant, minimal... and surprising. I don’t like surprises when I’m reading APIs. Maybe I’m just a curmudgeon. Also, that second call doesn’t actually make a new ProcessBuilder, it just returns the same one because, well, I don’t know why.

Compulsory Generics · On my first Tiger build, I got this disturbing little message that I was using “unsafe operations”, with advice to compile with -Xlint:unchecked. OK, that told me:

Connector.java:193: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.HashMap

I’ve never really cared much for generics, the class of errors they prevent seems small and uninteresting, and my eyes don’t even see all those casts any more. But I guess I gotta use ’em if I want clean compiles.

I’m definitely feeling a little curmudgeonly.


author · Dad · software · colophon · rights
picture of the day
June 06, 2005
· Technology (87 fragments)
· · Java (123 more)

By .

The opinions expressed here
are my own, and no other party
necessarily agrees with them.

A full disclosure of my
professional interests is
on the author page.