Improve Java version detection on OS X

In particular, this branch improves the behavior for OS X 10.9 (and very likely 10.8, too).

This branch fixes a problem where `JAVA_HOME` (via `--java-home` or otherwise) on OS X had absolutely no effect. Now, setting that variable is respected as long as it points to a non-Apple JVM (e.g., OpenJDK 7).

It also preserves the behavior of defaulting to Apple's Java: first 1.6, then 1.5, and finally resorting to the default installed version if any. Only when `JAVA_HOME` is given, or no Apple Java is present at all, will a non-Apple Java such as OpenJDK 7 be used.

Lastly, it fixes several logic errors in various methods of the OS X case logic.