--- icedtea-3.8.0/openjdk/jdk/src/share/bin/java.c 2018-09-18 09:11:59.480109603 +0200 +++ icedtea-3.8.0/openjdk/jdk/src/share/bin/java.c 2018-09-18 09:15:55.665368268 +0200 @@ -660,16 +660,25 @@ * arguments are for the application (i.e. the main class name, or * the -jar argument). */ - if ((i > 0 && *arg != '-') + if (i > 0) { + char *prev = argv[i - 1]; + // skip non-dash arg preceded by class path specifiers + if (*arg != '-' && + ((JLI_StrCmp(prev, "-cp") == 0 + || JLI_StrCmp(prev, "-classpath") == 0))) { + continue; + } + + 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 - ) { + || JLI_StrCmp(arg, "-X") == 0) { return; } + } /* * The following case checks for "-XX:NativeMemoryTracking=value". * If value is non null, an environmental variable set to this value --- icedtea-3.8.0/openjdk/jdk/test/tools/launcher/TestSpecialArgs.java 2018-09-18 09:11:59.320108768 +0200 +++ icedtea-3.8.0/openjdk/jdk/test/tools/launcher/TestSpecialArgs.java 2018-09-18 09:15:55.665368268 +0200 @@ -23,7 +23,7 @@ /* * @test - * @bug 7124089 7131021 8042469 8066185 + * @bug 7124089 7131021 8042469 8066185 8074373 * @summary Checks for Launcher special flags, such as MacOSX specific flags, * and JVM NativeMemoryTracking flags. * @compile -XDignore.symbol.file TestSpecialArgs.java EnvironmentVariables.java @@ -270,6 +270,16 @@ tr = doExec(envMap, javaCmd, "Foo", "-XX:NativeMemoryTracking=summary"); 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 // resolution is performed by the JVM. tr = doExec(javaCmd, "AbsentClass", "-XX:NativeMemoryTracking=summary"); @@ -277,6 +287,14 @@ throw new RuntimeException("Test Fails"); } } + + 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) { if (!tr.isOK()) {