I have some code that uses the proprietary sun.*.OperatingSystemMXBean, so I was being careful with it.
try {
_osBean = (com.sun.management.OperatingSystemMXBean) java.lang.management.ManagementFactory.getOperatingSystemMXBean();
}
catch (ClassCastException e) {
_osBean = null;
}
However, when this code runs on an IBM JVM, instead of ClassCastException
, I get a runtime ClassNotFoundException
. Why is this code able to compile just fine if that class is not available and how does a JVM affect something like this?