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

java trailing options ignored when using options like -version, -X, -help (can be confusing)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • 10
    • 6
    • tools
    • generic
    • generic

      It appears that the order of the java arguments is critical here. This was surprising. Had me scratching my head for a while.

      bonsai<465> /opt/java/jdk1.6.0/bin/java -Xint -client -version
      java version "1.6.0-rc"
      Java(TM) SE Runtime Environment (build 1.6.0-rc-b98)
      Java HotSpot(TM) Client VM (build 1.6.0-rc-b98, interpreted mode, sharing) <--- OK

      bonsai<466> /opt/java/jdk1.6.0/bin/java -client -version -Xint
      java version "1.6.0-rc"
      Java(TM) SE Runtime Environment (build 1.6.0-rc-b98)
      Java HotSpot(TM) Client VM (build 1.6.0-rc-b98, mixed mode, sharing) <--- Strange, not interpreted? -Xint silently ignored?

      It appears the the second one above has ignored the -Xint option. The Hotspot version string comes directly from the HotSpot VM as far as I can tell.

      Ahh... I see the issue, the -version option appears to terminate some of the option parsing. Not -server and -client, but apparently options that change the VM like -Xint, etc.

      bonsai<467> /opt/java/jdk1.6.0/bin/java -client -Xint -version
      java version "1.6.0-rc"
      Java(TM) SE Runtime Environment (build 1.6.0-rc-b98)
      Java HotSpot(TM) Client VM (build 1.6.0-rc-b98, interpreted mode, sharing) <--- OK

      Maybe this is just a documentation issue, e.g. "Displays version information and exit. Options after -version are ignored, except for -server and -client."?

      Actually it appears that other options do this too, like -X and -help, many options supplied on the command like after -version, -help, or -X are completely ignored.

      Interesting enough, not all the tools behave this way, so we have an inconsistent situation, check out javah:

      bonsai<59> javah -version -junk
      Error: -junk is an illegal argument

      Usage: javah [options] <classes>

      where [options] include:

              -help Print this help message and exit
              -classpath <path> Path from which to load classes
              -bootclasspath <path> Path from which to load bootstrap classes
              -d <dir> Output directory
              -o <file> Output file (only one of -d or -o may be used)
              -jni Generate JNI-style header file (default)
              -version Print version information
              -verbose Enable verbose output
              -force Always write output files

      <classes> are specified with their fully qualified names (for
      instance, java.lang.Object).

      But 'java' is silent:

      bonsai<60> java -version -junk
      java version "1.5.0_06"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
      Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)

      Seems like we should be consistent at least, but this is a minor issue.

      -kto

            ksrini Kumar Srinivasan
            ohair Kelly Ohair (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: