2008-08-21

Using using in C# - a little pitfall

The using clause in C# is pretty nifty. Wrap an initializer in the first part of using, and, no matter how the code in body exits, the object will be disposed of using its IDisposable interface. .NET defines a lot of such managed object classes for processes, mutexes, and so on. Well, I was stealing borrowing some code from an example that looked like: using (Process p = new Process()) { . . . p.WaitForExit(); } but I needed to return the process and wait for it somewhere else instead, outside this snipped. So I wrote: using (Process p = new Process()) { . . . return p; } As soon as the caller used WaitForExit() on the process, it blew up, because the process was disposed of before it was returned ! While I suppose there could be reasons for returning disposed objects — after all, they are still valid objects — this kind of thing is usually a braino. It would be nice if the compiler issued a warning like: Hey, bub, do you really want to return a disposed object ?

2008-05-13

PHP Goonz


PHP Goonz, originally uploaded by rpkrajewski.

No comment.

2008-04-30

Here's What JDK 6 in Mac OS X Gets You:

Finally, Apple has shipped JDK 6 for Mac OS X 10.5. It's only for Intel Macs that can run 64-bit code, like Core 2 Duos and Xeons. If you have an early Intel Mac, you're probably out of luck.

You can run pure Java programs in 64-bit mode.

But a lot of popular programs, like those based on the Eclipse Rich Client Platform, cannot run in the new JDK. That includes Eclipse and Azureus.

However, you can use Eclipse as a development environment for JDK 6-based programs. Eclipse will detect the JDK 6 runtime, and you can use it in a Java project. If you run a little program like this:

public class Main {
public static void main(String[] args) {
 System.out.print("os.arch: ");
 System.out.println(System.getProperty("os.arch"));
}
}

It will print out:

os.arch: x86_64

instead of

os.arch: i386

as it would with the default Mac OS X JVM (1.5, 32 bit).

Whoopee !