static bool compressedOOPSEnabled_is64bitHotSpot; static bool compressedOOPSEnabled_compressedOOPS; static bool compressedOOPSEnabled_checked; static bool compressedOOPSEnabled() { if (compressedOOPSEnabled_checked) ret compressedOOPSEnabled_compressedOOPS; S OS_ARCH = System.getProperty("os.arch"); S MANAGEMENT_FACTORY_CLASS = "java.lang.management.ManagementFactory"; S HOTSPOT_BEAN_CLASS = "com.sun.management.HotSpotDiagnosticMXBean"; S x = System.getProperty("sun.arch.data.model"); bool is64Bit = contains(or(x, OS_ARCH), "64"); if (is64Bit) { try { final Class beanClazz = Class.forName(HOTSPOT_BEAN_CLASS); final Object hotSpotBean = Class.forName(MANAGEMENT_FACTORY_CLASS).getMethod("getPlatformMXBean", Class.class) .invoke(null, beanClazz); if (hotSpotBean != null) { compressedOOPSEnabled_is64bitHotSpot = true; final Method getVMOptionMethod = beanClazz.getMethod("getVMOption", String.class); try { final Object vmOption = getVMOptionMethod.invoke(hotSpotBean, "UseCompressedOops"); compressedOOPSEnabled_compressedOOPS = Boolean.parseBoolean(vmOption.getClass().getMethod("getValue").invoke(vmOption).toString()); } catch (ReflectiveOperationException | RuntimeException e) { compressedOOPSEnabled_is64bitHotSpot = false; } } } catch (ReflectiveOperationException | RuntimeException e) { compressedOOPSEnabled_is64bitHotSpot = false; } } compressedOOPSEnabled_checked = true; ret compressedOOPSEnabled_compressedOOPS; }