Skip to content

[TrimmableTypeMap] Add GetStaticMethodFallbackTypesCore override for desugared default interface methods#11050

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-getstaticmethodfallbacktypescore-override
Draft

[TrimmableTypeMap] Add GetStaticMethodFallbackTypesCore override for desugared default interface methods#11050
Copilot wants to merge 2 commits intomainfrom
copilot/add-getstaticmethodfallbacktypescore-override

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

Adds GetStaticMethodFallbackTypesCore override to TrimmableTypeMapTypeManager to support Java 8+ default interface methods desugared by D8/R8.

Problem

TrimmableTypeMapTypeManager did not override GetStaticMethodFallbackTypesCore(). Without this, calls to desugared default interface methods fail with NoSuchMethodError at runtime when using the trimmable type map. This affects any app using Java libraries with default interface methods (Java 8+ feature, very common in modern Android libraries like AndroidX).

Fix

Added the same override that already exists in ManagedTypeManager to TrimmableTypeMapTypeManager:

protected override IReadOnlyList<string>? GetStaticMethodFallbackTypesCore(string jniSimpleReference)
{
    int slash = jniSimpleReference.LastIndexOf('/');
    var desugarType = slash > 0
        ? $"{jniSimpleReference.Substring(0, slash + 1)}Desugar{jniSimpleReference.Substring(slash + 1)}"
        : $"Desugar{jniSimpleReference}";
    return new[] {
        $"{desugarType}$_CC",
        $"{jniSimpleReference}$-CC",
    };
}

This generates two fallback type names for desugared companion classes (Desugar{Type}$_CC and {Type}$-CC) so that JNI static method lookups on desugared default interface methods succeed at runtime.

@simonrozsival
Copy link
Copy Markdown
Member

@copilot continue

…Manager

Agent-Logs-Url: https://github.com/dotnet/android/sessions/1eb1fc88-df89-4cb7-bd45-15187eea3776

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 31, 2026

@copilot continue

Added the GetStaticMethodFallbackTypesCore override to TrimmableTypeMapTypeManager in c0a25a0. The implementation is a direct copy from ManagedTypeManager, generating the two desugar fallback type names (Desugar...$_CC and ...$-CC) needed for D8/R8-desugared default interface methods.

Copilot AI changed the title [WIP] Add GetStaticMethodFallbackTypesCore override for TrimmableTypeMap [TrimmableTypeMap] Add GetStaticMethodFallbackTypesCore override for desugared default interface methods Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TrimmableTypeMap] Add GetStaticMethodFallbackTypesCore override for desugared default interface methods

2 participants