On Mon, 31 May 2021 06:06:37 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. > > Jaroslav Tulach has refreshed the contents of this pull request, and previous > commits have been removed. The incremental views will show differences > compared to the previous content of the PR. I think it would be wrong to extend the meaning of `-XX:+PreserveAllAnnotations` to the AnnotationParser so it would return CLASS retention-marked annotations. `-XX:+PreserveAllAnnotations` is just disabling the JVM optimization and it is not meant to be "visible" in the Java code. ------------- PR: https://git.openjdk.java.net/jdk/pull/4245