-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Description
We noticed this happening on both of these PRs:
- [main] Update dependencies from dotnet/sdk android#9031
- [release/9.0.1xx-preview6] Update dependencies from dotnet/sdk android#9051
We have a test failure:
Xamarin.Android.JcwGen_Tests, Xamarin.Android.JcwGenTests.BindingTests.JavaAbstractMethodTest / Release
Error message
System.TypeLoadException : VTable setup of type Library.MyClrCursor failed
Stack trace
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object , BindingFlags )
This test is verifying that this trimmer step works:
- https://github.com/dotnet/android/blob/e9ee3d4cc35edd5986629d2d5a5415ff93dbe0d5/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ILLink.targets#L60
- https://github.com/dotnet/android/blob/e9ee3d4cc35edd5986629d2d5a5415ff93dbe0d5/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/FixAbstractMethodsStep.cs#L305
What the trimmer step does, is attempt to "fill in" new abstract members of new Android APIs. This would allow existing net8.0-android NuGet packages to work in .NET 9, when Android adds new abstract members. (unfortunately Google does!). The general idea, is we'd prevent an exception unless the new member was actually called.
It seems like our trimmer step is doing its work:
ILLink: Added method: System.Void Test.Bindings.ICursor::NewMethod() to type: Library.MyClrCursor scope: Xamarin.Android.FixJavaAbstractMethod-Library.dll
ILLink: Added method: System.Int32 Test.Bindings.ICursor::NewMethodWithParams(System.Int32,System.String) to type: Library.MyClrCursor scope: Xamarin.Android.FixJavaAbstractMethod-Library.dll
ILLink: Added method: System.Int32 Test.Bindings.ICursor::NewMethodWithParams(System.Int32,System.String,System.Single) to type: Library.MyClrCursor scope: Xamarin.Android.FixJavaAbstractMethod-Library.dll
ILLink: Added method: System.Int32 Test.Bindings.ICursor::NewMethodWithRT() to type: Library.MyClrCursor scope: Xamarin.Android.FixJavaAbstractMethod-Library.dll
But we don't see the changes in illink's output.
Reproduction Steps
- Build .NET for Android
- Run test project
.\dotnet-local.cmd build tests\CodeGen-Binding\Xamarin.Android.JcwGen-Tests\Xamarin.Android.JcwGen-Tests.csproj -c Release -t:Install,RunTestApks --p:_ExtraTrimmerArgs=--verbose
Expected behavior
JavaAbstractMethodTest passes
Actual behavior
JavaAbstractMethodTest fails with TypeLoadException
Regression?
Yes, this worked in .NET 9 Preview 5
Known Workarounds
None
Configuration
Runtime: 9.0.0-preview.6.24321.8 or newer
Other information
.binlog: illink-verbose.zip
Output assemblies: linked.zip
Metadata
Metadata
Assignees
Labels
Type
Projects
Status