JDK-8221528 : Introduce compatibility mode with VM option -XX:AllowRedefinitionToAddOrDeleteMethods
  • Type: CSR
  • Component: hotspot
  • Sub-Component: jvmti
  • Priority: P2
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 13
  • Submitted: 2019-03-27
  • Updated: 2019-05-06
  • Resolved: 2019-04-08
Related Reports
CSR :  
Description
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.



Comments
Without wanting to bikeshed, we're not enabling all violations of the JVMTI spec, so I don't really agree with the suggested alternate name.
09-04-2019

Moving to Approved.
08-04-2019

I do not see well argumented objections against this CSR. It feels that it can be finalized now.
05-04-2019

Right, this change shouldn't involved spec changes. It was a mistake in JDK 6 to allow this and trying to specify this behavior now has huge implications that go way beyond the JVM TI spec.
04-04-2019

I think adding a flag to toggle the behavior is fine, but since this change is being made, I think the spec should be updated to see the capability in question is optional, but "deprecated for removal," use API terminology. Moving to Provisional.
28-03-2019

This is right, thought I've set "low" myself. :)
27-03-2019

I changed the compatibility to "low" because I think Eclipse users are going to have to add it to their command lines.
27-03-2019