Skip to content

Commit dafbe5b

Browse files
committed
GH-143 do not use VM name and vendor to test profiling support
1 parent 183b3fe commit dafbe5b

File tree

1 file changed

+13
-31
lines changed

1 file changed

+13
-31
lines changed

visualvm/profiler/src/com/sun/tools/visualvm/profiler/ProfilerSupport.java

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,8 @@ public final class ProfilerSupport {
6161

6262
// private static final Logger LOGGER = Logger.getLogger(ProfilerSupport.class.getName());
6363

64-
private static final boolean FORCE_PROFILING_SUPPORTED =
65-
Boolean.getBoolean("com.sun.tools.visualvm.profiler.SupportAllVMs"); // NOI18N
6664
private static final String HOTSPOT_VM_NAME_PREFIX = "Java HotSpot"; // NOI18N
6765
private static final String OPENJDK_VM_NAME_PREFIX = "OpenJDK "; // NOI18N
68-
private static final String SAPJDK_VM_NAME_PREFIX = "SAP Java "; // NOI18N
69-
private static final String SUN_VM_VENDOR_PREFIX = "Sun "; // NOI18N
70-
private static final String ORACLE_VM_VENDOR_PREFIX = "Oracle "; // NOI18N
71-
private static final String APPLE_VM_VENDOR_PREFIX = "Apple "; // NOI18N
72-
private static final String HP_VM_VENDOR_PREFIX = "\"Hewlett-Packard "; // NOI18N
73-
private static final String AZUL_VM_VENDOR_PREFIX = "Azul "; // NOI18N
74-
private static final String SAP_VM_VENDOR_PREFIX = "SAP AG"; // NOI18N
75-
private static final String GRAAL_VM_VENDOR_PREFIX = "GraalVM "; // NOI18N
76-
private static final String ORACLE1_VM_VENDOR_PREFIX = "\"Oracle "; // NOI18N
7766

7867
private static final String JAVA_RT_16_PREFIX = "1.6.0"; // NOI18N
7968
private static final String JAVA_RT_17_PREFIX = "1.7.0"; // NOI18N
@@ -315,29 +304,14 @@ boolean supportsProfiling(Application application) {
315304
// Basic info has to be supported and VM has to be attachable
316305
if (!jvm.isBasicInfoSupported() || !jvm.isAttachable()) return false;
317306

318-
// User explicitly requests to profile any VM
319-
if (FORCE_PROFILING_SUPPORTED) return true;
320-
321-
////// //TODO
322-
////// // temporary disabled until profiling is rewritten to NB 90
323-
////// return false;
324-
325307
// Profiled application needs to be running JDK 6.0 or 7.0 or 8.0 or 9.0
326-
// or 10 or 11
308+
// or 10 or 11 or 12
327309
if (jvm.is14() || jvm.is15()) return false;
328310

329-
String vmName = jvm.getVmName();
330-
String vmVendor = jvm.getVmVendor();
331-
332-
// VM has to be a HotSpot VM or OpenJDK by Sun Microsystems Inc. or
333-
// Oracle Co. or Apple Inc. or Hewlett-Packard Co. or
334-
// Azul Systems, Inc. or SAP AG or Graal VM
335-
return vmName != null && (vmName.startsWith(HOTSPOT_VM_NAME_PREFIX) || vmName.startsWith(OPENJDK_VM_NAME_PREFIX)
336-
|| vmName.startsWith(SAPJDK_VM_NAME_PREFIX) || vmName.startsWith(GRAAL_VM_VENDOR_PREFIX)) &&
337-
vmVendor != null && (vmVendor.startsWith(ORACLE_VM_VENDOR_PREFIX) || vmVendor.startsWith(SUN_VM_VENDOR_PREFIX)
338-
|| vmVendor.startsWith(APPLE_VM_VENDOR_PREFIX) || vmVendor.startsWith(HP_VM_VENDOR_PREFIX)
339-
|| vmVendor.startsWith(AZUL_VM_VENDOR_PREFIX) || vmVendor.startsWith(SAP_VM_VENDOR_PREFIX)
340-
|| vmVendor.startsWith(ORACLE1_VM_VENDOR_PREFIX));
311+
int arch = getJVMArchitecture(jvm);
312+
if (arch == -1) return false;
313+
String javaVer = Platform.getJDKVersionString(jvm.getJavaVersion());
314+
return supportsProfiling(javaVer, arch);
341315
}
342316

343317
static boolean classSharingBreaksProfiling(Application application) {
@@ -411,6 +385,14 @@ private static int getBuildNumber(String javaRTVersion) {
411385

412386
return -1;
413387
}
388+
389+
private static int getJVMArchitecture(Jvm jvm) {
390+
String jvmArch = jvm.getSystemProperties().getProperty("sun.arch.data.model"); // NOI18N
391+
if (jvmArch != null) {
392+
return Integer.valueOf(jvmArch);
393+
}
394+
return -1;
395+
}
414396

415397
synchronized void setProfiledApplication(Application profiledApplication) {
416398
this.profiledApplication = profiledApplication;

0 commit comments

Comments
 (0)