You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[TrimmableTypeMap] Explore trimming optimization for Implementor and EventDispatcher types #10911
Implementor (e.g., IOnClickListenerImplementor) and EventDispatcher types are generated by the binding generator and are only instantiated from .NET code (e.g., when a C# event is subscribed). They are never instantiated from Java directly.
Currently, the TrimmableTypeMap treats them as unconditional ACW types (always preserved), matching the legacy type map behavior. However, these types are candidates for trimming — if the app never subscribes to the corresponding C# event, the Implementor/EventDispatcher and its JCW could be removed.
Proposed optimization
Use the 3-arg TypeMap attribute (trimmable) instead of the 2-arg (unconditional) for these types, allowing the trimmer to remove them when unused.
Considerations
Detection: These types have no special attributes. The binding generator gives Implementors a JNI name starting with mono/ and a managed name ending in Implementor. EventDispatchers follow a similar pattern. A heuristic combining JNI prefix + name suffix was prototyped in PR [TrimmableTypeMap] Add TypeMap proxy groundwork with CreateInstance #10808 but removed to avoid unintentional regressions.
Correctness: Need to verify that trimming these types doesn't break runtime behavior (e.g., if event subscription is done via reflection or late binding).
Test coverage: Need integration tests that verify trimmed apps still work correctly when events are and aren't used.
Alternative: The Java.Interop binding generator could be updated to emit a dedicated attribute or metadata flag on these types, making detection reliable without heuristics.
That PR removed the ForceUnconditionalEntries workaround and restored conditional/trimmable TypeMap entries for framework ACW helper types. The current model coverage also asserts framework ACWs are conditional rather than unconditionally rooting their proxy types, which covers the core Implementor/EventDispatcher trimming optimization tracked here.
If we want additional event-specific integration coverage, that should be tracked separately rather than keeping this optimization issue open.
Activity
[TrimmableTypeMap] Add TypeMap proxy groundwork with CreateInstance (#…
Revert Implementor/EventDispatcher heuristic — deferred to #10911
Revert Implementor/EventDispatcher heuristic — deferred to #10911
Revert Implementor/EventDispatcher heuristic — deferred to #10911
[TrimmableTypeMap] Add UCO wrappers, JCW generator, and JNI signature…
simonrozsival commentedon May 25, 2026
Closing as addressed by #11345.
That PR removed the ForceUnconditionalEntries workaround and restored conditional/trimmable TypeMap entries for framework ACW helper types. The current model coverage also asserts framework ACWs are conditional rather than unconditionally rooting their proxy types, which covers the core Implementor/EventDispatcher trimming optimization tracked here.
If we want additional event-specific integration coverage, that should be tracked separately rather than keeping this optimization issue open.