jdk/src/java.base/share/native/libjli/java.c
changeset 29114 a9b39a645e85
parent 28771 2885fb2e1002
child 29373 8f41a04d1a02
--- a/jdk/src/java.base/share/native/libjli/java.c	Wed Feb 25 14:30:02 2015 +0100
+++ b/jdk/src/java.base/share/native/libjli/java.c	Wed Feb 25 06:21:55 2015 -0800
@@ -651,9 +651,26 @@
 SetJvmEnvironment(int argc, char **argv) {
 
     static const char*  NMT_Env_Name    = "NMT_LEVEL_";
-
     int i;
     for (i = 0; i < argc; i++) {
+        char *arg = argv[i];
+        /*
+         * Since this must be a VM flag we stop processing once we see
+         * an argument the launcher would not have processed beyond (such
+         * as -version or -h), or an argument that indicates the following
+         * arguments are for the application (i.e. the main class name, or
+         * the -jar argument).
+         */
+        if ((i > 0 && *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".
          * If value is non null, an environmental variable set to this value
@@ -661,7 +678,6 @@
          * The argument is passed to the JVM, which will check validity.
          * The JVM is responsible for removing the env variable.
          */
-        char *arg = argv[i];
         if (JLI_StrCCmp(arg, "-XX:NativeMemoryTracking=") == 0) {
             int retval;
             // get what follows this parameter, include "="