Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8355808

Use a single copy of ignoreUnrecognized in arguments.cpp

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • None
    • hotspot

      Summary:

      Replace multiple occurrences of "ignoreUnrecognized" with a single global variable

      Background:

      Argument parsing in argument.cpp is very convoluted. Here's what it does in handling IgnoreUnrecognizedVMOptions:

      [1] Scan all options specified provided by the following 4 sources, in this order:

           - JAVA_TOOL_OPTIONS env var
           - _JAVA_OPTIONS env var
           - options in the /java.base/jdk/internal/vm/options resource, if present
           - arguments passed to JNI_CreateJavaVM (from the java launcher, etc)

          (a) Find the last instance of -XX:[+-]IgnoreUnrecognizedVMOptions. Use that to decide the value of a boolean ignoreUnrecognized. If no such option is found, ignoreUnrecognized is false.

          (b) Find the last instance of -XX:Flags=flags_file, if present

      [2] If flags_file is specified, parse all options from this file.

      [3] Parse all options in the 4 sources listed in [1] (but strangely in a different order ....).

      If an unrecognized option is found in [2] or [3], report an error ONLY if ignoreUnrecognized is false.

      =============
      Note: IgnoreUnrecognizedVMOptions is allowed to be used in flags_file, however, it has NO effect. Example:

      $ echo "+IgnoreUnrecognizedVMOptions" > flags.txt
      $ java -XX:Flags=flags.txt -XX:Foo=1 --version
      Unrecognized VM option 'Foo=1'
      Error: Could not create the Java Virtual Machine.
      Error: A fatal exception has occurred. Program will exit.

      (This behavior is unspecified, and this RFE will NOT change this behavior)
      =============


      Proposal:

      arguments.cpp stores ignoreUnrecognized in multiple variables, but they all have the exact same value. The value of these variables never change afterwards. Therefore, we can consolidate them into a single global.

            iklam Ioi Lam
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: