提交 fae01be3 编写于 作者: D dbuck

8074373: NMT is not enabled if NMT option is specified after class path specifiers

Reviewed-by: dholmes
上级 22489704
/* /*
* Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -660,15 +660,24 @@ SetJvmEnvironment(int argc, char **argv) { ...@@ -660,15 +660,24 @@ SetJvmEnvironment(int argc, char **argv) {
* arguments are for the application (i.e. the main class name, or * arguments are for the application (i.e. the main class name, or
* the -jar argument). * the -jar argument).
*/ */
if ((i > 0 && *arg != '-') if (i > 0) {
|| JLI_StrCmp(arg, "-version") == 0 char *prev = argv[i - 1];
|| JLI_StrCmp(arg, "-fullversion") == 0 // skip non-dash arg preceded by class path specifiers
|| JLI_StrCmp(arg, "-help") == 0 if (*arg != '-' &&
|| JLI_StrCmp(arg, "-?") == 0 ((JLI_StrCmp(prev, "-cp") == 0
|| JLI_StrCmp(arg, "-jar") == 0 || JLI_StrCmp(prev, "-classpath") == 0))) {
|| JLI_StrCmp(arg, "-X") == 0 continue;
) { }
return;
if (*arg != '-'
|| JLI_StrCmp(arg, "-version") == 0
|| JLI_StrCmp(arg, "-fullversion") == 0
|| JLI_StrCmp(arg, "-help") == 0
|| JLI_StrCmp(arg, "-?") == 0
|| JLI_StrCmp(arg, "-jar") == 0
|| JLI_StrCmp(arg, "-X") == 0) {
return;
}
} }
/* /*
* The following case checks for "-XX:NativeMemoryTracking=value". * The following case checks for "-XX:NativeMemoryTracking=value".
......
/* /*
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 7124089 7131021 8042469 8066185 * @bug 7124089 7131021 8042469 8066185 8074373
* @summary Checks for Launcher special flags, such as MacOSX specific flags, * @summary Checks for Launcher special flags, such as MacOSX specific flags,
* and JVM NativeMemoryTracking flags. * and JVM NativeMemoryTracking flags.
* @compile -XDignore.symbol.file TestSpecialArgs.java EnvironmentVariables.java * @compile -XDignore.symbol.file TestSpecialArgs.java EnvironmentVariables.java
...@@ -270,6 +270,16 @@ public class TestSpecialArgs extends TestHelper { ...@@ -270,6 +270,16 @@ public class TestSpecialArgs extends TestHelper {
tr = doExec(envMap, javaCmd, "Foo", "-XX:NativeMemoryTracking=summary"); tr = doExec(envMap, javaCmd, "Foo", "-XX:NativeMemoryTracking=summary");
checkTestResult(tr); checkTestResult(tr);
// should accept with no warnings
tr = doExec(javaCmd, "-cp", jarFile.getName(),
"-XX:NativeMemoryTracking=summary", "Foo");
ensureNoWarnings(tr);
// should accept with no warnings
tr = doExec(javaCmd, "-classpath", jarFile.getName(),
"-XX:NativeMemoryTracking=summary", "Foo");
ensureNoWarnings(tr);
// make sure a missing class is handled correctly, because the class // make sure a missing class is handled correctly, because the class
// resolution is performed by the JVM. // resolution is performed by the JVM.
tr = doExec(javaCmd, "AbsentClass", "-XX:NativeMemoryTracking=summary"); tr = doExec(javaCmd, "AbsentClass", "-XX:NativeMemoryTracking=summary");
...@@ -278,6 +288,14 @@ public class TestSpecialArgs extends TestHelper { ...@@ -278,6 +288,14 @@ public class TestSpecialArgs extends TestHelper {
} }
} }
void ensureNoWarnings(TestResult tr) {
checkTestResult(tr);
if (tr.contains("warning: Native Memory Tracking")) {
System.err.println(tr.toString());
throw new RuntimeException("Test Fails");
}
}
void checkTestResult(TestResult tr) { void checkTestResult(TestResult tr) {
if (!tr.isOK()) { if (!tr.isOK()) {
System.err.println(tr.toString()); System.err.println(tr.toString());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册