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.
Assert matching method parameters in class-parse #1090
It will hit the Debug.Assert in Methods.UpdateParametersFromMethodParametersAttribute (...):
Unexpected number of method parameters; expected 0, got 1
at Xamarin.Android.Tools.Bytecode.MethodInfo.UpdateParametersFromMethodParametersAttribute(ParameterInfo[] parameters) in C:\code\xamarin-android\external\Java.Interop\src\Xamarin.Android.Tools.Bytecode\Methods.cs:line 305
at Xamarin.Android.Tools.Bytecode.MethodInfo.GetParameters() in C:\code\xamarin-android\external\Java.Interop\src\Xamarin.Android.Tools.Bytecode\Methods.cs:line 92
at Xamarin.Android.Tools.Bytecode.XmlClassDeclarationBuilder.GetMethodParameters(MethodInfo method)+MoveNext() in C:\code\xamarin-android\external\Java.Interop\src\Xamarin.Android.Tools.Bytecode\XmlClassDeclarationBuilder.cs:line 389
at System.Xml.Linq.XContainer.AddContentSkipNotify(Object content)
at System.Xml.Linq.XContainer.AddContentSkipNotify(Object content)
at Xamarin.Android.Tools.Bytecode.XmlClassDeclarationBuilder.GetMethod(String element, String name, MethodInfo method, String returns) in C:\code\xamarin-android\external\Java.Interop\src\Xamarin.Android.Tools.Bytecode\XmlClassDeclarationBuilder.cs:line 338
at Xamarin.Android.Tools.Bytecode.XmlClassDeclarationBuilder.<GetConstructors>b__23_2(MethodInfo c) in C:\code\xamarin-android\external\Java.Interop\src\Xamarin.Android.Tools.Bytecode\XmlClassDeclarationBuilder.cs:line 321
...
This works in the class-parse we ship in .NET 6 because it works today in the GooglePlayServices repository CI, so it's a regression since then.
which is to say that the only constructor accepts 1 parameter, but that parameter is named this. What is (probably) happening is Session.Runner.Reference is a non-static inner class of Session.Runner, and as such its constructor requires a reference of its enclosing type.
Turns Out™ that for the "offending" method, pinfo[0].AccessFlags is Final, Synthetic (0x1010), while what we were looking for -- in the form of OuterThis -- was Final, Mandated (0x8010). The actual value is what we expected for a "outer this reference", so we didn't skip it, which caused the assert to fire.
Activity
jonpryor commentedon Mar 30, 2023
Oddly, commit 8ccb837 is in the release/6.0.3xx branch, but was reverted in the release/6.0.1xx-preview10 branch.
@jonathanpeppers: do you remember the background for the revert in 6.0.1xx-preview10? 2229ccc
xamarin-android on release/6.0.4xx is using commit 2a882d2d, which does contain 8ccb837 and does not contain the revert in 2229ccc, so as far as I can tell .NET 6 currently contains 8ccb837.
jonathanpeppers commentedon Mar 30, 2023
I'm not sure why I didn't put that information here: dotnet/android#6426
My memory is there was some error caused by it, and we just wanted to revert for this one release.
But then I don't see a java.interop commit that "fixes" something caused by 8ccb837.
jonpryor commentedon Mar 30, 2023
"Repro steps":
curl -o tensorflow-android-1.13.1.aar https://repo1.maven.org/maven2/org/tensorflow/tensorflow-android/1.13.1/tensorflow-android-1.13.1.aar unzip tensorflow-android-1.13.1.aar classes.jar dotnet path/to/class-parse.dll classes.jar # boomThe assert is triggered when processing the constructor for
org/tensorflow/Session$Runner$Reference.class-parse.exe --dumpshows:which is to say that the only constructor accepts 1 parameter, but that parameter is named
this. What is (probably) happening isSession.Runner.Referenceis a non-static inner class ofSession.Runner, and as such its constructor requires a reference of its enclosing type.Aside:
.class version 52.0is JDK 1.8.So we look at this block of code: https://github.com/xamarin/java.interop/blob/909239d4b70e5367e2d47e6ce60a2b399830324a/src/Xamarin.Android.Tools.Bytecode/Methods.cs#L297-L307
Turns Out™ that for the "offending" method,
pinfo[0].AccessFlagsisFinal, Synthetic(0x1010), while what we were looking for -- in the form ofOuterThis-- wasFinal, Mandated(0x8010). The actual value is what we expected for a "outer this reference", so we didn't skip it, which caused the assert to fire.jonpryor commentedon Mar 30, 2023
I don't know why tensorflow is using
Final, Syntheticinstead ofFinal, Mandated. I suspect a compiler bug of some form?jpobst commentedon Mar 30, 2023
Another example is https://mvnrepository.com/artifact/com.google.crypto.tink/tink-android/1.8.0.
However, this appears to be the same issue, as it is also
Final, Synthetic.[Xamarin.Android.Tools.Bytecode] Ignore synthetic ctor params
[Xamarin.Android.Tools.Bytecode] Ignore synthetic ctor params (#1091)
Bump to xamarin/Java.Interop/main@0355acf (#7931)
[Xamarin.Android.Tools.Bytecode] Ignore synthetic ctor params (#1091)