Skip to content

8358890: VM option -XX:AllowRedefinitionToAddDeleteMethods should be obsoleted then expired #26232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

sspitsyn
Copy link
Contributor

@sspitsyn sspitsyn commented Jul 10, 2025

The VM option -XX:AllowRedefinitionToAddDeleteMethods was added in JDK 13 as a temporary backward compatibility flag under JDK-8192936 and was immediately marked as Deprecate. The fix is to obsolete this option in JDK 26 and expire in JDK 27.

TBD: Need to submit a related CSR.

There are two concerns which may require some negotiation with the Runtime (@coleenp @dcubed-ojdk @dholmes-ora) and SQE (@lmesnik) teams:

  • Class redefinition/retransformation can impact lambda expressions which are supported with private methods
  • Many tests depend on this VM option and are being removed. I'm not sure if it is okay to completely remove those e may want another way to handle this (e.g. problem-listing the impacted tests for now).

Testing:

  • mach5 tiers 1-6 are good
  • may need to run mach5 tiers > 6

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8358890: VM option -XX:AllowRedefinitionToAddDeleteMethods should be obsoleted then expired (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26232/head:pull/26232
$ git checkout pull/26232

Update a local copy of the PR:
$ git checkout pull/26232
$ git pull https://git.openjdk.org/jdk.git pull/26232/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26232

View PR using the GUI difftool:
$ git pr show -t 26232

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26232.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 10, 2025

👋 Welcome back sspitsyn! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jul 10, 2025

@sspitsyn This change is no longer ready for integration - check the PR body for details.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 10, 2025
@openjdk
Copy link

openjdk bot commented Jul 10, 2025

@sspitsyn The following labels will be automatically applied to this pull request:

  • core-libs
  • hotspot
  • serviceability

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@mlbridge
Copy link

mlbridge bot commented Jul 10, 2025

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This involved a lot more code than I had envisaged.

The test situation seems problematic as it suggests to me that we have required functionality (redefine a method containing a lambda expression) that is not possible without the flag. And it seems this flag is also being used in the wild e.g.

https://blog.picnic.nl/embracing-java-17-heres-what-we-learned-69779d95fdf2

As of Java 16, JDK internals are strongly encapsulated by default (JEP 396). These and other changes mean that some dependencies now require additional JVM flags such as --add-opens and -XX:+AllowRedefinitionToAddDeleteMethods to function properly. We updated our shared build system such that teams can configure these flags in a single place, ensuring that test and production runtimes remain in sync.

With more info in reactor/BlockHound#33

So I am quite concerned that this "workaround" has become entrenched.

@@ -4114,18 +4050,14 @@ void VM_RedefineClasses::flush_dependent_code() {
JvmtiExport::set_all_dependencies_are_recorded(true);
}

void VM_RedefineClasses::compute_added_deleted_matching_methods() {
void VM_RedefineClasses::compute_matching_methods() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see that this method actually still does anything useful. ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it does:

  • has asserts on added/deleted methods
  • collects _matching_old_methods and _matching_new_methods

It seems that the _old_methods is same as _matching_old_methods and _new_methods is same as _matching_new_methods. But I do not want to make a deeper refactoring at this point until we have a decision on the full removal of added/deleted methods support. It feels like we may need to keep some support for lambda expression changes in class redefinitions/retransformations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this does now is that the redefined class can have matching method names in a different order because of the signature. So this sorts this out. I don't know why we don't sort methods according to name and signature when creating the klass though. That would make this just a method to check that the methods match.

@AlanBateman
Copy link
Contributor

/label remove core-libs

@openjdk
Copy link

openjdk bot commented Jul 10, 2025

@AlanBateman
The core-libs label was successfully removed.

@sspitsyn
Copy link
Contributor Author

So I am quite concerned that this "workaround" has become entrenched.

Thank you for the comments and concern! I'll check what can be done here. Need to investigate it a little bit.

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice to be able to clean this code out but I also think it's being used. Was there another mechanism that we suggest for instrumenting native methods? And there was code once to prefix native methods so this adding private method mechanism worked.

Edit: I seem to remember TransferNativeFunctionRegistration code was for instrumenting native methods that used adding and deleting static private methods. So maybe this should be removed also as a follow-up?

@@ -4114,18 +4050,14 @@ void VM_RedefineClasses::flush_dependent_code() {
JvmtiExport::set_all_dependencies_are_recorded(true);
}

void VM_RedefineClasses::compute_added_deleted_matching_methods() {
void VM_RedefineClasses::compute_matching_methods() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this does now is that the redefined class can have matching method names in a different order because of the signature. So this sorts this out. I don't know why we don't sort methods according to name and signature when creating the klass though. That would make this just a method to check that the methods match.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 11, 2025
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jul 11, 2025
@sspitsyn
Copy link
Contributor Author

It's nice to be able to clean this code out but I also think it's being used. Was there another mechanism that we suggest for instrumenting native methods? And there was code once to prefix native methods so this adding private method mechanism worked.

Edit: I seem to remember TransferNativeFunctionRegistration code was for instrumenting native methods that used adding and deleting static private methods. So maybe this should be removed also as a follow-up?

In fact, I have a big doubt we really want to get rid of this approach to instrument native methods calls.
The same doubt is about lambda expressions change support. It feels we need more thinking on this and some kind of consensus on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants