Skip to content

Commit 2f3dc69

Browse files
committed
GH-103 - strip module name from first commandline argument
1 parent 3eeefa0 commit 2f3dc69

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.jar.Attributes;
3535
import java.util.jar.JarFile;
3636
import java.util.logging.Logger;
37+
import java.util.regex.Pattern;
3738
import org.openide.util.NbBundle;
3839

3940
/**
@@ -50,6 +51,8 @@ public abstract class JvmJvmstatModel extends Model {
5051

5152
private static final String JAR_SUFFIX = ".jar"; // NOI18N
5253

54+
private static final Pattern MODULE_MAIN_CLASS_PATTERN = Pattern.compile("^(\\w+\\.)*\\w+/(\\w+\\.)+\\w+$");
55+
5356
protected Application application;
5457
protected JvmstatModel jvmstat;
5558
protected MonitoredValue loadedClasses;
@@ -253,6 +256,8 @@ public String getMainClass() {
253256
if (index != -1) {
254257
mainClassName = mainClassName.substring(index + 1);
255258
}
259+
} else if (MODULE_MAIN_CLASS_PATTERN.matcher(mainClassName).find()) {
260+
return mainClassName.substring(mainClassName.indexOf('/')+1);
256261
}
257262
mainClassName = mainClassName.replace('\\', '/').replace('/', '.');
258263
return mainClassName;

0 commit comments

Comments
 (0)