RFR: 8359707: Add classfile modification code to RedefineClassHelper

Serguei Spitsyn sspitsyn at openjdk.org
Tue Jun 17 22:33:28 UTC 2025


On Tue, 17 Jun 2025 17:11:01 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

> 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.

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

test/lib/RedefineClassHelper.java line 104:

> 102:      */
> 103: 
> 104:     public static byte[] replaceAllStrings(ClassLoader loader, String oldString, String newString) throws Exception {

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.

-------------

PR Review: https://git.openjdk.org/jdk/pull/25857#pullrequestreview-2937246161
PR Review Comment: https://git.openjdk.org/jdk/pull/25857#discussion_r2153274007


More information about the hotspot-runtime-dev mailing list