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

Print a message to stderr when -XX:AOTMode=on is specified

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • hotspot

      -XX:AOTMode=on provides a quick way to diagnose certain kinds of problems with the AOT cache.

      Here's one example:

      java -XX:AOTMode=on -XX:AOTCache=app.aot $VMARGS -cp app.jar App

      If $VMARGS contains an option that's not compatible with the AOT cache (e.g., as described in the "Consistency of training and subsequent runs" section of https://openjdk.org/jeps/483), the JVM will print an error message and exit.

      It's not recommended to use -XX:AOTMode=on in production environments, as incompatible VM options may be adopted without the knowledge of the application, leading to unexpected exit at application start. For example:

      - A cloud provide could inject VM options into your Java program's start-up options
      - The JVM could choose certain options ergonomically depending on available system resources

      To make sure that users are aware of the risks of -XX:AOTMode=on, the JVM should print the following message to stderr when this option is specified:

      "-XX:AOTMode=on is specified. The JVM may exit if there are VM options that are incompatible with the AOT cache"

      We have precedents for such stderr output when a potential risk is detected. For example, the JVM informs the user of the fact that VM options are being picked up from the environment variable JAVA_TOOL_OPTIONS (which could have security implications).

      $ env JAVA_TOOL_OPTIONS=-Xint java --version
      Picked up JAVA_TOOL_OPTIONS: -Xint
      openjdk 21.0.7 2025-04-15
      OpenJDK Runtime Environment (build 21.0.7+6-Ubuntu-0ubuntu124.04)
      OpenJDK 64-Bit Server VM (build 21.0.7+6-Ubuntu-0ubuntu124.04, interpreted mode, sharing)

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

              Created:
              Updated: