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.


ongoing
software · G & M · Dad author · colophon · rights
picture of the day
Around June 06, 2005: On Apple and Intel · Caynes’ Cairn · The Autobox of Death · COOL BIZ · XML and Religion

What?
· Technology (61 fragments)
· · Java (93 more)


Serif · Sans-Serif
I work at Sun Microsystems. The opinions expressed here are my own, and neither Sun nor any other party necessarily agrees with them.