RFR: JDK-8267936: PreserveAllAnnotations option doesn't expose the annotation to Java code [v4]

Jaroslav Tulach github.com+26887752+jaroslavtulach at openjdk.java.net
Mon May 31 06:06:37 UTC 2021


> 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. The pull request contains two new commits since the last revision:

 - Merging with test for long time existing behavior of -XX:+PreserveAllAnnotations
 - Test long time existing behavior of -XX:+PreserveAllAnnotations

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/4245/files
  - new: https://git.openjdk.java.net/jdk/pull/4245/files/9548a565..0fd2fced

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4245&range=03
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4245&range=02-03

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 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


More information about the hotspot-runtime-dev mailing list