RFR: 8359707: Add classfile modification code to RedefineClassHelper [v8]

Coleen Phillimore coleenp at openjdk.org
Mon Jun 30 11:38:24 UTC 2025


On Mon, 30 Jun 2025 05:22:11 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Rename replaceAllStrings to replaceClassName and add back the byte buffer version of the function.
>
> test/lib/RedefineClassHelper.java line 87:
> 
>> 85:      * @param newClassName new class name to replace with old class name.
>> 86:      */
>> 87:     public static byte[] replaceClassName(byte[] bytes, String oldClassName, String newClassName) throws Exception {
> 
> Just realized that `oldClassName` is not actually used. Suggestion:
> 
> /*
>  * Copy the class defined by `bytes`, replacing the name of the class with `newClassName`, so that both
>  * old and new classes can be compiled by jtreg for the test.
>  *
>  * @param bytes the bytes presenting the original classfile
>  * @param newClassName the new class name for the returned class representation
>  * @ return a copy of the class represented by `bytes` but with the name `newClassName`
>  */
>  public static byte[] replaceClassName(byte[] bytes, String newClassName) throws Exception {

Thanks David for the comment text, I changed it slightly because I didn't understand what the word presenting meant in that sentence.  Also removed the parameter.  We can add it back when the class file remapper API is available without having to add --add-modules to all the tests.  If we need to make the old classfiles substitute more than the name.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25857#discussion_r2174862057


More information about the serviceability-dev mailing list