Summary
On the NativeAOT TrimmableTypeMap build path, Java Callable Wrapper (JCW) generation is metadata-driven, not usage/trimming-aware. The scanner emits a JCW for every [Register]/Java-peer type it finds (JavaPeerScanner), regardless of whether ILC will trim that type. On the CoreCLR/illink path, unused framework types are removed before JCW generation, so their JCWs (and any associated lint/build warnings) never appear.
Impact
NativeAOT builds emit extra Java sources and warnings for framework types that are unused by the app. Example: Xamarin.Android.Net.ServerCertificateCustomValidator produces ServerCertificateCustomValidator_TrustManager.java, which trips XA0102 [CustomX509TrustManager] lint. illink removes this type on CoreCLR, so the warning does not occur there.
This is the reason the following Xamarin.Android.Build.Tests warning assertions are currently skipped on NativeAOT (with a reference to this issue):
BuildTest.CheckLintErrorsAndWarnings (XA0102 assertion)
Proposed work
Make JCW generation trimming-aware so NativeAOT only generates wrappers for types that survive trimming (e.g. integrate ILC's reachability, or run JCW generation against a trimmed view of the app). Once done, re-enable the skipped NativeAOT warning assertions.
Tracked as a follow-up to PR #11617.
Summary
On the NativeAOT
TrimmableTypeMapbuild path, Java Callable Wrapper (JCW) generation is metadata-driven, not usage/trimming-aware. The scanner emits a JCW for every[Register]/Java-peer type it finds (JavaPeerScanner), regardless of whether ILC will trim that type. On the CoreCLR/illink path, unused framework types are removed before JCW generation, so their JCWs (and any associated lint/build warnings) never appear.Impact
NativeAOT builds emit extra Java sources and warnings for framework types that are unused by the app. Example:
Xamarin.Android.Net.ServerCertificateCustomValidatorproducesServerCertificateCustomValidator_TrustManager.java, which tripsXA0102 [CustomX509TrustManager]lint. illink removes this type on CoreCLR, so the warning does not occur there.This is the reason the following
Xamarin.Android.Build.Testswarning assertions are currently skipped on NativeAOT (with a reference to this issue):BuildTest.CheckLintErrorsAndWarnings(XA0102 assertion)Proposed work
Make JCW generation trimming-aware so NativeAOT only generates wrappers for types that survive trimming (e.g. integrate ILC's reachability, or run JCW generation against a trimmed view of the app). Once done, re-enable the skipped NativeAOT warning assertions.
Tracked as a follow-up to PR #11617.