wrap-java: Basic classfile parser to get CLASS retained annotations #589
Draft
ktoso wants to merge 4 commits intoswiftlang:mainfrom
Draft
wrap-java: Basic classfile parser to get CLASS retained annotations #589ktoso wants to merge 4 commits intoswiftlang:mainfrom
ktoso wants to merge 4 commits intoswiftlang:mainfrom
Conversation
getResourceAsStream
d41030e to
9eb575c
Compare
Implement basic class file parsing, only enough to get annotations Thankfully the classfile format is well known and documented. We avoid the usual "Java way" of doing this work which would be to pull in the asm.jar dependency, but instead choose to do the parsing ourselfes. The format is well specified and stable, so we can be pretty confident in it. I based it on the JDK22 revision of the spec: https://docs.oracle.com/javase/specs/jvms/se22/html/jvms-4.html We only forus on the "RuntimeInvisibleAannotations" attribute because runtime visible ones we're able to get from plain reflection calls (which the Deprecated test cases showcase already in previous PR): https://docs.oracle.com/javase/specs/jvms/se22/html/jvms-4.html#jvms-4.7.17 This is necessary to support Android's RequiredApi annotations which are CLASS retained (or how kotlin confusingly calls it BINARY which mislead me and I thouhgt they're retained but yeah makes sense). This way we're able to emit Android availability annotations for the whole Android SDK.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement basic class file parsing, only enough to get annotations
Thankfully the classfile format is well known and documented.
We avoid the usual "Java way" of doing this work which would be to pull
in the asm.jar dependency, but instead choose to do the parsing
ourselfes.
The format is well specified and stable, so we can be pretty confident
in it. I based it on the JDK22 revision of the spec: https://docs.oracle.com/javase/specs/jvms/se22/html/jvms-4.html
We only forus on the "RuntimeInvisibleAannotations" attribute because
runtime visible ones we're able to get from plain reflection calls
(which the Deprecated test cases showcase already in previous PR): https://docs.oracle.com/javase/specs/jvms/se22/html/jvms-4.html#jvms-4.7.17
This is necessary to support Android's RequiredApi annotations which are
CLASS retained (or how kotlin confusingly calls it BINARY which mislead
me and I thouhgt they're retained but yeah makes sense).
This way we're able to emit Android availability annotations for the
whole Android SDK.