RFR: JDK-8267936: PreserveAllAnnotations option isn't tested

Peter Levart plevart at openjdk.java.net
Wed Jun 2 15:38:32 UTC 2021


On Wed, 2 Jun 2021 13:24:10 GMT, David Holmes <david.holmes at oracle.com> wrote:

> Sorry now I see what happens. We aren't combining two arrays of
> annotations we're concatenating two streams of byes, each of which
> represents a set of annotations, starting with the length.
> 
> The code that receives this on the JDK side doesn't seem to understand
> that this is a possibility.
> 
> Though maybe this isn't a bug, maybe the AnnotationParser is
> deliberately ignoring the second byte stream. (Though if it were
> deliberate there should be some commentary to that affect!)
> 
> David

I think this is not deliberate. Since `rawAnnotations` may end up having any of the following:
- `RuntimeVisibleAnnotations` (when there were just `RUNTIME` annotation usages compiled into the class or `-XX+PreserveAllAnnotations` was not used at runtime)
- `RuntimeInvisibleAnnotations` (when there were just `CLASS` annotation usages compiled into the class and `-XX+PreserveAllAnnotations` was used at runtime)
- `RuntimeVisibleAnnotations + RuntimeInvisibleAnnotations` (when there were `RUNTIME` and `CLASS` annotation usages compiled into the class and `-XX+PreserveAllAnnotations` was used at runtime)

So why would `RuntimeInvisibleAnnotations` be skipped in 3rd case but not in 2nd case?

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

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


More information about the core-libs-dev mailing list