On Sun, 30 May 2021 23:03:55 GMT, David Holmes <[email protected]> wrote:
> But we should add in some tests. Right, I was surprised by missing tests as well. I've just created a _"standalone"_ commit 0f689ea that adds such test and also shows the way I am currently using the `-XX:+PreserveAllAnnotations` flag. It [requires some tricks](https://github.com/openjdk/jdk/pull/4245/files#r642231785) with `ClassLoader` and bytecode manipulation to change the retention to `RUNTIME` and then (in combination with `-XX:+PreserveAllAnnotations`) the annotation is accessible. The test in 0f689ea is _"standalone"_ - e.g. it can be merged without my other changes. However I continue to hope the change in `Class.getAnnotation` could get in: the `-XX:+PreserveAllAnnotation` option hasn't caused any issues since Java 5 - this is the first improvement ever requested. Possibly also the last one - tests are written & the functionality works - what else could one want? ------------- PR: https://git.openjdk.java.net/jdk/pull/4245
