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

Introduce compatibility mode with VM option -XX:AllowRedefinitionToAddOrDeleteMethods

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P2 P2
    • 13
    • hotspot
    • None
    • behavioral
    • low
    • The new VM option is explicitly introduced to give customers some time to remove the dependency on old unspecified behavior. It should help them in transition back to the specified behavior.
    • add/remove/modify command line option

      Summary

      Introduce compatibility mode with new command-line VM option -XX:{+|-}AllowRedefinitionToAddOrDeleteMethods.

      The option will enable old behavior and allow the JVM TI RedefineClasses and RetransformClasses to add/delete private static and private final instance methods in the new class versions.

      Problem

      Now, implementation of the JVMTI RedefineClasses and RetransformClasses allows to add/delete private static and private final instance methods in the new class versions.

      It means that current implementation does not follow the JVM TI spec which explicitly states:

      "The redefinition must not add, remove or rename fields or methods, change the signatures of methods, change modifiers, or change inheritance."

      For details, please, see the spec:

      https://docs.oracle.com/en/java/javase/12/docs/specs/jvmti.html#RedefineClasses

      https://docs.oracle.com/en/java/javase/12/docs/specs/jvmti.html#RetransformClasses

      The decision was made to align the implementation with the spec. For reference, please, see the https://bugs.openjdk.java.net/browse/JDK-8192936.

      This decision is going to cause some inconveniences to the customers.

      Solution

      The solution is to introduce a compatibility mode with new command-line VM option -XX:{+|-}AllowRedefinitionToAddOrDeleteMethods. New option will enable old behavior and allow the JVM TI RedefineClasses and RetransformClasses to add/delete private static and private final instance methods in the new class versions.

      Without this option the old behavior will be disabled.

      This option is deprecated right away. The plan is to keep it for a couple of releases to allow customers (tool vendors) to remove dependency on old behavior from their tools.

      Specification

      New command-line VM option is: -XX:{+|-}AllowRedefinitionToAddOrDeleteMethods . The option -XX:+AllowRedefinitionToAddOrDeleteMethods sets the VM flag "AllowRedefinitionToAddOrDeleteMethods" to "true" (to allow the JVM TI RedefineClasses and RetransformClasses to add/delete private static and private final instance methods in the new class versions).

      The option -XX:-AllowRedefinitionToAddOrDeleteMethods sets the VM flag "AllowRedefinitionToAddOrDeleteMethods" to "false" (to disallow the JVM TI RedefineClasses and RetransformClasses to add/delete private static and private final instance methods in the new class versions).

      The default value of the flag "AllowRedefinitionToAddOrDeleteMethods" is "false". Without this option the old behavior will be disabled.

            sspitsyn Serguei Spitsyn
            lkuskov Leonid Kuskov
            Alan Bateman, Coleen Phillimore, David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: