RFR: JDK-8267936: PreserveAllAnnotations option isn't tested

Peter Levart plevart at openjdk.java.net
Thu Jun 3 07:02:36 UTC 2021


On Wed, 2 Jun 2021 22:47:13 GMT, David Holmes <david.holmes at oracle.com> wrote:

> On 3/06/2021 2:54 am, Joe Darcy wrote:
> 
> > If the reflection runtime doesn't implement the semantics of
> > -XX+PreserveAllAnnotations, I suggest deprecating/obsoleting/etc. that
> > option now.
> 
> I have to agree with Joe now. I mistakenly thought the raw annotation
> stream was exposed to some parts of reflection, but now I see that it
> all goes through AnnotationParser, which strips out all non-Runtime
> retention annotations. So the flag is useless as the data it causes to
> be passed to the JDK is thrown away anyway.
> 
> Cheers,
> David

We are constantly dancing around the same problem which is a false assumption that `RuntimeVisibleAnnotations` attribute contains only RUNTIME retention annotations and that `RuntimeInvisibleAnnotations` attribute contains only CLASS retention annotations. This is simply not true in a real world. It is only true in a world where either nothing changes from the day 1 when it is 1st created or in a world where all the sources that compose the application are always recompiled. Those two worlds are ideal worlds that don't exist.
In other words, the flag is useless in the dream world(s) but not in the real world.

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

PR: https://git.openjdk.java.net/jdk/pull/4280


More information about the core-libs-dev mailing list