Download Jar. Libraryless. Click here for Pure Java version (741L/6K).
!7 static String OS_ARCH = System.getProperty("os.arch"); static boolean JRE_IS_64BIT_HOTSPOT; static boolean COMPRESSED_REFS_ENABLED; static String MANAGEMENT_FACTORY_CLASS = "java.lang.management.ManagementFactory"; static String HOTSPOT_BEAN_CLASS = "com.sun.management.HotSpotDiagnosticMXBean"; p { boolean is64Bit = false; final String x = System.getProperty("sun.arch.data.model"); if (x != null) { is64Bit = x.contains("64"); } else { if (OS_ARCH != null && OS_ARCH.contains("64")) { is64Bit = true; } else { is64Bit = false; } } boolean compressedOops = false; boolean is64BitHotspot = false; if (is64Bit) { try { final Class<?> beanClazz = Class.forName(HOTSPOT_BEAN_CLASS); // we use reflection for this, because the management factory is // not part // of Java 8's compact profile: final Object hotSpotBean = Class.forName(MANAGEMENT_FACTORY_CLASS).getMethod("getPlatformMXBean", Class.class) .invoke(null, beanClazz); if (hotSpotBean != null) { is64BitHotspot = true; final Method getVMOptionMethod = beanClazz.getMethod("getVMOption", String.class); try { final Object vmOption = getVMOptionMethod.invoke(hotSpotBean, "UseCompressedOops"); compressedOops = Boolean.parseBoolean(vmOption.getClass().getMethod("getValue").invoke(vmOption).toString()); } catch (ReflectiveOperationException | RuntimeException e) { is64BitHotspot = false; } } } catch (ReflectiveOperationException | RuntimeException e) { is64BitHotspot = false; } } JRE_IS_64BIT_HOTSPOT = is64BitHotspot; COMPRESSED_REFS_ENABLED = compressedOops; print("Is 64bit Hotspot JVM: " + JRE_IS_64BIT_HOTSPOT); print("Compressed Oops enabled: " + COMPRESSED_REFS_ENABLED); print("isCompressedOopsOffOn64Bit: " + isCompressedOopsOffOn64Bit()); } static bool isCompressedOopsOffOn64Bit() { ret JRE_IS_64BIT_HOTSPOT && !COMPRESSED_REFS_ENABLED; }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, ppjhyzlbdabe, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1011521 |
Snippet name: | CompressedOOPSChecker Spike |
Eternal ID of this version: | #1011521/1 |
Text MD5: | 92bcd8681e8307a3522f3c6678a60297 |
Transpilation MD5: | eb7613ab824f2bed7e48f798f6419318 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-10-30 23:01:53 |
Source code size: | 2192 bytes / 58 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 527 / 1217 |
Referenced in: | #1011522 - compressedOOPSEnabled |