Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

38
LINES

< > BotCompany Repo | #1035194 // compressedOOPSEnabled (backup)

JavaX fragment (include)

1  
static bool compressedOOPSEnabled_is64bitHotSpot;
2  
static bool compressedOOPSEnabled_compressedOOPS;
3  
static bool compressedOOPSEnabled_checked;
4  
5  
static bool compressedOOPSEnabled() {
6  
  if (compressedOOPSEnabled_checked) ret compressedOOPSEnabled_compressedOOPS;
7  
  
8  
  S OS_ARCH = System.getProperty("os.arch");
9  
  S MANAGEMENT_FACTORY_CLASS = "java.lang.management.ManagementFactory";
10  
  S HOTSPOT_BEAN_CLASS = "com.sun.management.HotSpotDiagnosticMXBean";
11  
12  
  S x = System.getProperty("sun.arch.data.model");
13  
  bool is64Bit = contains(or(x, OS_ARCH), "64");
14  
    
15  
  if (is64Bit) {
16  
      try {
17  
          final Class<?> beanClazz = Class.forName(HOTSPOT_BEAN_CLASS);
18  
          final Object hotSpotBean = Class.forName(MANAGEMENT_FACTORY_CLASS).getMethod("getPlatformMXBean", Class.class)
19  
                  .invoke(null, beanClazz);
20  
          if (hotSpotBean != null) {
21  
22  
              compressedOOPSEnabled_is64bitHotSpot = true;
23  
              final Method getVMOptionMethod = beanClazz.getMethod("getVMOption", String.class);
24  
              try {
25  
                  final Object vmOption = getVMOptionMethod.invoke(hotSpotBean, "UseCompressedOops");
26  
                  compressedOOPSEnabled_compressedOOPS = Boolean.parseBoolean(vmOption.getClass().getMethod("getValue").invoke(vmOption).toString());
27  
              } catch (ReflectiveOperationException | RuntimeException e) {
28  
                  compressedOOPSEnabled_is64bitHotSpot = false;
29  
              }
30  
          }
31  
      } catch (ReflectiveOperationException | RuntimeException e) {
32  
          compressedOOPSEnabled_is64bitHotSpot = false;
33  
      }
34  
  }
35  
  
36  
  compressedOOPSEnabled_checked = true;
37  
  ret compressedOOPSEnabled_compressedOOPS;
38  
}

Author comment

Began life as a copy of #1011522

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035194
Snippet name: compressedOOPSEnabled (backup)
Eternal ID of this version: #1035194/1
Text MD5: 69b9c52daab97075ae1e6a0e942b7a30
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-11 19:47:07
Source code size: 1720 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 49 / 60
Referenced in: [show references]