Skip to content

Commit f65e0c7

Browse files
committed
Bring in the rest of relevant changes from #10402
1 parent ac1731c commit f65e0c7

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/Microsoft.Android.Runtime.NativeAOT/Android.Runtime.NativeAOT/JavaInteropRuntime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ static void init (IntPtr jnienv, IntPtr klass, IntPtr classLoader)
5858

5959
// Entry point into Mono.Android.dll
6060
JNIEnvInit.InitializeJniRuntime (runtime);
61+
XA_Host_NativeAOT_OnInit ();
6162

6263
transition = new JniTransition (jnienv);
63-
XA_Host_NativeAOT_OnInit ();
6464

6565
var handler = Java.Lang.Thread.DefaultUncaughtExceptionHandler;
6666
Java.Lang.Thread.DefaultUncaughtExceptionHandler = new UncaughtExceptionMarshaler (handler);

src/Microsoft.Android.Runtime.NativeAOT/Java.Interop/JreRuntime.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ static NativeAotRuntimeOptions CreateJreVM (NativeAotRuntimeOptions builder)
6161
builder.TypeManager ??= new ManagedTypeManager ();
6262
#endif // NET
6363

64-
builder.ValueManager ??= new SimpleValueManager ();
65-
builder.ObjectReferenceManager ??= new ManagedObjectReferenceManager (builder.JniGlobalReferenceLogWriter, builder.JniLocalReferenceLogWriter);
64+
builder.ValueManager ??= ManagedValueManager.GetOrCreateInstance();
65+
builder.ObjectReferenceManager ??= new Android.Runtime.AndroidObjectReferenceManager ();
6666

6767
if (builder.InvocationPointer != IntPtr.Zero || builder.EnvironmentPointer != IntPtr.Zero)
6868
return builder;

src/Mono.Android/Android.Runtime/AndroidRuntime.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ public AndroidRuntimeOptions (IntPtr jnienv,
102102
}
103103
}
104104

105-
class AndroidObjectReferenceManager : JniRuntime.JniObjectReferenceManager {
105+
// TODO: this shouldn't be public
106+
public class AndroidObjectReferenceManager : JniRuntime.JniObjectReferenceManager {
106107
public override int GlobalReferenceCount {
107108
get {return RuntimeNativeMethods._monodroid_gref_get ();}
108109
}

src/Mono.Android/Android.Runtime/JNIEnvInit.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ static Type TypeGetType (string typeName) =>
8282
internal static void InitializeJniRuntime (JniRuntime runtime)
8383
{
8484
androidRuntime = runtime;
85+
gref_gc_threshold = RuntimeNativeMethods._monodroid_max_gref_get ();
86+
if (gref_gc_threshold != int.MaxValue) {
87+
gref_gc_threshold = checked((gref_gc_threshold * 9) / 10);
88+
}
8589
SetSynchronizationContext ();
8690
}
8791

0 commit comments

Comments
 (0)