-
Notifications
You must be signed in to change notification settings - Fork 569
Expand file tree
/
Copy pathJreRuntime.cs
More file actions
89 lines (72 loc) · 2.58 KB
/
JreRuntime.cs
File metadata and controls
89 lines (72 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Originally from: https://github.com/dotnet/java-interop/blob/dd3c1d0514addfe379f050627b3e97493e985da6/src/Java.Runtime.Environment/Java.Interop/JreRuntime.cs
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.Android.Runtime;
namespace Java.Interop {
struct JavaVMInitArgs {
#pragma warning disable CS0649 // Field is never assigned to;
public JniVersion version; /* use JNI_VERSION_1_2 or later */
public int nOptions;
public IntPtr /* JavaVMOption[] */ options;
public byte ignoreUnrecognized;
#pragma warning restore CS0649
}
class NativeAotRuntimeOptions : JniRuntime.CreationOptions {
public bool IgnoreUnrecognizedOptions {get; set;}
public TextWriter? JniGlobalReferenceLogWriter {get; set;}
public TextWriter? JniLocalReferenceLogWriter {get; set;}
public NativeAotRuntimeOptions ()
{
JniVersion = JniVersion.v1_2;
}
public JreRuntime CreateJreVM ()
{
return new JreRuntime (this);
}
}
class JreRuntime : JniRuntime
{
static JreRuntime ()
{
}
static NativeAotRuntimeOptions CreateJreVM (NativeAotRuntimeOptions builder)
{
if (builder == null)
throw new ArgumentNullException ("builder");
if (builder.InvocationPointer == IntPtr.Zero &&
builder.EnvironmentPointer == IntPtr.Zero &&
string.IsNullOrEmpty (builder.JvmLibraryPath))
throw new InvalidOperationException ($"Member `{nameof (NativeAotRuntimeOptions)}.{nameof (NativeAotRuntimeOptions.JvmLibraryPath)}` must be set.");
#if NET
builder.TypeManager ??= new ManagedTypeManager ();
#endif // NET
builder.ValueManager ??= ManagedValueManager.Instance;
builder.ObjectReferenceManager ??= new Android.Runtime.AndroidObjectReferenceManager ();
if (builder.InvocationPointer != IntPtr.Zero || builder.EnvironmentPointer != IntPtr.Zero)
return builder;
throw new NotImplementedException ();
}
internal protected JreRuntime (NativeAotRuntimeOptions builder)
: base (CreateJreVM (builder))
{
}
public override string? GetCurrentManagedThreadName ()
{
return Thread.CurrentThread.Name;
}
public override string GetCurrentManagedThreadStackTrace (int skipFrames, bool fNeedFileInfo)
{
return new StackTrace (skipFrames, fNeedFileInfo)
.ToString ();
}
}
}