diff --git a/tests/generator-Tests/Integration-Tests/Adapters.cs b/tests/generator-Tests/Integration-Tests/Adapters.cs
index 417ee3811..d10be6e40 100644
--- a/tests/generator-Tests/Integration-Tests/Adapters.cs
+++ b/tests/generator-Tests/Integration-Tests/Adapters.cs
@@ -6,7 +6,7 @@ namespace generatortests
[TestFixture]
public class Adapters : BaseGeneratorTest
{
- protected override bool TryJavaInterop1 => false;
+ protected override bool TryJavaInterop1 => true;
[Test]
public void GeneratedOK ()
diff --git a/tests/generator-Tests/Integration-Tests/Java_Lang_Enum.cs b/tests/generator-Tests/Integration-Tests/Java_Lang_Enum.cs
index 2155e3beb..eb9451042 100644
--- a/tests/generator-Tests/Integration-Tests/Java_Lang_Enum.cs
+++ b/tests/generator-Tests/Integration-Tests/Java_Lang_Enum.cs
@@ -6,7 +6,7 @@ namespace generatortests
[TestFixture]
public class Java_Lang_Enum : BaseGeneratorTest
{
- protected override bool TryJavaInterop1 => false;
+ protected override bool TryJavaInterop1 => true;
[Test]
public void Generated_OK ()
diff --git a/tests/generator-Tests/expected.ji/Adapters/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/Adapters/Java.Lang.Object.cs
index 86d0bd17b..47f7f2661 100644
--- a/tests/generator-Tests/expected.ji/Adapters/Java.Lang.Object.cs
+++ b/tests/generator-Tests/expected.ji/Adapters/Java.Lang.Object.cs
@@ -1,3 +1,13 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
diff --git a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AbsSpinner.cs b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AbsSpinner.cs
index bc042e770..490730408 100644
--- a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AbsSpinner.cs
+++ b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AbsSpinner.cs
@@ -1,3 +1,13 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
@@ -64,20 +74,19 @@ public AbsSpinnerInvoker (ref JniObjectReference reference, JniObjectReferenceOp
const string __id = "getAdapter.()Lxamarin/test/Adapter;";
try {
var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null);
- return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
+ return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
} finally {
}
}
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='T']]"
set {
const string __id = "setAdapter.(Lxamarin/test/Adapter;)V";
- IntPtr native_value = JNIEnv.ToLocalJniHandle (value);
+ var native_value = (value?.PeerReference ?? default);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_value);
_members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args);
} finally {
- JNIEnv.DeleteLocalRef (native_value);
global::System.GC.KeepAlive (value);
}
}
diff --git a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AdapterView.cs b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AdapterView.cs
index 2d51d9e06..d87fd856a 100644
--- a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AdapterView.cs
+++ b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AdapterView.cs
@@ -1,3 +1,13 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
@@ -22,11 +32,11 @@ protected AdapterView (ref JniObjectReference reference, JniObjectReferenceOptio
protected abstract global::Java.Lang.Object RawAdapter {
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='getAdapter' and count(parameter)=0]"
- [Register ("getAdapter", "()Lxamarin/test/Adapter;", "GetGetAdapterHandler")]
+ [global::Java.Interop.JniMethodSignature ("getAdapter", "()Lxamarin/test/Adapter;")]
get;
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='T']]"
- [Register ("setAdapter", "(Lxamarin/test/Adapter;)V", "GetSetAdapter_Lxamarin_test_Adapter_Handler")]
+ [global::Java.Interop.JniMethodSignature ("setAdapter", "(Lxamarin/test/Adapter;)V")]
set;
}
@@ -52,20 +62,19 @@ public AdapterViewInvoker (ref JniObjectReference reference, JniObjectReferenceO
const string __id = "getAdapter.()Lxamarin/test/Adapter;";
try {
var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null);
- return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
+ return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
} finally {
}
}
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='T']]"
set {
const string __id = "setAdapter.(Lxamarin/test/Adapter;)V";
- IntPtr native_value = JNIEnv.ToLocalJniHandle (value);
+ var native_value = (value?.PeerReference ?? default);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_value);
_members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args);
} finally {
- JNIEnv.DeleteLocalRef (native_value);
global::System.GC.KeepAlive (value);
}
}
diff --git a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.GenericReturnObject.cs b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.GenericReturnObject.cs
index 01bdabfaa..2ddfe6c4d 100644
--- a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.GenericReturnObject.cs
+++ b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.GenericReturnObject.cs
@@ -1,3 +1,13 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
@@ -20,6 +30,7 @@ protected GenericReturnObject (ref JniObjectReference reference, JniObjectRefere
}
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='GenericReturnObject']/method[@name='GenericReturn' and count(parameter)=0]"
+ [global::Java.Interop.JniMethodSignature ("GenericReturn", "()Lxamarin/test/AdapterView;")]
public virtual unsafe global::Xamarin.Test.AdapterView GenericReturn ()
{
const string __id = "GenericReturn.()Lxamarin/test/AdapterView;";
diff --git a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs
index 65e5026e1..27e1271b2 100644
--- a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs
+++ b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs
@@ -8,4 +8,20 @@ namespace Xamarin.Test {
[global::Java.Interop.JniTypeSignature ("xamarin/test/Adapter", GenerateJavaPeer=false)]
public partial interface IAdapter : IJavaPeerable {
}
+
+ [global::Java.Interop.JniTypeSignature ("xamarin/test/Adapter", GenerateJavaPeer=false)]
+ internal partial class IAdapterInvoker : global::Java.Lang.Object, IAdapter {
+ [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)]
+ [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)]
+ public override global::Java.Interop.JniPeerMembers JniPeerMembers {
+ get { return _members_xamarin_test_Adapter; }
+ }
+
+ static readonly JniPeerMembers _members_xamarin_test_Adapter = new JniPeerMembers ("xamarin/test/Adapter", typeof (IAdapterInvoker));
+
+ public IAdapterInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options)
+ {
+ }
+
+ }
}
diff --git a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs
index 2a63a5060..c2219a950 100644
--- a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs
+++ b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs
@@ -8,4 +8,22 @@ namespace Xamarin.Test {
[global::Java.Interop.JniTypeSignature ("xamarin/test/SpinnerAdapter", GenerateJavaPeer=false)]
public partial interface ISpinnerAdapter : global::Xamarin.Test.IAdapter {
}
+
+ [global::Java.Interop.JniTypeSignature ("xamarin/test/SpinnerAdapter", GenerateJavaPeer=false)]
+ internal partial class ISpinnerAdapterInvoker : global::Java.Lang.Object, ISpinnerAdapter {
+ [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)]
+ [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)]
+ public override global::Java.Interop.JniPeerMembers JniPeerMembers {
+ get { return _members_xamarin_test_SpinnerAdapter; }
+ }
+
+ static readonly JniPeerMembers _members_xamarin_test_Adapter = new JniPeerMembers ("xamarin/test/Adapter", typeof (ISpinnerAdapterInvoker));
+
+ static readonly JniPeerMembers _members_xamarin_test_SpinnerAdapter = new JniPeerMembers ("xamarin/test/SpinnerAdapter", typeof (ISpinnerAdapterInvoker));
+
+ public ISpinnerAdapterInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options)
+ {
+ }
+
+ }
}
diff --git a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Enum.cs b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Enum.cs
index bbec25401..b9fc562c5 100644
--- a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Enum.cs
+++ b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Enum.cs
@@ -1,3 +1,13 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
@@ -21,17 +31,17 @@ protected Enum (ref JniObjectReference reference, JniObjectReferenceOptions opti
}
// Metadata.xml XPath method reference: path="/api/package[@name='java.lang']/class[@name='Enum']/method[@name='compareTo' and count(parameter)=1 and parameter[1][@type='E']]"
+ [global::Java.Interop.JniMethodSignature ("compareTo", "(Ljava/lang/Enum;)I")]
public unsafe int CompareTo (global::Java.Lang.Object o)
{
const string __id = "compareTo.(Ljava/lang/Enum;)I";
- IntPtr native_o = JNIEnv.ToLocalJniHandle (o);
+ var native_o = (o?.PeerReference ?? default);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_o);
var __rm = _members.InstanceMethods.InvokeNonvirtualInt32Method (__id, this, __args);
return __rm;
} finally {
- JNIEnv.DeleteLocalRef (native_o);
global::System.GC.KeepAlive (o);
}
}
diff --git a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs
index 3907f9f94..7514b0d00 100644
--- a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs
+++ b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs
@@ -9,7 +9,38 @@ namespace Java.Lang {
[global::Java.Interop.JavaTypeParameters (new string [] {"T"})]
public partial interface IComparable : IJavaPeerable {
// Metadata.xml XPath method reference: path="/api/package[@name='java.lang']/interface[@name='Comparable']/method[@name='compareTo' and count(parameter)=1 and parameter[1][@type='T']]"
+ [global::Java.Interop.JniMethodSignature ("compareTo", "(Ljava/lang/Object;)I")]
int CompareTo (global::Java.Lang.Object another);
}
+
+ [global::Java.Interop.JniTypeSignature ("java/lang/Comparable", GenerateJavaPeer=false)]
+ internal partial class IComparableInvoker : global::Java.Lang.Object, IComparable {
+ [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)]
+ [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)]
+ public override global::Java.Interop.JniPeerMembers JniPeerMembers {
+ get { return _members_java_lang_Comparable; }
+ }
+
+ static readonly JniPeerMembers _members_java_lang_Comparable = new JniPeerMembers ("java/lang/Comparable", typeof (IComparableInvoker));
+
+ public IComparableInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options)
+ {
+ }
+
+ public unsafe int CompareTo (global::Java.Lang.Object another)
+ {
+ const string __id = "compareTo.(Ljava/lang/Object;)I";
+ var native_another = (another?.PeerReference ?? default);
+ try {
+ JniArgumentValue* __args = stackalloc JniArgumentValue [1];
+ __args [0] = new JniArgumentValue (native_another);
+ var __rm = _members_java_lang_Comparable.InstanceMethods.InvokeAbstractInt32Method (__id, this, __args);
+ return __rm;
+ } finally {
+ global::System.GC.KeepAlive (another);
+ }
+ }
+
+ }
}
diff --git a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Object.cs
index 86d0bd17b..47f7f2661 100644
--- a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Object.cs
+++ b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Object.cs
@@ -1,3 +1,13 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
diff --git a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.State.cs b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.State.cs
index adf0c6bf8..ee78a59c3 100644
--- a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.State.cs
+++ b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.State.cs
@@ -1,3 +1,13 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
@@ -14,7 +24,7 @@ public sealed partial class State : global::Java.Lang.Enum {
const string __id = "BLOCKED.Ljava/lang/State;";
var __v = _members.StaticFields.GetObjectValue (__id);
- return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
+ return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue(ref __v, JniObjectReferenceOptions.Copy);
}
}
@@ -25,7 +35,7 @@ public sealed partial class State : global::Java.Lang.Enum {
const string __id = "NEW.Ljava/lang/State;";
var __v = _members.StaticFields.GetObjectValue (__id);
- return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
+ return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue(ref __v, JniObjectReferenceOptions.Copy);
}
}
@@ -36,7 +46,7 @@ public sealed partial class State : global::Java.Lang.Enum {
const string __id = "RUNNABLE.Ljava/lang/State;";
var __v = _members.StaticFields.GetObjectValue (__id);
- return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
+ return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue(ref __v, JniObjectReferenceOptions.Copy);
}
}
@@ -47,7 +57,7 @@ public sealed partial class State : global::Java.Lang.Enum {
const string __id = "TERMINATED.Ljava/lang/State;";
var __v = _members.StaticFields.GetObjectValue (__id);
- return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
+ return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue(ref __v, JniObjectReferenceOptions.Copy);
}
}
@@ -58,7 +68,7 @@ public sealed partial class State : global::Java.Lang.Enum {
const string __id = "TIMED_WAITING.Ljava/lang/State;";
var __v = _members.StaticFields.GetObjectValue (__id);
- return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
+ return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue(ref __v, JniObjectReferenceOptions.Copy);
}
}
@@ -69,7 +79,7 @@ public sealed partial class State : global::Java.Lang.Enum {
const string __id = "WAITING.Ljava/lang/State;";
var __v = _members.StaticFields.GetObjectValue (__id);
- return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
+ return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue(ref __v, JniObjectReferenceOptions.Copy);
}
}