Skip to content

Commit bb556f0

Browse files
committed
GH-130 JDK 12 support added
1 parent 7ebd911 commit bb556f0

File tree

6 files changed

+41
-57
lines changed

6 files changed

+41
-57
lines changed

visualvm/jvmstat/src/com/sun/tools/visualvm/jvmstat/JvmJvmstatModelProvider.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public JvmJvmstatModel createModelFor(Application app) {
4545
if (jvmstat != null) {
4646

4747
JvmJvmstatModel model = null;
48-
// Check for Sun VM (and maybe other?)
48+
// Check for Sun/Oracle VM (and maybe other?)
4949
// try java.property.java.version from HotSpot Express 14.0
5050
String javaVersion = jvmstat.findByName("java.property.java.version"); // NOI18N
5151

@@ -59,15 +59,13 @@ public JvmJvmstatModel createModelFor(Application app) {
5959
// JVM 1.9
6060
else if (javaVersion.startsWith("1.9.")) model = new JvmJvmstatModel_8(app,jvmstat); // NOI18N
6161
// JVM 9
62-
else if (javaVersion.equals("9")) model = new JvmJvmstatModel_8(app,jvmstat); // NOI18N
63-
else if (javaVersion.startsWith("9.")) model = new JvmJvmstatModel_8(app,jvmstat); // NOI18N
62+
else if (isJavaVersion(javaVersion, "9")) model = new JvmJvmstatModel_8(app,jvmstat); // NOI18N
6463
// JVM 10
65-
else if (javaVersion.equals("10")) model = new JvmJvmstatModel_8(app,jvmstat); // NOI18N
66-
else if (javaVersion.startsWith("10.")) model = new JvmJvmstatModel_8(app,jvmstat); // NOI18N
64+
else if (isJavaVersion(javaVersion,"10")) model = new JvmJvmstatModel_8(app,jvmstat); // NOI18N
6765
// JVM 11
68-
else if (javaVersion.equals("11")) model = new JvmJvmstatModel_8(app,jvmstat); // NOI18N
69-
else if (javaVersion.equals("11-ea")) model = new JvmJvmstatModel_8(app,jvmstat); // NOI18N
70-
else if (javaVersion.startsWith("11.")) model = new JvmJvmstatModel_8(app,jvmstat); // NOI18N
66+
else if (isJavaVersion(javaVersion,"11")) model = new JvmJvmstatModel_8(app,jvmstat); // NOI18N
67+
// JVM 12
68+
else if (isJavaVersion(javaVersion,"12")) model = new JvmJvmstatModel_8(app,jvmstat); // NOI18N
7169
}
7270

7371
if (model == null) {
@@ -92,14 +90,20 @@ public JvmJvmstatModel createModelFor(Application app) {
9290
else if (vmVersion.startsWith("13.")) model = new JvmJvmstatModel_5(app,jvmstat); // NOI18N
9391
else if (vmVersion.startsWith("14.")) model = new JvmJvmstatModel_5(app,jvmstat); // NOI18N
9492

95-
if (model == null) { // still not recognized, fallback to JvmJvmstatModel_5
93+
if (model == null) { // still not recognized, fallback to JvmJvmstatModel_8
9694
LOGGER.log(Level.WARNING, "Unrecognized java.vm.version " + vmVersion); // NOI18N
97-
model = new JvmJvmstatModel_5(app,jvmstat); // NOI18N
95+
model = new JvmJvmstatModel_8(app,jvmstat); // NOI18N
9896
}
9997
}
10098
return model;
10199
}
102100
return null;
103101
}
104102

103+
private static final boolean isJavaVersion(String javaVersionProperty, String releaseVersion) {
104+
if (javaVersionProperty.equals(releaseVersion)) return true;
105+
if (javaVersionProperty.equals(releaseVersion+"-ea")) return true;
106+
if (javaVersionProperty.startsWith(releaseVersion+".")) return true;
107+
return false;
108+
}
105109
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
build.xml.data.CRC32=dd702792
1+
build.xml.data.CRC32=2ac97466
22
build.xml.script.CRC32=03a7511e
33
build.xml.stylesheet.CRC32=[email protected]
44
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
55
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6-
nbproject/build-impl.xml.data.CRC32=dd702792
6+
nbproject/build-impl.xml.data.CRC32=2ac97466
77
nbproject/build-impl.xml.script.CRC32=6c1a4403
88
nbproject/build-impl.xml.stylesheet.CRC32=[email protected]

visualvm/profiler/nbproject/project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<compile-dependency/>
6666
<run-dependency>
6767
<release-version>1</release-version>
68-
<specification-version>1.111</specification-version>
68+
<specification-version>1.112</specification-version>
6969
</run-dependency>
7070
</dependency>
7171
<dependency>

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

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ public final class ProfilerSupport {
7777

7878
private static final String JAVA_RT_16_PREFIX = "1.6.0"; // NOI18N
7979
private static final String JAVA_RT_17_PREFIX = "1.7.0"; // NOI18N
80-
private static final String JAVA_RT_18_PREFIX = "1.8.0"; // NOI18N
81-
private static final String JAVA_RT_19_PREFIX = "1.9.0"; // NOI18N
82-
private static final String JAVA_RT_9_PREFIX = "9"; // NOI18N
83-
private static final String JAVA_RT_100_PREFIX = "10"; // NOI18N
84-
private static final String JAVA_RT_110_PREFIX = "11"; // NOI18N
8580

8681
private static ProfilerSupport instance;
8782

@@ -121,6 +116,12 @@ public boolean hasSupportedJavaPlatforms() {
121116
String code = "jdk1" + (5 + i); // NOI18N
122117
if (supportsProfiling(code, 32) || supportsProfiling(code, 64)) return true;
123118
}
119+
String code = "jdk100"; // NOI18N
120+
if (supportsProfiling(code, 32) || supportsProfiling(code, 64)) return true;
121+
code = "jdk110"; // NOI18N
122+
if (supportsProfiling(code, 32) || supportsProfiling(code, 64)) return true;
123+
code = "jdk120"; // NOI18N
124+
if (supportsProfiling(code, 32) || supportsProfiling(code, 64)) return true;
124125
return false;
125126
}
126127

@@ -135,6 +136,8 @@ public String[][] getSupportedJavaPlatforms() {
135136
if (supportsProfiling(code, 32) || supportsProfiling(code, 64)) codesl.add(code);
136137
code = "jdk110"; // NOI18N
137138
if (supportsProfiling(code, 32) || supportsProfiling(code, 64)) codesl.add(code);
139+
code = "jdk120"; // NOI18N
140+
if (supportsProfiling(code, 32) || supportsProfiling(code, 64)) codesl.add(code);
138141

139142
String[] names = new String[codesl.size()];
140143
String[] codes = new String[codesl.size()];
@@ -181,6 +184,8 @@ static String getJavaName(String code) {
181184
return NbBundle.getMessage(ProfilerSupport.class, "STR_Java_platform_name", 10); // NOI18N
182185
if (Platform.JDK_110_STRING.equals(code))
183186
return NbBundle.getMessage(ProfilerSupport.class, "STR_Java_platform_name", 11); // NOI18N
187+
if (Platform.JDK_120_STRING.equals(code))
188+
return NbBundle.getMessage(ProfilerSupport.class, "STR_Java_platform_name", 12); // NOI18N
184189
throw new IllegalArgumentException("Unknown java code " + code); // NOI18N
185190
}
186191

@@ -357,56 +362,30 @@ static boolean classSharingBreaksProfiling(Application application) {
357362
if (vmName.startsWith(HOTSPOT_VM_NAME_PREFIX)) {
358363
// JDK 6.0 is OK from Update 6 except of Update 10 Build 23 and lower
359364
if (javaRTVersion.startsWith(JAVA_RT_16_PREFIX)) {
360-
if (updateNumber == 10) {
361-
if (buildNumber >= 24) return false;
362-
} else if (updateNumber >= 6) return false;
365+
if (updateNumber < 10) return true;
366+
if (updateNumber == 10 && buildNumber <= 23) return true;
363367
// JDK 7.0 is OK from Build 26
364368
} else if (javaRTVersion.startsWith(JAVA_RT_17_PREFIX)) {
365369
if (updateNumber == 0) {
366-
if (buildNumber >= 26) return false;
367-
} else {
368-
return false;
370+
if (buildNumber < 26) return true;
369371
}
370-
} else if (javaRTVersion.startsWith(JAVA_RT_18_PREFIX)) {
371-
return false;
372-
} else if (javaRTVersion.startsWith(JAVA_RT_19_PREFIX)) {
373-
return false;
374-
} else if (javaRTVersion.startsWith(JAVA_RT_9_PREFIX)) {
375-
return false;
376-
} else if (javaRTVersion.startsWith(JAVA_RT_100_PREFIX)) {
377-
return false;
378-
} else if (javaRTVersion.startsWith(JAVA_RT_110_PREFIX)) {
379-
return false;
380372
}
373+
return false;
381374
// OpenJDK -------------------------------------------------------------
382375
} else if(vmName.startsWith(OPENJDK_VM_NAME_PREFIX)) {
383376
// OpenJDK 6 is OK from Build 11
384377
if (javaRTVersion.startsWith(JAVA_RT_16_PREFIX)) {
385378
if (updateNumber == 0) {
386-
if (buildNumber >= 11) return false;
387-
} else {
388-
return false;
379+
if (buildNumber < 11) return true;
389380
}
390381
// OpenJDK 7 is assumed to be OK from Build 26 (not tested)
391382
} else if (javaRTVersion.startsWith(JAVA_RT_17_PREFIX)) {
392383
if (updateNumber == 0) {
393-
if (buildNumber >= 26) return false;
394-
} else {
395-
return false;
384+
if (buildNumber < 26) return true;
396385
}
397386
}
398387
// OpenJDK 8 should be OK
399-
else if (javaRTVersion.startsWith(JAVA_RT_18_PREFIX)) {
400-
return false;
401-
} else if (javaRTVersion.startsWith(JAVA_RT_19_PREFIX)) {
402-
return false;
403-
} else if (javaRTVersion.startsWith(JAVA_RT_9_PREFIX)) {
404-
return false;
405-
} else if (javaRTVersion.startsWith(JAVA_RT_100_PREFIX)) {
406-
return false;
407-
} else if (javaRTVersion.startsWith(JAVA_RT_110_PREFIX)) {
408-
return false;
409-
}
388+
return false;
410389
}
411390

412391
return classSharing;

visualvm/startup/src/com/sun/tools/visualvm/modules/startup/Bundle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ ACSD_RejectButton=Click to reject license and exit
5353
OpenIDE-Module-Short-Description=VisualVM startup Module
5454

5555
VisualVMStartup_ErrorStartupCaption=Error Starting VisualVM
56-
VisualVMStartup_IncorrectVersionMsg=<html><br><b>You are running VisualVM using an unsupported Java version: {0}.</b><br><br>Please use JDK 8 or JDK 9 or JDK 10 or JDK 11 to run VisualVM. For information<br>about requirements and setup visit https://visualvm.github.io.<br><br><hr><i>Java: {1}<br>JVM: {2}<br>Location: {3}</i><br><br></html>
56+
VisualVMStartup_IncorrectVersionMsg=<html><br><b>You are running VisualVM using an unsupported Java version: {0}.</b><br><br>Please use JDK 8 to JDK 12 to run VisualVM. For information<br>about requirements and setup visit https://visualvm.github.io.<br><br><hr><i>Java: {1}<br>JVM: {2}<br>Location: {3}</i><br><br></html>
5757
VisualVMStartup_JreMsg=<html><br><b>You are running VisualVM using Java Runtime Environment (JRE).</b><br><br>Please use Java Development Kit (JDK) to run VisualVM. For information<br>about requirements and setup visit https://visualvm.github.io.<br><br><hr><i>Java: {0}<br>JVM: {1}<br>Location: {2}</i><br><br></html>

visualvm/startup/src/com/sun/tools/visualvm/modules/startup/VisualVMStartup.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ static synchronized boolean checkEnv() {
6161
if (DISABLE_STARTUP_CHECK) {
6262
System.err.println("Starting with com.sun.tools.visualvm.modules.startup.DisableStartupCheck=true"); // NOI18N
6363
} else {
64-
if (!isJava8or9or10or11()) {
65-
displayError8or9or10or11();
64+
if (!isSupportedJava()) {
65+
displayUnsupportedJavaError();
6666
return false;
6767
} else if (!isJDK()) {
6868
displayErrorJRE();
@@ -73,7 +73,7 @@ static synchronized boolean checkEnv() {
7373
return true;
7474
}
7575

76-
private static void displayError8or9or10or11() {
76+
private static void displayUnsupportedJavaError() {
7777
Utils.setSystemLaF();
7878
JDialog d = StartupDialog.create(ERROR_STARTUP_CAPTION, MessageFormat.format(INCORRECT_VERSION_MSG,
7979
new Object[] { System.getProperty("java.specification.version"), getJavaInfo(), // NOI18N
@@ -90,13 +90,14 @@ private static void displayErrorJRE() {
9090
d.setVisible(true);
9191
}
9292

93-
private static boolean isJava8or9or10or11() {
93+
private static boolean isSupportedJava() {
9494
String javaVersion = System.getProperty("java.specification.version"); // NOI18N
9595
if (javaVersion == null) return false;
9696
return javaVersion.startsWith("1.8") // NOI18N
9797
|| javaVersion.startsWith("1.9") || javaVersion.startsWith("9") // NOI18N
9898
|| javaVersion.startsWith("10") // NOI18N
99-
|| javaVersion.startsWith("11"); // NOI18N
99+
|| javaVersion.startsWith("11") // NOI18N
100+
|| javaVersion.startsWith("12"); // NOI18N
100101
}
101102

102103
private static boolean isJDK() {

0 commit comments

Comments
 (0)