RFR: 8356548: Use ClassFile API instead of ASM to transform classes in tests [v8]

Serguei Spitsyn sspitsyn at openjdk.org
Wed Oct 15 17:52:40 UTC 2025


On Wed, 15 Oct 2025 17:03:26 GMT, Chen Liang <liach at openjdk.org> wrote:

>> One of the goals of ClassFile API is to avoid updating the copy of ASM in the JDK (now moved to the test library) to support future class file formats.
>> 
>> However, some tests in hotspot turn out to parse latest class files, usually produced by the javac in the JDK under test, to transform them to inject desired bytecode patterns. If we keep these tests, we must keep maintaining the ASM library to accept all current class files, which will be costly with the upcoming project Valhalla.
>> 
>> To avoid maintaining ASM down the road, we can either:
>> 1. Migrate the transformation to ClassFile API
>> 2. Set source and release version in javac flags to produce stable bytecode
>> 
>> I recommend migrating to ClassFile API; javac has a deprecation policy, that in the future, old source and target versions will no longer be supported, and we would still need another port at that time.
>
> Chen Liang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Serguei reviews

test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineAnnotations.java line 94:

> 92:                 public void accept(ClassBuilder builder, ClassElement element) {
> 93:                     if (element instanceof FieldModel field && field.fieldName().stringValue().startsWith("dummy")) {
> 94:                         // Defer dummy fields to defer their associated constant pool entries

Nit: This comment is kind of confusing. What does it mean: `defer dummy fields`? Do you mean `defer adding dummy fields to the class file`?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25124#discussion_r2433474192


More information about the serviceability-dev mailing list