Skip to content

[TrimmableTypeMap] Runtime should walk Java interfaces when class hierarchy walk fails #11386

Closed

Description

@simonrozsival

Problem

The trimmable typemap runtime (TrimmableTypeMap.GetProxyForJavaObject) only walks the Java class hierarchy via getSuperclass() — it never checks Java interfaces. When an intermediate class entry is trimmed (e.g., javax/net/ssl/X509ExtendedTrustManager), the hierarchy walk cannot find a TypeMap entry for Java interfaces like javax/net/ssl/X509TrustManager, even though the entry exists in the trimmed TypeMap.

The llvm-ir typemap has the same limitation but masks it because its custom trimming mechanism preserves more class entries.

Example

TrustManagerFactory.GetTrustManagers() returns objects whose Java class hierarchy is:

com.android.org.conscrypt.TrustManagerImpl  → no TypeMap entry
javax.net.ssl.X509ExtendedTrustManager     → TRIMMED (nothing references it)
java.lang.Object                            → does not match ITrustManager

The interface entry javax/net/ssl/X509TrustManager → IX509TrustManagerInvoker is preserved but unreachable.

Suggested approach

Add a fallback Java interface walk (via JNI getInterfaces()) after the class hierarchy walk fails. This could potentially reuse the proxy mechanism similar to how array TypeMap entries work.

Investigation needed

  • Should we also preserve intermediate class entries (like X509ExtendedTrustManager) in the trimmable TypeMap to match llvm-ir behavior?
  • How to efficiently walk Java interfaces without excessive JNI calls
  • Whether this should be done in the TypeMap generator or at runtime

Activity

  1. added
    needs-triage
    on May 18, 2026
  2. added
    bug
    copilot
    and removed
    needs-triage
    on May 18, 2026
  3. added this to the .NET 11 milestone on May 18, 2026
  4. locked and limited conversation to collaborators on Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcopilottrimmable-type-map

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions