On Fri, 28 May 2021 12:56:39 GMT, Jaroslav Tulach <github.com+26887752+jaroslavtul...@openjdk.org> wrote:
> This PR exposes runtime invisible annotations via `Class.getAnnotation` when > `-XX:+PreserveAllAnnotations` option is passed to the JVM. > > Existing `-XX:+PreserveAllAnnotations` option can be very useful for code > that needs to access annotations with `RetentionPolicy.CLASS` without the > need to parse the .class files manually. While the > RuntimeInvisibleAnnotations are kept in the runtime, they are not visible via > java.lang.reflect API. I assume that's just an omission. > > This PR provides a new test and a fix to make `Class.getAnnotation(...)` > useful when `-XX:+PreserveAllAnnotations` option is on. I checked the pre-OpenJDK history and `-XX:+PreserveAllAnnotations` dates from when JSR-175 support was added in JDK 5. It may have been useful during the development but I don't see any tests using it now. I don't think we want to create an attractive nuisance here and maybe this XX option should be deprecated so that it can be obsoleted and eventually removed. ------------- PR: https://git.openjdk.java.net/jdk/pull/4245