RFR: 8333377: Migrate Generic Signature parsing to ClassFile API
Chen Liang
liach at openjdk.org
Fri May 31 22:29:50 UTC 2024
On Sat, 18 May 2024 05:24:16 GMT, ExE Boss <duke at openjdk.org> wrote:
>> Core reflection's generic signature parsing uses an ancient library with outdated visitor pattern on a tree model and contains unnecessary boilerplates. This is a duplication of ClassFile API's signature model. We should just move to ClassFile API, which is more throughoutly tested as well.
>>
>> To ensure compatibility, new tests are added to ensure consistent behavior when encountering malformed signatures or signatures with missing types. The reflective objects have been preserved and the only change is that lazy expansion now happens from CF objects, to reduce compatibility risks.
>
> src/java.base/share/classes/java/lang/Class.java line 3487:
>
>> 3485:
>> 3486: // Generic info repository; lazily initialized
>> 3487: private transient volatile @Stable ClassGenericInfo<T> genericInfo;
>
> I don’t think this field can be `@Stable`, as generic signatures can change when a class gets redefined by **JVM TI**, just like [simple][Class::getSimpleName()] and [canonical names][Class::getCanonicalName()].
> https://github.com/openjdk/jdk/blob/8acdd2d7c8de17515b87815d54ce556237039406/src/java.base/share/classes/java/lang/Class.java#L3452-L3454
>
> [Class::getSimpleName()]: https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/Class.html#getSimpleName()
> [Class::getCanonicalName()]: https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/Class.html#getCanonicalName()
Existing genericInfo is not part of ReflectionData. The migration of genericInfo into reflectionData should be done in a separate task.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19281#discussion_r1605781541
More information about the core-libs-dev
mailing list