On Thu, 6 Aug 2026 07:18:56 GMT, Axel Boldt-Christmas <[email protected]>
wrote:
>> test/jtreg_value_class_plugin/plugin/jdk/test/valueclass/ValueClassPlugin.java
>> line 81:
>>
>>> 79: public void visitClassDef(JCClassDecl tree) {
>>> 80: boolean hasAnnotation =
>>> tree.mods.annotations.stream()
>>> 81: .anyMatch(a ->
>>> a.annotationType.toString()
>>
>> I think maybe you can check `a.annotationType.type.toString()`? That should
>> be the fully-qualified class name of `AsValueClass` and you should be able
>> to drop the complex checks with imports and everything.
>
> This plugin runs during parsing when the type has not yet been resolved and
> set. I am not fully aware of all the reasons that we decided to do this
> during parsing. But it seems like `javac` consumes the information we are
> modifying before it does its analysis which figures out the type and
> populates the type field.
>
> I think if we want to be able to do this later we would have to either change
> javac, or mimic what javac does here and not only fix-up what we already do,
> but also repair any derived properties.
>
> I think doing it like this is a pragmatic albite hacky solution.
>
> It would be nice if there was a more elegant solution here, but that is not a
> solution I can currently see. (But I am very much a newcomer to the javac
> code and tooling)
What about handling at the ENTER stage? I don't think tweaking
`tree.mods.flags` must happen right after initial parsing.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/32214#discussion_r3730920708