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

Peter Levart plevart at openjdk.java.net
Wed Jun 2 21:18:37 UTC 2021


On Wed, 2 Jun 2021 16:56:07 GMT, Joe Darcy <joe.darcy at oracle.com> wrote:

> If the reflection runtime doesn't implement the semantics of
> -XX+PreserveAllAnnotations, I suggest deprecating/obsoleting/etc. that
> option now.
> 
> -Joe

What is the -XX+PreserveAllAnnotations semantics in terms of reflection? The VM spec allows it, but reflection spec doesn't mention it or anything close to it. It doesn't violate the reflection spec. It actually makes reflection behave more correctly in some cases. Without it, reflection sometimes doesn't return annotations with RUNTIME retention.

It does implement a useful semantics in terms of late binding. It's just buggy in corner case, which apparently hasn't bothered anyone, since nobody officially complained. That doesn't mean it hasn't been or is not used in the way where it behaves in a useful way and it doesn't mean it won't be needed in the future. Jaroslav gave a perfect example of the case where it is needed now. Removing this option means that migrating an annotation from CLASS retention to RUNTIME becomes almost impossible thing in the real world where no single person controls the whole codebase.

Peter

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

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


More information about the core-libs-dev mailing list