-
Notifications
You must be signed in to change notification settings - Fork 58
[Xamarin.Android.Tools.Bytecode] Support RuntimeVisibleAnnotations #467
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
Closed
Conversation
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
Context: dotnet#466 While investigating issue dotnet#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.
This was referenced Aug 13, 2019
TODO: add found annotations to XML output. |
jonpryor
pushed a commit
that referenced
this pull request
Sep 30, 2019
…495) Context: #466 Context: #467 When attempting to bind [`kotlin-stdlib-1.3.41.jar`][0], `generator` crashes with the following exception: System.NullReferenceException: Object reference not set to an instance of an object at Xamarin.Android.Tools.ApiXmlAdjuster.JavaApiXmlGeneratorExtensions.Save (Xamarin.Android.Tools.ApiXmlAdjuster.JavaTypeParameters typeParameters, System.Xml.XmlWriter writer, System.String indent) at Xamarin.Android.Tools.ApiXmlAdjuster.JavaApiXmlGeneratorExtensions.SaveCommon (Xamarin.Android.Tools.ApiXmlAdjuster.JavaMember m, System.Xml.XmlWriter writer, System.String elementName, System.String abs, System.String native, System.String ret, System.String sync, System.String transient, System.String type, System.String typeGeneric, System.String value, System.String volat, Xamarin.Android.Tools.ApiXmlAdjuster.JavaTypeParameters typeParameters, System.Collections.Generic.IEnumerable`1[T] parameters, System.Collections.Generic.IEnumerable`1[T] exceptions, System.Nullable`1[T] extBridge, System.String jniReturn, System.Nullable`1[T] extSynthetic) at Xamarin.An/droid.Tools.ApiXmlAdjuster.JavaApiXmlGeneratorExtensions.Save (Xamarin.Android.Tools.ApiXmlAdjuster.JavaMethod method, System.Xml.XmlWriter writer) at Xamarin.Android.Tools.ApiXmlAdjuster.JavaApiXmlGeneratorExtensions.SaveTypeCommon (Xamarin.Android.Tools.ApiXmlAdjuster.JavaType cls, System.Xml.XmlWriter writer, System.String elementName, System.String abs, System.String ext, System.String extgen, System.String jniExt) at Xamarin.Android.Tools.ApiXmlAdjuster.JavaApiXmlGeneratorExtensions.Save (Xamarin.Android.Tools.ApiXmlAdjuster.JavaClass cls, System.Xml.XmlWriter writer) at Xamarin.Android.Tools.ApiXmlAdjuster.JavaApiXmlGeneratorExtensions.Save (Xamarin.Android.Tools.ApiXmlAdjuster.JavaApi api, System.Xml.XmlWriter writer) at Xamarin.Android.Tools.ApiXmlAdjuster.JavaApiXmlGeneratorExtensions.Save (Xamarin.Android.Tools.ApiXmlAdjuster.JavaApi api, System.String xmlfile) at Xamarin.Android.Tools.ApiXmlAdjuster.Adjuster.Process (System.String inputXmlFile, MonoDroid.Generation.CodeGenerationOptions opt, MonoDroid.Generation.GenBase[] gens, System.String outputXmlFile, System.Int32 reportVerbosity) at Xamarin.Android.Binder.CodeGenerator.Run (Xamarin.Android.Binder.CodeGeneratorOptions options, Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver) at Xamarin.Android.Binder.CodeGenerator.Run (Xamarin.Android.Binder.CodeGeneratorOptions options) at Xamarin.Android.Binder.CodeGenerator.Main (System.String[] args) We are still investigating *why* this happens and how it should be appropriately fixed. In the meantime, to "unblock" developers attempting to bind binding Kotlin libraries in Visual Studio 16.4 Preview 2, simply prevent the `NullReferenceException` from being generated generated. This at least lets people get past the crash so they can apply fixups in `Metadata.xml` to continue. (This `NullReferenceException` happens before the `metadata` stage; there's nothing a user can currently do.) I will be making our Kotlin bindings more "correct" in future sprints. [0]: https://search.maven.org/remotecontent?filepath=org/jetbrains/kotlin/kotlin-stdlib/1.3.41/kotlin-stdlib-1.3.41.jar
jonpryor
pushed a commit
that referenced
this pull request
Sep 30, 2019
…495) Context: #466 Context: #467 When attempting to bind [`kotlin-stdlib-1.3.41.jar`][0], `generator` crashes with the following exception: System.NullReferenceException: Object reference not set to an instance of an object at Xamarin.Android.Tools.ApiXmlAdjuster.JavaApiXmlGeneratorExtensions.Save (Xamarin.Android.Tools.ApiXmlAdjuster.JavaTypeParameters typeParameters, System.Xml.XmlWriter writer, System.String indent) at Xamarin.Android.Tools.ApiXmlAdjuster.JavaApiXmlGeneratorExtensions.SaveCommon (Xamarin.Android.Tools.ApiXmlAdjuster.JavaMember m, System.Xml.XmlWriter writer, System.String elementName, System.String abs, System.String native, System.String ret, System.String sync, System.String transient, System.String type, System.String typeGeneric, System.String value, System.String volat, Xamarin.Android.Tools.ApiXmlAdjuster.JavaTypeParameters typeParameters, System.Collections.Generic.IEnumerable`1[T] parameters, System.Collections.Generic.IEnumerable`1[T] exceptions, System.Nullable`1[T] extBridge, System.String jniReturn, System.Nullable`1[T] extSynthetic) at Xamarin.An/droid.Tools.ApiXmlAdjuster.JavaApiXmlGeneratorExtensions.Save (Xamarin.Android.Tools.ApiXmlAdjuster.JavaMethod method, System.Xml.XmlWriter writer) at Xamarin.Android.Tools.ApiXmlAdjuster.JavaApiXmlGeneratorExtensions.SaveTypeCommon (Xamarin.Android.Tools.ApiXmlAdjuster.JavaType cls, System.Xml.XmlWriter writer, System.String elementName, System.String abs, System.String ext, System.String extgen, System.String jniExt) at Xamarin.Android.Tools.ApiXmlAdjuster.JavaApiXmlGeneratorExtensions.Save (Xamarin.Android.Tools.ApiXmlAdjuster.JavaClass cls, System.Xml.XmlWriter writer) at Xamarin.Android.Tools.ApiXmlAdjuster.JavaApiXmlGeneratorExtensions.Save (Xamarin.Android.Tools.ApiXmlAdjuster.JavaApi api, System.Xml.XmlWriter writer) at Xamarin.Android.Tools.ApiXmlAdjuster.JavaApiXmlGeneratorExtensions.Save (Xamarin.Android.Tools.ApiXmlAdjuster.JavaApi api, System.String xmlfile) at Xamarin.Android.Tools.ApiXmlAdjuster.Adjuster.Process (System.String inputXmlFile, MonoDroid.Generation.CodeGenerationOptions opt, MonoDroid.Generation.GenBase[] gens, System.String outputXmlFile, System.Int32 reportVerbosity) at Xamarin.Android.Binder.CodeGenerator.Run (Xamarin.Android.Binder.CodeGeneratorOptions options, Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver) at Xamarin.Android.Binder.CodeGenerator.Run (Xamarin.Android.Binder.CodeGeneratorOptions options) at Xamarin.Android.Binder.CodeGenerator.Main (System.String[] args) We are still investigating *why* this happens and how it should be appropriately fixed. In the meantime, to "unblock" developers attempting to bind binding Kotlin libraries in Visual Studio 16.4 Preview 2, simply prevent the `NullReferenceException` from being generated generated. This at least lets people get past the crash so they can apply fixups in `Metadata.xml` to continue. (This `NullReferenceException` happens before the `metadata` stage; there's nothing a user can currently do.) I will be making our Kotlin bindings more "correct" in future sprints. [0]: https://search.maven.org/remotecontent?filepath=org/jetbrains/kotlin/kotlin-stdlib/1.3.41/kotlin-stdlib-1.3.41.jar
jonpryor
pushed a commit
that referenced
this pull request
Oct 9, 2019
#502) Context: #466 Context: #467 Context: #499 Add support for parsing the [`RuntimeVisibleAnnotations`][0] and [`RuntimeInvisibleAnnotations`][1] attributes in Java bytecode. These attributes store Java programming language [annotations][2] placed on language constructs such as types, fields, and methods, and are analogous with C# custom attributes. Kotlin stores various bits of information in these attributes, and it will be necessary to parse these attributes to read that information; see also PR #499. [0]: https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.16 [1]: https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.17 [2]: https://docs.oracle.com/javase/specs/jls/se7/html/jls-9.html#jls-9.7
Superseded by PR #502. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
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 whatE
is.Normally, there'd be a
<typeParameters/>
element, which isprovided by the
Signature
annotation.Note that the above does not contain
<typeParameters/>
!On the vague thought that maybe
RuntimeVisibleAnnotations
were beingused to store generic type information, add support to
class-parse
to extract
RuntimeVisibleAnnotations
andRuntimeInvisibleAnnotations
annotation blobs.