Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Mono.Android/Android.Runtime/AndroidRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ internal void RemovePeer (IJavaPeerable value, IntPtr hash)

public override void ActivatePeer (IJavaPeerable? self, JniObjectReference reference, ConstructorInfo cinfo, object? []? argumentValues)
{
Java.Interop.TypeManager.Activate (self, reference.Handle, cinfo, argumentValues);
Java.Interop.TypeManager.Activate (reference.Handle, cinfo, argumentValues);
}

protected override bool TryUnboxPeerObject (IJavaPeerable value, [NotNullWhen (true)]out object? result)
Expand Down
56 changes: 0 additions & 56 deletions src/Mono.Android/Android.Runtime/ConstructorBuilder.cs

This file was deleted.

15 changes: 11 additions & 4 deletions src/Mono.Android/Java.Interop/TypeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,21 @@ static void n_Activate (IntPtr jnienv, IntPtr jclass, IntPtr typename_ptr, IntPt
return;
}

Activate (o, jobject, cinfo, parms);
Activate (jobject, cinfo, parms);
}

internal static void Activate (IJavaPeerable? o, IntPtr jobject, ConstructorInfo cinfo, object? []? parms)
internal static void Activate (IntPtr jobject, ConstructorInfo cinfo, object? []? parms)
{
try {
var activator = ConstructorBuilder.CreateDelegate (cinfo);
activator (jobject, parms);
var newobj = RuntimeHelpers.GetUninitializedObject (cinfo.DeclaringType);
if (newobj is Java.Lang.Object o) {
o.handle = jobject;
} else if (newobj is Java.Lang.Throwable throwable) {
throwable.handle = jobject;
} else {
throw new InvalidOperationException ($"Unsupported type: '{newobj}'");
}
cinfo.Invoke (newobj, parms);
} catch (Exception e) {
var m = string.Format ("Could not activate JNI Handle 0x{0} (key_handle 0x{1}) of Java type '{2}' as managed type '{3}'.",
jobject.ToString ("x"), JNIEnv.IdentityHash! (jobject).ToString ("x"), JNIEnv.GetClassNameFromInstance (jobject), cinfo.DeclaringType.FullName);
Expand Down
2 changes: 1 addition & 1 deletion src/Mono.Android/Java.Lang/Object.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public partial class Object : IDisposable, IJavaObject, IJavaObjectEx
[NonSerialized] int refs_added;
#pragma warning restore CS0649, CS0169, CS0414
[NonSerialized] JObjectRefType handle_type;
[NonSerialized] IntPtr handle;
[NonSerialized] internal IntPtr handle;
[NonSerialized] bool needsActivation;
[NonSerialized] bool isProxy;

Expand Down
2 changes: 1 addition & 1 deletion src/Mono.Android/Java.Lang/Throwable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public partial class Throwable : global::System.Exception, IJavaObject, IDisposa
{

protected bool is_generated;
IntPtr handle;
internal IntPtr handle;

IntPtr key_handle;
JObjectRefType handle_type;
Expand Down
1 change: 0 additions & 1 deletion src/Mono.Android/Mono.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@
<Compile Include="Android.Runtime\AnnotationAttribute.cs" />
<Compile Include="Android.Runtime\BoundExceptionType.cs" />
<Compile Include="Android.Runtime\CharSequence.cs" />
<Compile Include="Android.Runtime\ConstructorBuilder.cs" />
<Compile Include="Android.Runtime\CPUArchitecture.cs" />
<Compile Include="Android.Runtime\Extensions.cs" />
<Compile Include="Android.Runtime\GeneratedEnumAttribute.cs" />
Expand Down