Skip to content

8359707: Add classfile modification code to RedefineClassHelper #25857

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 2 commits into
base: master
Choose a base branch
from

Conversation

coleenp
Copy link
Contributor

@coleenp coleenp commented Jun 17, 2025

I copied this code for another test in the Valhalla repo and thought it would be a good utility function. It might be better written using the Classfile API.
Tested with test.


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-8359707: Add classfile modification code to RedefineClassHelper (Enhancement - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25857

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 17, 2025

👋 Welcome back coleenp! 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 Jun 17, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

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

openjdk bot commented Jun 17, 2025

@coleenp The following label will be automatically applied to this pull request:

  • serviceability

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

@openjdk openjdk bot added the serviceability serviceability-dev@openjdk.org label Jun 17, 2025
@coleenp
Copy link
Contributor Author

coleenp commented Jun 17, 2025

/label add hotspot-runtime

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Jun 17, 2025
@openjdk
Copy link

openjdk bot commented Jun 17, 2025

@coleenp
The hotspot-runtime label was successfully added.

@mlbridge
Copy link

mlbridge bot commented Jun 17, 2025

Webrevs

Copy link
Contributor

@sspitsyn sspitsyn left a comment

Choose a reason for hiding this comment

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

This looks reasonable. I've posted one nit suggestion.

* @param newString new class name to replace with old class name.
*/

public static byte[] replaceAllStrings(ClassLoader loader, String oldString, String newString) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I'd suggest to rename parameters:
oldString => oldClassName
newString => newClassName

Alternatively, it is possible to pass bytecodes buffer instead of class loader and keep oldString and newString as before.

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 wanted this code to also read bytecodes off the disk and not the caller do that either. The code for getBytecodes or very similar is duplicated all over the tests also.

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 can add a byte buffer version though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime hotspot-runtime-dev@openjdk.org rfr Pull request is ready for review serviceability serviceability-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

2 participants