The CodeGenerationTarget enum / AndroidCodegenTarget MSBuild property historically had three values:
XamarinAndroid - classic/legacy codegen target; obsolete and no longer supported.
XAJavaInterop1 - current supported/default .NET for Android target.
JavaInterop1 - experimental value from the first NativeAOT/Java.Interop exploration.
JavaInterop1 should be removed as a public/documented Android codegen value, and we should also remove the underlying JavaPeerStyle.JavaInterop1 / generator support once the remaining internal NativeAOT references are cleaned up.
Why this should be removable
The current NativeAOT/trimmable path does not need the JavaInterop1 Java peer generator shape:
- The supported/default NativeAOT path uses the trimmable type map (
_AndroidTypeMapImplementation=trimmable), and the trimmable type map has its own Java generator. It does not need to call the Java peer generator that emits net.dot.jni.ManagedPeer.* / JavaPeerStyle.JavaInterop1 style Java classes.
- We don't need to use the JI1 style for Java classes anymore. It gets in the way more than it helps now that the trimmable type map owns the generated Java source shape.
- The GC bridge currently has a distinction between CoreCLR and NativeAOT. Removing the remaining JavaInterop1-style split should let us align both paths around 100% shared native code.
- The public docs now say
JavaInterop1 is obsolete/no longer supported, leaving XAJavaInterop1 as the supported value for AndroidCodegenTarget.
Current source still has one important internal reference to migrate/remove:
That should be treated as cleanup work, not as a reason to keep the public experimental target.
Relevant history
Possible cleanup steps
- Remove
JavaInterop1 from the documented/public AndroidCodegenTarget surface if any remaining acceptance path still exists.
- Replace/remove the NativeAOT
$(_AndroidJcwCodegenTarget)=JavaInterop1 default.
- Remove
JavaPeerStyle.JavaInterop1 use from the dotnet/android build path.
- Remove Java.Interop generator/codegen branches that only exist for
CodeGenerationTarget.JavaInterop1, once the NativeAOT/trimmable path no longer consumes them.
- Decide whether the trimmable type map Java shape needs a distinct internal name/specification (for example an
XAJavaInterop2-style label), or whether it is simply the trimmable typemap Java generator and does not need to be represented as an AndroidCodegenTarget value.
The
CodeGenerationTargetenum /AndroidCodegenTargetMSBuild property historically had three values:XamarinAndroid- classic/legacy codegen target; obsolete and no longer supported.XAJavaInterop1- current supported/default .NET for Android target.JavaInterop1- experimental value from the first NativeAOT/Java.Interop exploration.JavaInterop1should be removed as a public/documented Android codegen value, and we should also remove the underlyingJavaPeerStyle.JavaInterop1/ generator support once the remaining internal NativeAOT references are cleaned up.Why this should be removable
The current NativeAOT/trimmable path does not need the JavaInterop1 Java peer generator shape:
_AndroidTypeMapImplementation=trimmable), and the trimmable type map has its own Java generator. It does not need to call the Java peer generator that emitsnet.dot.jni.ManagedPeer.*/JavaPeerStyle.JavaInterop1style Java classes.JavaInterop1is obsolete/no longer supported, leavingXAJavaInterop1as the supported value forAndroidCodegenTarget.Current source still has one important internal reference to migrate/remove:
$(_AndroidJcwCodegenTarget)=JavaInterop1: https://github.com/dotnet/android/blob/main/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets#L19That should be treated as cleanup work, not as a reason to keep the public experimental target.
Relevant history
xamarin/Java.Interop: the imported generator already hadXamarinAndroid,XAJavaInterop1, andJavaInterop1in the 2016 generator import: dotnet/java-interop@d1deb90. SoJavaInterop1is not simply older thanXAJavaInterop1; the real legacy target wasXamarinAndroid.dotnet/android:XAJavaInterop1became the Android default in dcab2da / [Xamarin.Android.Build.Tasks] AndroidCodegenTarget=XAJavaInterop1 #1774. The commit message saysXAJavaInterop1moved generator output toJava.Interop.JniPeerMembersinstead of legacyAndroid.Runtime.JNIEnv, with memory/perf benefits.xamarin/Java.Interop: support for--codegen-target=XamarinAndroidwas removed in dotnet/java-interop@d41793a / [generator] Remove obsolete 'XamarinAndroid' codegen target. java-interop#1121. The commit message callsXamarinAndroidClassic-only and says .NET Android needed theJniPeerMembers/DIM-capable path.xamarin/Java.Interop: the NativeAOT Android sample added in dotnet/java-interop@78d5937 / [Hello-NativeAOTFromAndroid] Add NativeAOT+Android sample java-interop#1218 documents the originalJavaInterop1NativeAOT experiment. The README saysXAJavaInterop1bakes marshal methods into binding assemblies, whileJavaInterop1skips that sojnimarshalmethod-gencan insert NativeAOT-compatible marshal methods later.dotnet/android: 0edc16d / [Xamarin.Android.Build.Tasks] introduce$(_AndroidJcwCodegenTarget)#9858 introduced$(_AndroidJcwCodegenTarget)to split Java stub/JCW generation from the public C# generator$(AndroidCodegenTarget). The commit message saysgenerator --codegen-target=JavaInterop1is experimental and should not be used for the public AndroidCodegenTarget path, then states the NativeAOT defaults became:$(_AndroidJcwCodegenTarget)=JavaInterop1$(AndroidCodegenTarget)=XAJavaInterop1Possible cleanup steps
JavaInterop1from the documented/publicAndroidCodegenTargetsurface if any remaining acceptance path still exists.$(_AndroidJcwCodegenTarget)=JavaInterop1default.JavaPeerStyle.JavaInterop1use from the dotnet/android build path.CodeGenerationTarget.JavaInterop1, once the NativeAOT/trimmable path no longer consumes them.XAJavaInterop2-style label), or whether it is simply the trimmable typemap Java generator and does not need to be represented as anAndroidCodegenTargetvalue.