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

Unsupported GC options passed in JAVA_TOOL_OPTIONS are silently ignored

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 16
    • 11, 15, 16
    • hotspot
    • gc
    • b17

      We have actually observed it with JDK 11u jobs trying to run ZGC on Windows. But the issue is not ZGC-specific, and it affects head jdk as well.

      Steps to reproduce:

      1. Build current jdk with --with-jvm-features=-zgc

      2. Do: export JAVA_TOOL_OPTIONS="-XX:+UseZGC"

      3. Run -version, observing silent fallback to G1:

      $ jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -Xlog:gc -version
      Picked up JAVA_TOOL_OPTIONS: -XX:+UseZGC
      [0.036s][info][gc] Using G1

      4. Run with explicit flags:

      ~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -Xlog:gc -XX:+UseZGC -version
      Picked up JAVA_TOOL_OPTIONS: -XX:+UseZGC
      Error occurred during initialization of VM
      Option -XX:+UseZGC not supported

      I think that happens because GCConfig checks only for FLAG_IS_CMDLINE, which is only from cmdline-originated flags. In this case, the flag comes from the environment variable. Maybe checking for !FLAG_IS_DEFAULT is better, as it captures all non-default origins.

            shade Aleksey Shipilev
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: