Skip to content

Commit

Permalink
[generator-Tests] Enable JavaInterop1 Integration output tests (#1271)
Browse files Browse the repository at this point in the history
Remaining Integration-Tests which don't support JavaInterop1:

  * Use of `Android.Runtime.GeneratedEnumAttribute`:

        CS0234: The type or namespace name 'GeneratedEnumAttribute' does not exist in the namespace 'Android.Runtime'

    Impacts: Core_Jar2Xml.cs

  * Use of `Android.Runtime.RegisterAttribute` on `*Implementor`
    types, probable missing event handler support:

        CS0234: The type or namespace name 'RegisterAttribute' does not exist in the namespace 'Android.Runtime'

        [Register ("mono/com/google/android/exoplayer/drm/ExoMediaDrm_OnEventListenerImplementor")]
        internal sealed partial class IExoMediaDrmOnEventListenerImplementor : global::Java.Lang.Object, IExoMediaDrmOnEventListener

    Impacts: GenericArguments.cs

  * Missing builtin mapping between collection types:

        warning BG8800: Unknown parameter type 'java.util.List<java.lang.Integer>' for member …
        warning BG8800: Unknown parameter type 'java.util.ArrayList<java.lang.Integer>' for member
        warning BG8400: Unexpected field type `java.util.List<java.lang.String>`

    Impacts: Java_Util_List.cs, NormalMethods.cs, ParameterXPath.cs

  * `Handle` isn't a public property in JavaInterop1, resulting in
    warning CS0109:

        CS0109: The member 'SomeObject.Handle(Object, Throwable)' does not hide an accessible member. The new keyword is not required.

    Impacts: NormalMethods.cs

  * Use of `JNIEnv.GetJniName()`

        string __id = "(L" + global::Android.Runtime.JNIEnv.GetJniName (GetType ().DeclaringType) + ";)V";

    Impacts: NestedTypes.cs
jonpryor authored Oct 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 2a1e180 commit 0aec86a
Showing 12 changed files with 152 additions and 18 deletions.
2 changes: 1 addition & 1 deletion tests/generator-Tests/Integration-Tests/Adapters.cs
Original file line number Diff line number Diff line change
@@ -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 ()
2 changes: 1 addition & 1 deletion tests/generator-Tests/Integration-Tests/Java_Lang_Enum.cs
Original file line number Diff line number Diff line change
@@ -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 ()
10 changes: 10 additions & 0 deletions tests/generator-Tests/expected.ji/Adapters/Java.Lang.Object.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

#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<global::global::Java.Lang.Object>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.Object>(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);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

#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<global::global::Java.Lang.Object>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.Object>(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);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

#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;";
Original file line number Diff line number Diff line change
@@ -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)
{
}

}
}
Original file line number Diff line number Diff line change
@@ -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)
{
}

}
}
14 changes: 12 additions & 2 deletions tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Enum.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

#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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}

}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

#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<global::Java.Lang.State> (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State >(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<global::Java.Lang.State> (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State >(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<global::Java.Lang.State> (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State >(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<global::Java.Lang.State> (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State >(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<global::Java.Lang.State> (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State >(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<global::Java.Lang.State> (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State >(ref __v, JniObjectReferenceOptions.Copy);
}
}

0 comments on commit 0aec86a

Please sign in to comment.