Download Jar. Libraryless. Click here for Pure Java version (741L/6K).
1 | !7 |
2 | |
3 | static String OS_ARCH = System.getProperty("os.arch");
|
4 | static boolean JRE_IS_64BIT_HOTSPOT; |
5 | static boolean COMPRESSED_REFS_ENABLED; |
6 | static String MANAGEMENT_FACTORY_CLASS = "java.lang.management.ManagementFactory"; |
7 | static String HOTSPOT_BEAN_CLASS = "com.sun.management.HotSpotDiagnosticMXBean"; |
8 | |
9 | p {
|
10 | boolean is64Bit = false; |
11 | final String x = System.getProperty("sun.arch.data.model");
|
12 | if (x != null) {
|
13 | is64Bit = x.contains("64");
|
14 | } else {
|
15 | if (OS_ARCH != null && OS_ARCH.contains("64")) {
|
16 | is64Bit = true; |
17 | } else {
|
18 | is64Bit = false; |
19 | } |
20 | } |
21 | boolean compressedOops = false; |
22 | boolean is64BitHotspot = false; |
23 | |
24 | if (is64Bit) {
|
25 | try {
|
26 | final Class<?> beanClazz = Class.forName(HOTSPOT_BEAN_CLASS); |
27 | // we use reflection for this, because the management factory is |
28 | // not part |
29 | // of Java 8's compact profile: |
30 | final Object hotSpotBean = Class.forName(MANAGEMENT_FACTORY_CLASS).getMethod("getPlatformMXBean", Class.class)
|
31 | .invoke(null, beanClazz); |
32 | if (hotSpotBean != null) {
|
33 | |
34 | is64BitHotspot = true; |
35 | final Method getVMOptionMethod = beanClazz.getMethod("getVMOption", String.class);
|
36 | try {
|
37 | final Object vmOption = getVMOptionMethod.invoke(hotSpotBean, "UseCompressedOops"); |
38 | compressedOops = Boolean.parseBoolean(vmOption.getClass().getMethod("getValue").invoke(vmOption).toString());
|
39 | } catch (ReflectiveOperationException | RuntimeException e) {
|
40 | is64BitHotspot = false; |
41 | } |
42 | } |
43 | } catch (ReflectiveOperationException | RuntimeException e) {
|
44 | is64BitHotspot = false; |
45 | } |
46 | } |
47 | |
48 | JRE_IS_64BIT_HOTSPOT = is64BitHotspot; |
49 | COMPRESSED_REFS_ENABLED = compressedOops; |
50 | |
51 | print("Is 64bit Hotspot JVM: " + JRE_IS_64BIT_HOTSPOT);
|
52 | print("Compressed Oops enabled: " + COMPRESSED_REFS_ENABLED);
|
53 | print("isCompressedOopsOffOn64Bit: " + isCompressedOopsOffOn64Bit());
|
54 | } |
55 | |
56 | static bool isCompressedOopsOffOn64Bit() {
|
57 | ret JRE_IS_64BIT_HOTSPOT && !COMPRESSED_REFS_ENABLED; |
58 | } |
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: | 762 / 1870 |
| Referenced in: | [show references] |