[TrimmableTypeMap] Pass TargetType and InvokerType through JavaPeerProxy constructor#11092
Merged
simonrozsival merged 1 commit intomainfrom Apr 9, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes trimmable typemap proxy generation so JavaPeerProxy.InvokerType is properly overridden on generated proxy types (instead of being emitted as a hidden new member), enabling runtime resolution of interface invoker types.
Changes:
- Emit
get_InvokerTypewithMethodAttributes.Virtualto correctly overrideJavaPeerProxy.InvokerType.
4 tasks
38e3262 to
5451150
Compare
ced4c5f to
ff0ef65
Compare
ff0ef65 to
7faf5f5
Compare
…oxy constructor Replace virtual property overrides for both TargetType and InvokerType with constructor parameters. The generated proxy ctor now calls base(typeof(Target), typeof(Invoker)) or base(typeof(Target), null), storing both values in readonly fields. No virtual dispatch needed. Before (two virtual overrides per proxy): public override Type TargetType => typeof(Activity); public override Type? InvokerType => typeof(IActivityInvoker); After (ctor params, field reads): protected JavaPeerProxy(Type targetType, Type? invokerType) // Generated: base(typeof(Activity), typeof(IActivityInvoker)) This also fixes the original bug where get_InvokerType was emitted without MethodAttributes.Virtual, causing the base class to always return null. With the constructor approach, virtual dispatch is eliminated entirely for both properties. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
7faf5f5 to
e70f93a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TargetTypeandInvokerTypeon generated proxy types were implemented as virtual property overrides. This had two issues:Bug:
get_InvokerTypewas emitted withoutMethodAttributes.Virtual, making it anewmethod. When accessed via the baseJavaPeerProxyreference, the base returnednull, preventing interface invoker types from being resolved.Performance: Every access went through vtable dispatch for values that never change after construction.
Fix
Replace both virtual overrides with constructor parameters:
Generated proxy ctor:
base(typeof(Activity), typeof(IActivityInvoker))orbase(typeof(Button), null).JavaPeerProxy<T>updated to passtypeof(T)through base ctor instead of overridingTargetType.Files changed
JavaPeerProxy.cs— Single(Type, Type?)ctor; both properties areget-only fields;JavaPeerProxy<T>chainsbase(typeof(T), invokerType)TypeMapAssemblyEmitter.cs— Emitldtoken TargetType+ldtoken InvokerType/ldnull+base(Type, Type?)in proxy ctor; removeget_TargetTypeandget_InvokerTypeoverrides