-
Notifications
You must be signed in to change notification settings - Fork 64
[Xamarin.Android.Tools.Bytecode] Support Runtime[In]VisibleAnnotations #502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
93a8db4 to
4760982
Compare
| name-generic-aware="java.lang.annotation.Annotation" | ||
| jni-type="Ljava/lang/annotation/Annotation;" /> | ||
| <runtimeVisibleAnnotations> | ||
| <annotation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of the question here is twofold:
- What type of XML output do we want to emit, and
- What type of XML output will be easiest for
generatorto consume?
While <annotation type="..."><value key=="..." /></annotation> is easy to emit, I doubt that this is at all easy to consume. It's useful for human reading of output, but I doubt it's useful for machine reading of output.
I suspect what we might instead want is:
<runtimeVisibleAnnotations>
<annotation jni-type="Ljava/lang/annotation/Target;">
<array>
<enum jni-type="Ljava/lang/annotation/ElementType;" member="TYPE" />
<enum jni-type="Ljava/lang/annotation/ElementType;" member="FIELD" />
<enum jni-type="Ljava/lang/annotation/ElementType;" member="CONSTRUCTOR" />
<enum jni-type="Ljava/lang/annotation/ElementType;" member="METHOD" />
<enum jni-type="Ljava/lang/annotation/ElementType;" member="PARAMETER" />
<enum jni-type="Ljava/lang/annotation/ElementType;" member="LOCAL_VARIABLE" />
</array>
</annotation>
<annotation jni-type="Ljava/lang/annotation/Retention;">
<enum jni-type="Ljava/lang/annotation/RetentionPolicy;" member="SOURCE" />
</annotation>
</runtimeVisibleAnnotations>I can imagine this being far more understandable to generator -- and maybe even humans? -- than the mishmash of what I came up with in PR #467, though it also means an associated increase in "bloat"/XML size as well as implementation complexity. (Which is why I didn't do it in #467, but also why I didn't want to merge #467.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am beginning to think we should stick to Agile principles here and not write code that we don't need yet, since we don't know if we'll ever need it or what shape would be best if we do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an excellent point. In that case, do we actually need a separate <value/> element when the //value/@key attribute is always value? Why not just merge into <annotation/>?
<annotation
type="Ljava/lang/annotation/Target;"
elements="[Enum(Ljava/lang/annotation/ElementType;.TYPE), Enum(Ljava/lang/annotation/ElementType;.FIELD), Enum(Ljava/lang/annotation/ElementType;.CONSTRUCTOR), Enum(Ljava/lang/annotation/ElementType;.METHOD), Enum(Ljava/lang/annotation/ElementType;.PARAMETER), Enum(Ljava/lang/annotation/ElementType;.LOCAL_VARIABLE)]"
/>There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand, the keys have different names which should be preserved:
<annotation type="Lkotlin/Metadata;">
<value key="mv">[1, 1, 15]</value>
<value key="bv">[1, 0, 3]</value>
</annotation>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm an idiot and misread this line: https://github.com/xamarin/java.interop/pull/502/files#diff-759d8653993a49e7976b261c1ef45a72R335
return new XElement ("value",I misread that as the attribute value. Doh!
4760982 to
bd25ffe
Compare
Context: #466 While investigating issue #466, I ran across an "oddity" within the type `kotlin/collections/AbstractCollection\$toString\$1.class`: <api api-source="class-parse"> <package name="kotlin.collections" jni-name="kotlin/collections"> <class name="AbstractCollection.toString.1" jni-signature="Lkotlin/collections/AbstractCollection$toString$1;"> <implements name="kotlin.jvm.functions.Function1" name-generic-aware="kotlin.jvm.functions.Function1<E, java.lang.CharSequence>" jni-type="Lkotlin/jvm/functions/Function1<TE;Ljava/lang/CharSequence;>;" /> <method name="invoke" jni-signature="(Ljava/lang/Object;)Ljava/lang/CharSequence;"> <parameter name="it" type="E" jni-type="TE;" /> </method> </class> </package> </api> (Abbreviated output). What's *bizarre* is that the `invoke()` method references the type `E`, but there is no declaration of what `E` *is*. *Normally*, there'd be a `<typeParameters/>` element, which is provided by the `Signature` annotation. Note that the above does *not* contain `<typeParameters/>`! On the vague thought that maybe `RuntimeVisibleAnnotations` were being used to store generic type information, add support to `class-parse` to extract `RuntimeVisibleAnnotations` and `RuntimeInvisibleAnnotations` annotation blobs.
bd25ffe to
1127477
Compare
|
Proposed commit message: |
(Copied from #467)
Context: #466
While investigating issue #466, I ran across an "oddity" within the
type
kotlin/collections/AbstractCollection\$toString\$1.class:(Abbreviated output).
What's bizarre is that the
invoke()method references the typeE, but there is no declaration of whatEis.Normally, there'd be a
<typeParameters/>element, which isprovided by the
Signatureannotation.Note that the above does not contain
<typeParameters/>!On the vague thought that maybe
RuntimeVisibleAnnotationswere beingused to store generic type information, add support to
class-parseto extract
RuntimeVisibleAnnotationsandRuntimeInvisibleAnnotationsannotation blobs.