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

Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 12
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      We haven't seen any users outside Oracle using a java (and native) agent during CDS dumping.
    • Interface Kind:
      add/remove/modify command line option
    • Scope:
      JDK

      Description

      Summary

      Add the AllowArchvingWithJavaAgent diganostic vm option to allow running of java agent(s) during CDS dumping.

      Problem

      Sometimes running a Java agent during CDS dumping is useful for testing purposes such as provoking GC activities during dumping. However, if the Java agent rewrite classes during dump time, the resulting CDS archive is not suitable for production environment, as it may contain classes with unexpected contents.

      Solution

      Allow java agent during CDS dumping only if the user specifies the AllowArchvingWithJavaAgent diagnostic flag in the command line.

      Specification

      The AllowArchvingWithJavaAgent flag must be enabled using the UnlockDiagnosticVMOptions flag as follows:

       -XX:+UnlockDiagnosticVMOptions -XX:+AllowArchvingWithJavaAgent

      If the user specifies a java agent without the diagnostic flag during CDS dumping, VM will exit with the following error message:

      Error occurred during CDS dumping
      Must enable AllowArchivingWithJavaAgent in order to run Java agent during CDS dumping

      If the user specifies the diagnostic flag with a java agent during CDS dumping, the following warning will be printed:

      Java HotSpot(TM) 64-Bit Server VM warning: This archive was created with
      AllowArchivingWithJavaAgent. It should be used for testing purposes only and
      should not be used in a production environment

      The above warning will also be printed during run time if the -XX:+AllowArchvingWithJavaAgent flag is specified.

      The diagnostic flag will be stored in the CDS archive header. If the CDS archive is created with the diagnostic flag and during run time the diagnostic flag is not specified.

      1) if -Xshare:on is specified, vm will exit with the following error:

      An error has occurred while processing the shared archive file.
      The setting of the AllowArchivingWithJavaAgent is different from
      the setting in the shared archive.

      2) if -Xshare:auto is specified together with -Xlog:cds=info, the following info message will be printed, and the VM will continue execution without loading the CDS archive.

      [0.021s][info][cds       ] UseSharedSpaces: The setting of the 
      AllowArchivingWithJavaAgent is different from the setting in the shared archive.

      The -XX:+AllowArchvingWithJavaAgent should only be used for testing purpose only.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ccheung Calvin Cheung
              Reporter:
              ccheung Calvin Cheung
              Reviewed By:
              Ioi Lam, Jiangli Zhou
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: