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 test and a single line fix that makes 
`-XX:+PreserveAllAnnotations` useful in cooperation with 
`Class.getAnnotation(...)`.

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

Commit messages:
 - Expose runtime invisible annotations via Class.getAnnotation when 
-XX:+PreserveAllAnnotations is on

Changes: https://git.openjdk.java.net/jdk/pull/4245/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4245&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8267936
  Stats: 65 lines in 2 files changed: 61 ins; 2 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4245.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4245/head:pull/4245

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

Reply via email to