RFR: JDK-8267936: PreserveAllAnnotations option isn't tested
David Holmes
david.holmes at oracle.com
Wed Jun 2 22:20:31 UTC 2021
On 3/06/2021 12:39 am, Peter Levart wrote:
> On Wed, 2 Jun 2021 05:59:05 GMT, David Holmes <david.holmes at oracle.com> wrote:
>
>> Sorry Jaroslav but I don't really see this test as a basic functional
>> test of the PreserveAllAnnotations flag. There is no need for any
>> dynamic retention mode switch. All you need as I've said previously is a
>> class with all the CLASS retention annotations of interest (8 IIRC)
>> applied and a programs that reads them, and either expects to find them
>> or not, based on the PreserveAllAnnotations flag.
>
> `CLASS` retention annotations are never returned by reflection regardless of whether the `PreserveAllAnnotations` option was used
Sorry yes - my bad. I missed that getRawAnnotations() output was then
fed through the AnnotationsParser.
Thanks,
David
-----
or not. The only way (apart from hacking into encapsulated state and
doing your own parsing) is to compile a class that uses an annotation
with `CLASS` retention and then run a test that looks up the annotation
on this class after the annotation has been changed to have `RUNTIME`
retention, but the class that uses it has not been recompiled.
> `AltClassLoader` does the trick which replaces the class file of _v1 class with the class file of _v2 class when loading the class which simulates this change and recompilation of the annotation without changing anything else.
>
> -------------
>
> PR: https://git.openjdk.java.net/jdk/pull/4280
>
More information about the core-libs-dev
mailing list