Skip to content

Commit 8e18c90

Browse files
authored
[generator] Avoid C#11 delegate cache overhead. (#1053)
Fixes: #1034 Context: dotnet/roslyn#62832 (comment) Context: Context: dotnet/android@938b2cb [The C#11 compiler was updated][0] so that "method group conversions" are now cached: > The C# 11 compiler caches the delegate object created from a method > group conversion and reuses that single delegate object. Our marshal method infrastructure uses method group conversions, e.g. the cast to `(_JniMarshal_PP_L)` is a method group conversion: static Delegate GetGetActionBarHandler () { if (cb_getActionBar == null) cb_getActionBar = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetActionBar); return cb_getActionBar; } This C# 11 compiler change resulted in `Mono.Android.dll` and .NET Android apps being ~4.5% *larger*. This was worked around in dotnet/android@938b2cbe by setting `$(LangVersion)`=10 (i.e. "don't use C# 11"). Update `generator` output to avoid use of method group conversion for delegate types. This allows us to use C# 11 without increasing the size of `Mono.Android.dll` and .NET Android apps: static Delegate GetGetActionBarHandler () { if (cb_getActionBar == null) cb_getActionBar = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_L (n_GetActionBar)); return cb_getActionBar; } [0]: https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-11#improved-method-group-conversion-to-delegate
1 parent 2d8b6d2 commit 8e18c90

File tree

61 files changed

+167
-158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+167
-158
lines changed

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/Common/WriteDuplicateInterfaceEventArgs.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ internal partial class AnimatorListenerInvoker : global::Java.Lang.Object, Anima
7171
static Delegate GetOnAnimationEnd_IHandler ()
7272
{
7373
if (cb_OnAnimationEnd_I == null)
74-
cb_OnAnimationEnd_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_Z) n_OnAnimationEnd_I);
74+
cb_OnAnimationEnd_I = JNINativeWrapper.CreateDelegate (new _JniMarshal_PPI_Z (n_OnAnimationEnd_I));
7575
return cb_OnAnimationEnd_I;
7676
}
7777

@@ -97,7 +97,7 @@ internal partial class AnimatorListenerInvoker : global::Java.Lang.Object, Anima
9797
static Delegate GetOnAnimationEnd_IIHandler ()
9898
{
9999
if (cb_OnAnimationEnd_II == null)
100-
cb_OnAnimationEnd_II = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPII_Z) n_OnAnimationEnd_II);
100+
cb_OnAnimationEnd_II = JNINativeWrapper.CreateDelegate (new _JniMarshal_PPII_Z (n_OnAnimationEnd_II));
101101
return cb_OnAnimationEnd_II;
102102
}
103103

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/Common/WriteInterfaceRedeclaredDefaultMethod.txt

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,77 +4,86 @@ public partial interface IMyInterface2 : java.code.IMyInterface {
44
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/interface[@name='IMyInterface']/method[@name='DoSomething' and count(parameter)=0]"
55
[Register ("DoSomething", "()V", "GetDoSomethingHandler:java.code.IMyInterface2Invoker, MyAssembly")]
66
void DoSomething ();
7-
7+
88
}
9+
910
[global::Android.Runtime.Register ("java/code/IMyInterface2", DoNotGenerateAcw=true)]
1011
internal partial class IMyInterface2Invoker : global::Java.Lang.Object, IMyInterface2 {
11-
static readonly JniPeerMembers _members = new JniPeerMembers ("java/code/IMyInterface2", typeof (IMyInterface2Invoker));
12-
12+
static readonly JniPeerMembers _members = new XAPeerMembers ("java/code/IMyInterface2", typeof (IMyInterface2Invoker));
13+
1314
static IntPtr java_class_ref {
1415
get { return _members.JniPeerType.PeerReference.Handle; }
1516
}
16-
17+
18+
[global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)]
19+
[global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)]
1720
public override global::Java.Interop.JniPeerMembers JniPeerMembers {
1821
get { return _members; }
1922
}
20-
23+
24+
[global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)]
25+
[global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)]
2126
protected override IntPtr ThresholdClass {
2227
get { return class_ref; }
2328
}
24-
29+
30+
[global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)]
31+
[global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)]
2532
protected override global::System.Type ThresholdType {
2633
get { return _members.ManagedPeerType; }
2734
}
28-
35+
2936
IntPtr class_ref;
30-
37+
3138
public static IMyInterface2 GetObject (IntPtr handle, JniHandleOwnership transfer)
3239
{
3340
return global::Java.Lang.Object.GetObject<IMyInterface2> (handle, transfer);
3441
}
35-
42+
3643
static IntPtr Validate (IntPtr handle)
3744
{
3845
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
39-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface2"));
46+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface2'.");
4047
return handle;
4148
}
42-
49+
4350
protected override void Dispose (bool disposing)
4451
{
4552
if (this.class_ref != IntPtr.Zero)
4653
JNIEnv.DeleteGlobalRef (this.class_ref);
4754
this.class_ref = IntPtr.Zero;
4855
base.Dispose (disposing);
4956
}
50-
57+
5158
public IMyInterface2Invoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer)
5259
{
5360
IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle);
5461
this.class_ref = JNIEnv.NewGlobalRef (local_ref);
5562
JNIEnv.DeleteLocalRef (local_ref);
5663
}
57-
64+
5865
static Delegate cb_DoSomething;
59-
#pragma warning disable 0169
66+
#pragma warning disable 0169
6067
static Delegate GetDoSomethingHandler ()
6168
{
6269
if (cb_DoSomething == null)
63-
cb_DoSomething = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_DoSomething);
70+
cb_DoSomething = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_V (n_DoSomething));
6471
return cb_DoSomething;
6572
}
73+
6674
static void n_DoSomething (IntPtr jnienv, IntPtr native__this)
6775
{
6876
var __this = global::Java.Lang.Object.GetObject<java.code.IMyInterface2> (jnienv, native__this, JniHandleOwnership.DoNotTransfer);
6977
__this.DoSomething ();
7078
}
71-
#pragma warning restore 0169
79+
#pragma warning restore 0169
80+
7281
IntPtr id_DoSomething;
7382
public unsafe void DoSomething ()
7483
{
7584
if (id_DoSomething == IntPtr.Zero)
7685
id_DoSomething = JNIEnv.GetMethodID (class_ref, "DoSomething", "()V");
7786
JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_DoSomething);
7887
}
79-
88+
8089
}

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1-NRT/WriteClass.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public partial class MyClass {
5454
static Delegate Getget_CountHandler ()
5555
{
5656
if (cb_get_Count == null)
57-
cb_get_Count = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_get_Count);
57+
cb_get_Count = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_I (n_get_Count));
5858
return cb_get_Count;
5959
}
6060

@@ -70,7 +70,7 @@ public partial class MyClass {
7070
static Delegate Getset_Count_IHandler ()
7171
{
7272
if (cb_set_Count_I == null)
73-
cb_set_Count_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_set_Count_I);
73+
cb_set_Count_I = JNINativeWrapper.CreateDelegate (new _JniMarshal_PPI_V (n_set_Count_I));
7474
return cb_set_Count_I;
7575
}
7676

@@ -110,7 +110,7 @@ public partial class MyClass {
110110
static Delegate Getget_KeyHandler ()
111111
{
112112
if (cb_get_Key == null)
113-
cb_get_Key = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_get_Key);
113+
cb_get_Key = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_L (n_get_Key));
114114
return cb_get_Key;
115115
}
116116

@@ -126,7 +126,7 @@ public partial class MyClass {
126126
static Delegate Getset_Key_Ljava_lang_String_Handler ()
127127
{
128128
if (cb_set_Key_Ljava_lang_String_ == null)
129-
cb_set_Key_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_set_Key_Ljava_lang_String_);
129+
cb_set_Key_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate (new _JniMarshal_PPL_V (n_set_Key_Ljava_lang_String_));
130130
return cb_set_Key_Ljava_lang_String_;
131131
}
132132

@@ -193,7 +193,7 @@ public partial class MyClass {
193193
static Delegate Getget_AbstractCountHandler ()
194194
{
195195
if (cb_get_AbstractCount == null)
196-
cb_get_AbstractCount = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_get_AbstractCount);
196+
cb_get_AbstractCount = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_I (n_get_AbstractCount));
197197
return cb_get_AbstractCount;
198198
}
199199

@@ -209,7 +209,7 @@ public partial class MyClass {
209209
static Delegate Getset_AbstractCount_IHandler ()
210210
{
211211
if (cb_set_AbstractCount_I == null)
212-
cb_set_AbstractCount_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_set_AbstractCount_I);
212+
cb_set_AbstractCount_I = JNINativeWrapper.CreateDelegate (new _JniMarshal_PPI_V (n_set_AbstractCount_I));
213213
return cb_set_AbstractCount_I;
214214
}
215215

@@ -235,7 +235,7 @@ public partial class MyClass {
235235
static Delegate GetGetCountForKey_Ljava_lang_String_Handler ()
236236
{
237237
if (cb_GetCountForKey_Ljava_lang_String_ == null)
238-
cb_GetCountForKey_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_GetCountForKey_Ljava_lang_String_);
238+
cb_GetCountForKey_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate (new _JniMarshal_PPL_I (n_GetCountForKey_Ljava_lang_String_));
239239
return cb_GetCountForKey_Ljava_lang_String_;
240240
}
241241

@@ -269,7 +269,7 @@ public partial class MyClass {
269269
static Delegate GetKeyHandler ()
270270
{
271271
if (cb_Key == null)
272-
cb_Key = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_Key);
272+
cb_Key = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_L (n_Key));
273273
return cb_Key;
274274
}
275275

@@ -308,7 +308,7 @@ public partial class MyClass {
308308
static Delegate GetAbstractMethodHandler ()
309309
{
310310
if (cb_AbstractMethod == null)
311-
cb_AbstractMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_AbstractMethod);
311+
cb_AbstractMethod = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_V (n_AbstractMethod));
312312
return cb_AbstractMethod;
313313
}
314314

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1-NRT/WriteInterface.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
135135
static Delegate Getget_CountHandler ()
136136
{
137137
if (cb_get_Count == null)
138-
cb_get_Count = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_get_Count);
138+
cb_get_Count = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_I (n_get_Count));
139139
return cb_get_Count;
140140
}
141141

@@ -151,7 +151,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
151151
static Delegate Getset_Count_IHandler ()
152152
{
153153
if (cb_set_Count_I == null)
154-
cb_set_Count_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_set_Count_I);
154+
cb_set_Count_I = JNINativeWrapper.CreateDelegate (new _JniMarshal_PPI_V (n_set_Count_I));
155155
return cb_set_Count_I;
156156
}
157157

@@ -184,7 +184,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
184184
static Delegate Getget_KeyHandler ()
185185
{
186186
if (cb_get_Key == null)
187-
cb_get_Key = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_get_Key);
187+
cb_get_Key = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_L (n_get_Key));
188188
return cb_get_Key;
189189
}
190190

@@ -200,7 +200,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
200200
static Delegate Getset_Key_Ljava_lang_String_Handler ()
201201
{
202202
if (cb_set_Key_Ljava_lang_String_ == null)
203-
cb_set_Key_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_set_Key_Ljava_lang_String_);
203+
cb_set_Key_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate (new _JniMarshal_PPL_V (n_set_Key_Ljava_lang_String_));
204204
return cb_set_Key_Ljava_lang_String_;
205205
}
206206

@@ -236,7 +236,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
236236
static Delegate Getget_AbstractCountHandler ()
237237
{
238238
if (cb_get_AbstractCount == null)
239-
cb_get_AbstractCount = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_get_AbstractCount);
239+
cb_get_AbstractCount = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_I (n_get_AbstractCount));
240240
return cb_get_AbstractCount;
241241
}
242242

@@ -252,7 +252,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
252252
static Delegate Getset_AbstractCount_IHandler ()
253253
{
254254
if (cb_set_AbstractCount_I == null)
255-
cb_set_AbstractCount_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_set_AbstractCount_I);
255+
cb_set_AbstractCount_I = JNINativeWrapper.CreateDelegate (new _JniMarshal_PPI_V (n_set_AbstractCount_I));
256256
return cb_set_AbstractCount_I;
257257
}
258258

@@ -285,7 +285,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
285285
static Delegate GetGetCountForKey_Ljava_lang_String_Handler ()
286286
{
287287
if (cb_GetCountForKey_Ljava_lang_String_ == null)
288-
cb_GetCountForKey_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_GetCountForKey_Ljava_lang_String_);
288+
cb_GetCountForKey_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate (new _JniMarshal_PPL_I (n_GetCountForKey_Ljava_lang_String_));
289289
return cb_GetCountForKey_Ljava_lang_String_;
290290
}
291291

@@ -316,7 +316,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
316316
static Delegate GetKeyHandler ()
317317
{
318318
if (cb_Key == null)
319-
cb_Key = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_Key);
319+
cb_Key = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_L (n_Key));
320320
return cb_Key;
321321
}
322322

@@ -340,7 +340,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
340340
static Delegate GetAbstractMethodHandler ()
341341
{
342342
if (cb_AbstractMethod == null)
343-
cb_AbstractMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_AbstractMethod);
343+
cb_AbstractMethod = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_V (n_AbstractMethod));
344344
return cb_AbstractMethod;
345345
}
346346

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1-NRT/WriteMethodWithCharSequenceArrays.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public partial class MyClass : Java.Lang.Object {
3434
static Delegate GetEcho_arrayLjava_lang_CharSequence_Handler ()
3535
{
3636
if (cb_echo_arrayLjava_lang_CharSequence_ == null)
37-
cb_echo_arrayLjava_lang_CharSequence_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_L) n_Echo_arrayLjava_lang_CharSequence_);
37+
cb_echo_arrayLjava_lang_CharSequence_ = JNINativeWrapper.CreateDelegate (new _JniMarshal_PPL_L (n_Echo_arrayLjava_lang_CharSequence_));
3838
return cb_echo_arrayLjava_lang_CharSequence_;
3939
}
4040

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteClass.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public partial class MyClass {
5454
static Delegate Getget_CountHandler ()
5555
{
5656
if (cb_get_Count == null)
57-
cb_get_Count = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_get_Count);
57+
cb_get_Count = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_I (n_get_Count));
5858
return cb_get_Count;
5959
}
6060

@@ -70,7 +70,7 @@ public partial class MyClass {
7070
static Delegate Getset_Count_IHandler ()
7171
{
7272
if (cb_set_Count_I == null)
73-
cb_set_Count_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_set_Count_I);
73+
cb_set_Count_I = JNINativeWrapper.CreateDelegate (new _JniMarshal_PPI_V (n_set_Count_I));
7474
return cb_set_Count_I;
7575
}
7676

@@ -110,7 +110,7 @@ public partial class MyClass {
110110
static Delegate Getget_KeyHandler ()
111111
{
112112
if (cb_get_Key == null)
113-
cb_get_Key = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_get_Key);
113+
cb_get_Key = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_L (n_get_Key));
114114
return cb_get_Key;
115115
}
116116

@@ -126,7 +126,7 @@ public partial class MyClass {
126126
static Delegate Getset_Key_Ljava_lang_String_Handler ()
127127
{
128128
if (cb_set_Key_Ljava_lang_String_ == null)
129-
cb_set_Key_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_set_Key_Ljava_lang_String_);
129+
cb_set_Key_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate (new _JniMarshal_PPL_V (n_set_Key_Ljava_lang_String_));
130130
return cb_set_Key_Ljava_lang_String_;
131131
}
132132

@@ -193,7 +193,7 @@ public partial class MyClass {
193193
static Delegate Getget_AbstractCountHandler ()
194194
{
195195
if (cb_get_AbstractCount == null)
196-
cb_get_AbstractCount = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_get_AbstractCount);
196+
cb_get_AbstractCount = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_I (n_get_AbstractCount));
197197
return cb_get_AbstractCount;
198198
}
199199

@@ -209,7 +209,7 @@ public partial class MyClass {
209209
static Delegate Getset_AbstractCount_IHandler ()
210210
{
211211
if (cb_set_AbstractCount_I == null)
212-
cb_set_AbstractCount_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_set_AbstractCount_I);
212+
cb_set_AbstractCount_I = JNINativeWrapper.CreateDelegate (new _JniMarshal_PPI_V (n_set_AbstractCount_I));
213213
return cb_set_AbstractCount_I;
214214
}
215215

@@ -235,7 +235,7 @@ public partial class MyClass {
235235
static Delegate GetGetCountForKey_Ljava_lang_String_Handler ()
236236
{
237237
if (cb_GetCountForKey_Ljava_lang_String_ == null)
238-
cb_GetCountForKey_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_GetCountForKey_Ljava_lang_String_);
238+
cb_GetCountForKey_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate (new _JniMarshal_PPL_I (n_GetCountForKey_Ljava_lang_String_));
239239
return cb_GetCountForKey_Ljava_lang_String_;
240240
}
241241

@@ -269,7 +269,7 @@ public partial class MyClass {
269269
static Delegate GetKeyHandler ()
270270
{
271271
if (cb_Key == null)
272-
cb_Key = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_Key);
272+
cb_Key = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_L (n_Key));
273273
return cb_Key;
274274
}
275275

@@ -308,7 +308,7 @@ public partial class MyClass {
308308
static Delegate GetAbstractMethodHandler ()
309309
{
310310
if (cb_AbstractMethod == null)
311-
cb_AbstractMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_AbstractMethod);
311+
cb_AbstractMethod = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_V (n_AbstractMethod));
312312
return cb_AbstractMethod;
313313
}
314314

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteDefaultInterfaceMethodInvoker.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public partial interface IMyInterface : IJavaObject, IJavaPeerable {
1212
private static Delegate GetDoDefaultHandler ()
1313
{
1414
if (cb_DoDefault == null)
15-
cb_DoDefault = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_DoDefault);
15+
cb_DoDefault = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_V (n_DoDefault));
1616
return cb_DoDefault;
1717
}
1818

@@ -96,7 +96,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
9696
static Delegate GetDoDeclarationHandler ()
9797
{
9898
if (cb_DoDeclaration == null)
99-
cb_DoDeclaration = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_DoDeclaration);
99+
cb_DoDeclaration = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_V (n_DoDeclaration));
100100
return cb_DoDeclaration;
101101
}
102102

0 commit comments

Comments
 (0)