Skip to content

Commit 76dcac7

Browse files
committed
Merge branch 'master' into graal
2 parents a279157 + ecb6996 commit 76dcac7

File tree

29 files changed

+156
-123
lines changed

29 files changed

+156
-123
lines changed

visualvm/application/nbproject/project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<compile-dependency/>
1313
<run-dependency>
1414
<release-version>0</release-version>
15-
<specification-version>1.5</specification-version>
15+
<specification-version>1.7</specification-version>
1616
</run-dependency>
1717
</dependency>
1818
<dependency>

visualvm/application/src/org/graalvm/visualvm/application/ApplicationDescriptor.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@
4343
public class ApplicationDescriptor extends DataSourceDescriptor<Application> {
4444

4545
private static final String DISPLAY_NAME_PROPERTY = "-Dvisualvm.display.name="; // NOI18N
46-
46+
47+
private static final String pid_PARAM = "%pid"; // NOI18N
48+
private static final String PID_PARAM = "%PID"; // NOI18N
49+
50+
4751
private String name;
4852

4953
/**
@@ -88,7 +92,7 @@ public void propertyChange(PropertyChangeEvent evt) {
8892
} else {
8993
// Descriptor doesn't support renaming, set name for overriden getName()
9094
String oldName = name;
91-
name = createGenericName(application, type.getName());
95+
name = formatName(createGenericName(application, type.getName()));
9296
PropertyChangeSupport pcs = ApplicationDescriptor.this.getChangeSupport();
9397
pcs.firePropertyChange(PROPERTY_NAME, oldName, name);
9498
}
@@ -152,6 +156,21 @@ private static String resolveCustomName(Application application) {
152156
return null;
153157
}
154158

159+
protected String formatName(String namePattern) {
160+
if (namePattern == null) return null;
161+
162+
String formatted = namePattern;
163+
164+
Integer pid = namePattern.contains(pid_PARAM) || namePattern.contains(PID_PARAM) ? getDataSource().getPid() : null;
165+
if (pid != null) {
166+
boolean unknownPid = Application.UNKNOWN_PID == pid;
167+
formatted = formatted.replace(pid_PARAM, unknownPid ? "unknown" : pid.toString()); // NOI18N
168+
formatted = formatted.replace(PID_PARAM, unknownPid ? " (unknown pid) " : " (pid " + pid.toString() + ") ").trim(); // NOI18N
169+
}
170+
171+
return formatted;
172+
}
173+
155174
private static String createGenericName(Application application, String nameBase) {
156175
int pid = application.getPid();
157176
String id = Application.CURRENT_APPLICATION.getPid() == pid ||

visualvm/core/src/org/graalvm/visualvm/core/datasource/descriptor/DataSourceDescriptor.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public DataSourceDescriptor(X ds, String n, String desc, Image ic, int pos, int
123123

124124
dataSource = ds;
125125
changeSupport = new PropertyChangeSupport(dataSource);
126-
name = n;
126+
name = formatName(n); // NOTE: called after dataSource is set, should work fine in subclasses with overriden formatName()
127127
description = desc;
128128
icon = ic;
129129
preferredPosition = pos;
@@ -158,9 +158,9 @@ public void setName(String newName) {
158158
if (!supportsRename()) throw new UnsupportedOperationException("Rename not supported for this descriptor"); // NOI18N
159159
if (newName == null) throw new IllegalArgumentException("Name cannot be null"); // NOI18N
160160
String oldName = name;
161-
name = newName;
161+
name = formatName(newName);
162162
getDataSource().getStorage().setCustomProperties(new String[] { PROPERTY_NAME }, new String[] { newName });
163-
getChangeSupport().firePropertyChange(PROPERTY_NAME, oldName, newName);
163+
getChangeSupport().firePropertyChange(PROPERTY_NAME, oldName, name);
164164
}
165165

166166
/**
@@ -172,6 +172,18 @@ public String getName() {
172172
return name;
173173
}
174174

175+
/**
176+
* Enables subclasses to process (format) the provided name of the DataSource.
177+
*
178+
* @param namePattern name of the DataSource to be processed (formatted)
179+
* @return processed (formatted) name of the DataSource.
180+
*
181+
* @since VisualVM 1.4.3
182+
*/
183+
protected String formatName(String namePattern) {
184+
return namePattern;
185+
}
186+
175187
/**
176188
* Returns description of the DataSource.
177189
*

visualvm/jmx/src/org/graalvm/visualvm/jmx/CredentialsProvider.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
package org.graalvm.visualvm.jmx;
2727

28+
import java.util.Arrays;
2829
import org.graalvm.visualvm.application.Application;
2930
import org.graalvm.visualvm.core.datasource.Storage;
3031
import org.graalvm.visualvm.core.datasupport.Utils;
@@ -110,7 +111,7 @@ public Custom(String username, char[] password, boolean persistent) {
110111

111112

112113
public Map<String, ?> getEnvironment(Application application, Storage storage) {
113-
return createMap(user, pword);
114+
return createMap(user, pword == null ? null : Arrays.copyOf(pword, pword.length));
114115
}
115116

116117
public String getEnvironmentId(Storage storage) {
@@ -145,7 +146,8 @@ public static class Persistent extends CredentialsProvider {
145146

146147
public Map<String, ?> getEnvironment(Application application, Storage storage) {
147148
String user = storage.getCustomProperty(PROPERTY_USER);
148-
char[] pword = storage.getCustomProperty(PROPERTY_PWORD).toCharArray();
149+
char[] pword = storage.getCustomProperty(PROPERTY_PWORD) == null ?
150+
null : storage.getCustomProperty(PROPERTY_PWORD).toCharArray();
149151
return createMap(user, pword);
150152
}
151153

@@ -162,8 +164,8 @@ String getUsername(Storage storage) { return storage.getCustomProperty(
162164
PROPERTY_USER); }
163165

164166
boolean hasPassword(Storage storage) {
165-
String pword = storage.getCustomProperty(PROPERTY_PWORD);
166-
return pword != null && pword.length() > 0;
167+
if (storage.getCustomProperty(PROPERTY_PWORD) == null) return false;
168+
return storage.getCustomProperty(PROPERTY_PWORD).length() > 0;
167169
}
168170

169171
boolean isPersistent(Storage storage) {
@@ -175,19 +177,25 @@ boolean isPersistent(Storage storage) {
175177

176178
// --- Private implementation ----------------------------------------------
177179

180+
// NOTE: clears the pword parameter!
178181
private static Map<String, ?> createMap(String username, char[] pword) {
179182
Map map = new HashMap();
180183

181-
if (username != null && !username.isEmpty())
182-
map.put(JMXConnector.CREDENTIALS, new String[] { username, new String(decodePassword(pword)) });
184+
if (username != null && !username.isEmpty()) {
185+
map.put(JMXConnector.CREDENTIALS, new String[] { username, pword == null ? null : new String(decodePassword(pword)) });
186+
} else {
187+
if (pword != null) Arrays.fill(pword, (char)0);
188+
}
183189

184190
return map;
185191
}
186192

193+
// NOTE: clears the pword parameter!
187194
private static char[] encodePassword(char[] pword) {
188195
return pword == null ? null : Utils.encodePassword(pword);
189196
}
190197

198+
// NOTE: clears the pword parameter!
191199
private static char[] decodePassword(char[] pword) {
192200
return pword == null ? null : Utils.decodePassword(pword);
193201
}

visualvm/jvmstat/src/org/graalvm/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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Manifest-Version: 1.0
22
OpenIDE-Module: org.graalvm.visualvm.lib.common/1
33
OpenIDE-Module-Localizing-Bundle: org/graalvm/visualvm/lib/common/Bundle.properties
4-
OpenIDE-Module-Specification-Version: 1.50
4+
OpenIDE-Module-Specification-Version: 1.51
55
OpenIDE-Module-Needs: org.graalvm.visualvm.lib.common.Profiler
66

visualvm/libs.profiler/lib.profiler.common/nbproject/project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ made subject to such option by the copyright holder.
5656
<compile-dependency/>
5757
<run-dependency>
5858
<release-version>1</release-version>
59-
<specification-version>1.112</specification-version>
59+
<specification-version>1.114</specification-version>
6060
</run-dependency>
6161
</dependency>
6262
<dependency>

visualvm/libs.profiler/lib.profiler.common/src/org/graalvm/visualvm/lib/common/integration/Bundle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ IntegrationUtils_PlatformJava80=Java SE 8.0
4848
IntegrationUtils_PlatformJava90=Java SE 9.0
4949
IntegrationUtils_PlatformJava100=Java SE 10.0
5050
IntegrationUtils_PlatformJava110=Java SE 11
51+
IntegrationUtils_PlatformJava120=Java SE 12
5152
IntegrationUtils_PlatformJavaCvm=CVM
5253
IntegrationUtils_PlatformWindowsOs=Windows, 32bit JVM
5354
IntegrationUtils_PlatformWindowsAmd64Os=Windows, 64bit JVM
@@ -83,6 +84,7 @@ IntegrationUtils_Jdk80Name=Java SE 8 (JRE or JDK)
8384
IntegrationUtils_Jdk90Name=Java SE 9 (JRE or JDK)
8485
IntegrationUtils_Jdk100Name=Java SE 10 (JRE or JDK)
8586
IntegrationUtils_Jdk110Name=Java SE 11 (JRE or JDK)
87+
IntegrationUtils_Jdk120Name=Java SE 12 (JRE or JDK)
8688
IntegrationUtils_JdkCvmName=CVM
8789
IntegrationUtils_RemoteString=remote
8890
# HTML-formatted

visualvm/libs.profiler/lib.profiler.common/src/org/graalvm/visualvm/lib/common/integration/IntegrationUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public class IntegrationUtils {
7474
public static final String PLATFORM_JAVA_90 = messages.getString("IntegrationUtils_PlatformJava90"); // NOI18N
7575
public static final String PLATFORM_JAVA_100 = messages.getString("IntegrationUtils_PlatformJava100"); // NOI18N
7676
public static final String PLATFORM_JAVA_110 = messages.getString("IntegrationUtils_PlatformJava110"); // NOI18N
77+
public static final String PLATFORM_JAVA_120 = messages.getString("IntegrationUtils_PlatformJava120"); // NOI18N
7778
public static final String PLATFORM_JAVA_CVM = messages.getString("IntegrationUtils_PlatformJavaCvm"); // NOI18N
7879
public static final String PLATFORM_WINDOWS_OS = messages.getString("IntegrationUtils_PlatformWindowsOs"); // NOI18N
7980
public static final String PLATFORM_WINDOWS_AMD64_OS = messages.getString("IntegrationUtils_PlatformWindowsAmd64Os"); // NOI18N
@@ -102,6 +103,7 @@ public class IntegrationUtils {
102103
private static final String JDK_90_NAME = messages.getString("IntegrationUtils_Jdk90Name"); // NOI18N
103104
private static final String JDK_100_NAME = messages.getString("IntegrationUtils_Jdk100Name"); // NOI18N
104105
private static final String JDK_110_NAME = messages.getString("IntegrationUtils_Jdk110Name"); // NOI18N
106+
private static final String JDK_120_NAME = messages.getString("IntegrationUtils_Jdk120Name"); // NOI18N
105107
private static final String JDK_CVM_NAME = messages.getString("IntegrationUtils_JdkCvmName"); // NOI18N
106108
private static final String HTML_REMOTE_STRING = "&lt;" + messages.getString("IntegrationUtils_RemoteString") + "&gt;"; // NOI18N
107109
private static final String EXPORT_SETENV_MESSAGE = messages.getString("IntegrationUtils_ExportSetenvMessage"); // NOI18N
@@ -277,6 +279,8 @@ public static String getJavaPlatformFromJavaVersionString(String javaVersionStri
277279
return PLATFORM_JAVA_100;
278280
} else if (javaVersionString.equals(CommonConstants.JDK_110_STRING)) {
279281
return PLATFORM_JAVA_110;
282+
} else if (javaVersionString.equals(CommonConstants.JDK_120_STRING)) {
283+
return PLATFORM_JAVA_120;
280284
} else if (javaVersionString.equals(CommonConstants.JDK_CVM_STRING)) {
281285
return PLATFORM_JAVA_CVM;
282286
}
@@ -344,6 +348,8 @@ public static String getJavaPlatformName(String javaPlatform) {
344348
return JDK_100_NAME;
345349
} else if (javaPlatform.equals(PLATFORM_JAVA_110)) {
346350
return JDK_110_NAME;
351+
} else if (javaPlatform.equals(PLATFORM_JAVA_120)) {
352+
return JDK_120_NAME;
347353
} else if (javaPlatform.equals(PLATFORM_JAVA_CVM)) {
348354
return JDK_CVM_NAME;
349355
}
@@ -411,6 +417,8 @@ public static String getLocalJavaPlatform() {
411417
return PLATFORM_JAVA_100;
412418
} else if (jdkVersion == Platform.JDK_110) {
413419
return PLATFORM_JAVA_110;
420+
} else if (jdkVersion == Platform.JDK_120) {
421+
return PLATFORM_JAVA_120;
414422
}
415423

416424
return null;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Manifest-Version: 1.0
22
OpenIDE-Module: org.graalvm.visualvm.lib.jfluid/1
33
OpenIDE-Module-Localizing-Bundle: org/graalvm/visualvm/lib/jfluid/Bundle.properties
4-
OpenIDE-Module-Specification-Version: 1.113
4+
OpenIDE-Module-Specification-Version: 1.114
55

0 commit comments

Comments
 (0)