You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
I just create a new binding project and build. Because at this point I don't want any actual types, I added <remove-node path="/api/package" /> to the transforms.
I don't know what's going on. Time for some musings to collect later...
I thought that RuntimeVisibleAnnotations might be involved, so I added support for parsing RuntimeVisibleAnnotations and RuntimeInvisibleAnnotations blobs to class-parse: #467.
This might be overthinking it, though the commit message in #467 points out an important thought:
How/Why does kotlin/collections/AbstractCollection$toString$1''s invoke() method mention the type E, when class-parse-generated XML output doesn't mention E within a <typeParameters/> block?
<typeParameters/> in turn comes from the Signature annotation, which I should have looked at earlier. For comparison purposes, consider android.app.FragmentHostCallback. If we run class-parse --dump android/app/FragmentHostCallback.class, we get:
The Signature annotation blob has a grammar for ClassSignature, which has FormalTypeParameters at the start of the string, between <...> brackets. This is what we see with android.app.FragmentHostCallback: a FormalTypeParameters specification of <E:Ljava/lang/Object;>, introducing the type parameter E which is constrained to java.lang.Object, followed by the signature of the super (base) class, android.app.FragmentContainer.
Now, what does kotlin/collections/AbstractCollection\$toString\$1.class have for it's Signature blob?
The Signature blob does not specify any type parameter information!
This leaves the question unanswered: where is E coming from? (I do see E in the RuntimeVisibleAnnotations for d2, but I don't want to begin to figure out what d1 and d2 are supposed to mean...)
Thus, it appears to be due to attempted processing of generic types and their constraints.
It would be useful to know which exact type & method causes things to break. @jpobst mentioned a signature of ([Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; on kotlin/collections/ArraysKt___ArraysKt.class, but those methods look reasonable:
changed the title [-]Binding Kotlin itself crashes the class-parse generator[/-][+]Binding Kotlin itself crashes `generator --only-xml-adjuster`[/+]on Aug 19, 2019
How/Why does kotlin/collections/AbstractCollection$toString$1''s invoke() method mention the type E, when class-parse-generated XML output doesn't mention E within a <typeParameters/> block?
With PR #469 we now parse the EnclosingMethod attribute and export it from class-parse-generated XML. From it we see:
i.e. AbstractCollectiondoes contain a declaration for the type parameter E, which is used/referenced by AbstractCollection$toString$1.
Thus, we can infer a possible fix: if a type has an enclosing-method-jni-type attribute, "lookup" the specified type (and optional method) to find any type parameters specified in the enclosing scope, and if necessary copy those <typeParameters/> into the resulting XML.
Alternatively, instead of having class-parse do that "copy <typeParameters/> to the referencing scope" logic, have generator perform that copy.
My concern over doing the copy at all is it alters the semantics of class-parse lib.jar vs. class-parse type.class: the former can perform "enclosing type" lookups; the latter can't. It may thus be preferable to have generator do the lookups, as it should have all necessary context.
A new Release version of Xamarin.Android has now been published on Windows that includes the fix for this item. The fix is not yet published in a Release version on macOS. I will update this item again when a Release version is available on macOS that includes the fix.
(Fix also included on macOS in Visual Studio 2019 for Mac version 8.4 Preview 2.1 and higher. To try the Preview version that includes the fix, check for the latest updates on the Previewupdater channel.)
A new Release version has now been published on macOS that includes the fix for this item.
Fix included in Xamarin.Android 10.1.1.0.
Fix included on macOS in Visual Studio 2019 for Mac version 8.4. To get the new version that includes the fix, check for the latest updates on the Stableupdater channel.
Activity
mattleibow commentedon Aug 13, 2019
More info can be found at: #464
[Xamarin.Android.Tools.Bytecode] Support RuntimeVisibleAnnotations
jonpryor commentedon Aug 13, 2019
I don't know what's going on. Time for some musings to collect later...
I thought that
RuntimeVisibleAnnotationsmight be involved, so I added support for parsingRuntimeVisibleAnnotationsandRuntimeInvisibleAnnotationsblobs toclass-parse: #467.This might be overthinking it, though the commit message in #467 points out an important thought:
How/Why does
kotlin/collections/AbstractCollection$toString$1''sinvoke()method mention the typeE, whenclass-parse-generated XML output doesn't mentionEwithin a<typeParameters/>block?<typeParameters/>in turn comes from theSignatureannotation, which I should have looked at earlier. For comparison purposes, considerandroid.app.FragmentHostCallback. If we runclass-parse --dump android/app/FragmentHostCallback.class, we get:The
Signatureannotation blob has a grammar forClassSignature, which hasFormalTypeParametersat the start of the string, between<...>brackets. This is what we see withandroid.app.FragmentHostCallback: aFormalTypeParametersspecification of<E:Ljava/lang/Object;>, introducing the type parameterEwhich is constrained tojava.lang.Object, followed by the signature of the super (base) class,android.app.FragmentContainer.Now, what does
kotlin/collections/AbstractCollection\$toString\$1.classhave for it'sSignatureblob?The
Signatureblob does not specify any type parameter information!This leaves the question unanswered: where is
Ecoming from? (I do seeEin theRuntimeVisibleAnnotationsford2, but I don't want to begin to figure out whatd1andd2are supposed to mean...)Could the
EnclosingMethodannotation be relevant?[Xamarin.Android.Tools.Bytecode] Add EnclosingMethod, SourceFile
jonpryor commentedon Aug 14, 2019
Thus, it appears to be due to attempted processing of generic types and their constraints.
It would be useful to know which exact type & method causes things to break. @jpobst mentioned a signature of
([Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object;onkotlin/collections/ArraysKt___ArraysKt.class, but those methods look reasonable:...although...perhaps it's having
Thave an interface bound onSwhich is causing the problem?Which is, I believe, equivalent to:
[Xamarin.Android.Tools.Bytecode] Add EnclosingMethod, SourceFile
[Xamarin.Android.Tools.Bytecode] Add EnclosingMethod, SourceFile
[Xamarin.Android.Tools.Bytecode] Add EnclosingMethod, SourceFile (#469)
[-]Binding Kotlin itself crashes the class-parse generator[/-][+]Binding Kotlin itself crashes `generator --only-xml-adjuster`[/+]jonpryor commentedon Aug 19, 2019
Revisiting #466 (comment)
With PR #469 we now parse the
EnclosingMethodattribute and export it fromclass-parse-generated XML. From it we see:$ mono class-parse.exe kotlin/collections/AbstractCollection\$toString\$1.class ... <class abstract="false" deprecated="not deprecated" enclosing-method-jni-type="Lkotlin/collections/AbstractCollection;" enclosing-method-name="toString" enclosing-method-signature="()Ljava/lang/String;" jni-extends="Lkotlin/jvm/internal/Lambda;" extends="kotlin.jvm.internal.Lambda" extends-generic-aware="kotlin.jvm.internal.Lambda" final="true" name="AbstractCollection.toString.1" jni-signature="Lkotlin/collections/AbstractCollection$toString$1;" source-file-name="AbstractCollection.kt" static="true" visibility=""> ...The enclosing type is
Lkotlin/collections/AbstractCollection;.If we turn our attention to
AbstractCollection, we see:$ mono class-parse.exe kotlin/collections/AbstractCollection.class ... <class abstract="true" deprecated="not deprecated" jni-extends="Ljava/lang/Object;" extends="java.lang.Object" extends-generic-aware="java.lang.Object" final="false" name="AbstractCollection" jni-signature="Lkotlin/collections/AbstractCollection;" source-file-name="AbstractCollection.kt" static="false" visibility="public"> <typeParameters> <typeParameter name="E" jni-classBound="Ljava/lang/Object;" classBound="java.lang.Object" interfaceBounds="" jni-interfaceBounds="" />i.e.
AbstractCollectiondoes contain a declaration for the type parameterE, which is used/referenced byAbstractCollection$toString$1.Thus, we can infer a possible fix: if a type has an
enclosing-method-jni-typeattribute, "lookup" the specified type (and optional method) to find any type parameters specified in the enclosing scope, and if necessary copy those<typeParameters/>into the resulting XML.Alternatively, instead of having
class-parsedo that "copy<typeParameters/>to the referencing scope" logic, havegeneratorperform that copy.My concern over doing the copy at all is it alters the semantics of
class-parse lib.jarvs.class-parse type.class: the former can perform "enclosing type" lookups; the latter can't. It may thus be preferable to havegeneratordo the lookups, as it should have all necessary context.[ApiXmlAdjuster] Guard against NRE when writing generic constraints. (#…
[ApiXmlAdjuster] Guard against NRE when writing generic constraints. (#…
Bump to xamarin/Java.Interop/master@2716edfd
Bump to xamarin/Java.Interop/master@2716edfd (#3709)
Bump to xamarin/Java.Interop/d16-4@35b08baa (#3709)
[Xamarin.Android.Tools.Bytecode] Support Runtime[In]VisibleAnnotations
[Xamarin.Android.Tools.Bytecode] Support Runtime[In]VisibleAnnotations
[Xamarin.Android.Tools.Bytecode] Support Runtime[In]VisibleAnnotations
[Xamarin.Android.Tools.Bytecode] Support Runtime[In]VisibleAnnotations
[Xamarin.Android.Tools.Bytecode] Runtime[In]VisibleAnnotations Parsing (
jpobst commentedon Oct 31, 2019
Fixed in #495.
brendanzagaeski commentedon Dec 4, 2019
Release status update
A new Release version of Xamarin.Android has now been published on Windows that includes the fix for this item. The fix is not yet published in a Release version on macOS. I will update this item again when a Release version is available on macOS that includes the fix.
Fix included in Xamarin.Android 10.1.0.30.
Fix included on Windows in Visual Studio 2019 version 16.4. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.
(Fix also included on macOS in Visual Studio 2019 for Mac version 8.4 Preview 2.1 and higher. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.)
brendanzagaeski commentedon Jan 8, 2020
Release status update
A new Release version has now been published on macOS that includes the fix for this item.
Fix included in Xamarin.Android 10.1.1.0.
Fix included on macOS in Visual Studio 2019 for Mac version 8.4. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.
(Fix also included on Windows in Visual Studio 2019 version 16.4 and higher. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.)