Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
-keep class net.dot.android.crypto.** { *; <init>(...); }
# NativeAOT resolves these interface methods through JNI during startup.
-keep class mono.android.IGCUserPeer { *; }
# The GC bridge constructs temporary peers and calls these methods through JNI.
-keep class mono.android.GCUserPeer {
<init>();
public void monodroidAddReference(java.lang.Object);
public void monodroidClearReferences();
}
# Native hosts resolve these package-private fields by name during startup.
-keepclassmembers class mono.android.Runtime {
static java.lang.Class *;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,38 @@ public void Build_WithTrimmableTypeMap_KeepsNativeAotRuntimeHostAcws ()
$"`{dexFile}` should include the UncaughtExceptionMarshaler runtime ACW.");
}

[Test]
public void Build_WithTrimmableTypeMap_KeepsNativeAotGcBridgeTemporaryPeer ()
{
const bool isRelease = true;
if (IgnoreUnsupportedConfiguration (AndroidRuntime.NativeAOT, release: isRelease)) {
return;
}

var proj = new XamarinAndroidApplicationProject {
IsRelease = isRelease,
LinkTool = "r8",
};
proj.SetRuntime (AndroidRuntime.NativeAOT);
proj.SetProperty ("AndroidTypeMapImplementation", "trimmable");

using var builder = CreateApkBuilder ();
Assert.IsTrue (builder.Build (proj), "Build should have succeeded.");

var dexDirectory = builder.Output.GetIntermediaryPath (Path.Combine ("android", "bin"));
var dexFiles = Directory.GetFiles (dexDirectory, "classes*.dex");
Assert.IsNotEmpty (dexFiles, "R8 should produce DEX files.");
foreach (var (method, signature) in new [] {
("<init>", "()V"),
("monodroidAddReference", "(Ljava/lang/Object;)V"),
("monodroidClearReferences", "()V"),
}) {
Assert.IsTrue (dexFiles.Any (dex => DexUtils.ContainsClassWithMethod (
"Lmono/android/GCUserPeer;", method, signature, dex, AndroidSdkPath)),
$"R8 must preserve GCUserPeer.{method}{signature} for the native GC bridge.");
Comment thread
jonathanpeppers marked this conversation as resolved.
}
}

[Test]
public void Build_WithTrimmableTypeMap_DeletesStaleGeneratedJavaSources ()
{
Expand Down
Loading