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 @@ -177,10 +177,18 @@ static void EmitPeers (TypeMapAssemblyData model, string jniName,
}

// Base JNI name entry → alias holder (self-referencing trim target, kept alive by associations)
// When ForceUnconditionalEntries is true we MUST emit this as 2-arg (unconditional) just
// like BuildEntry does: dotnet/runtime#127004 strips the TypeMapAssociation that keeps the
// holder alive when a TypeMap entry references the same type, leaving the dictionary key
// missing at runtime and breaking hierarchy lookups for essential types like
// java/lang/String and java/lang/Object.
bool aliasBaseUnconditional = ForceUnconditionalEntries
|| EssentialRuntimeTypes.Contains (jniName)
|| peersForName.Any (IsUnconditionalEntry);
model.Entries.Add (new TypeMapAttributeData {
JniName = jniName,
ProxyTypeReference = holderRef,
TargetTypeReference = holderRef,
TargetTypeReference = aliasBaseUnconditional ? null : holderRef,
});
Comment on lines +185 to 192
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new alias-base unconditional decision (aliasBaseUnconditional) is a key trimming workaround, but there doesn’t appear to be a unit/integration test asserting that the base alias entry (e.g., "test/Dup" → holder) is emitted as a 2-arg/unconditional TypeMap attribute (i.e., TargetTypeReference == null) when ForceUnconditionalEntries is enabled (and/or when any peer in the alias group is unconditional). Adding a regression test for this would help prevent reintroducing the original issue where only the indexed entries honored ForceUnconditionalEntries.

Copilot uses AI. Check for mistakes.

model.AliasHolders.Add (new AliasHolderData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ protected NUnitInstrumentation(IntPtr handle, JniHandleOwnership transfer)
// Throwable subclass registration
"Java.InteropTests.JnienvTest.ActivatedDirectThrowableSubclassesShouldBeRegistered",

// Typemap doesn't resolve most-derived type
"Java.LangTests.ObjectTest.GetObject_ReturnsMostDerivedType",

// Instance identity after JNI round-trip
"Java.LangTests.ObjectTest.JnienvCreateInstance_RegistersMultipleInstances",

Expand Down