IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IKVM.Runtime.JNI.JNIVM Class Referencesealed

Static Public Member Functions

static int CreateJavaVM (JavaVM **p_vm, void **p_env, void *vm_args)
 Implements the JNI_CreateJavaVM native method.
 
static int GetDefaultJavaVMInitArgs (void *vm_args)
 Implements the JNI_GetDefaultJavaVMInitArgs native function.
 
static int GetCreatedJavaVMs (JavaVM **ppvmBuf, jsize bufLen, jsize *nVMs)
 Implements the JNI_GetCreatedJavaVMs native function.
 

Detailed Description

Definition at line 38 of file JNIVM.cs.

Member Function Documentation

◆ CreateJavaVM()

static int IKVM.Runtime.JNI.JNIVM.CreateJavaVM ( JavaVM ** p_vm,
void ** p_env,
void * vm_args )
static

Implements the JNI_CreateJavaVM native method.

Parameters
p_vm
p_env
vm_args
Returns

Definition at line 80 of file JNIVM.cs.

81 {
82 var pInitArgs = (JavaVMInitArgs*)vm_args;
83
84 // we don't support the JDK 1.1 JavaVMInitArgs
85 if (!IsSupportedJNIVersion(pInitArgs->version) || pInitArgs->version == JNIEnv.JNI_VERSION_1_1)
86 return JNIEnv.JNI_EVERSION;
87
88 // JVM is already created, only one allowed at a time
89 if (jvmCreated)
90 return JNIEnv.JNI_ERR;
91
92 var properties = new Dictionary<string, string>();
93 for (int i = 0; i < pInitArgs->nOptions; i++)
94 {
95 var option = DecodePlatformString(pInitArgs->options[i].optionString);
96 if (option == null)
97 return JNIEnv.JNI_ERR;
98
99 if (option.StartsWith("-D"))
100 {
101 var idx = option.IndexOf('=', 2);
102 properties[option.Substring(2, idx - 2)] = option.Substring(idx + 1);
103 }
104 else if (option.StartsWith("-verbose"))
105 {
106 // ignore
107 }
108 else if (option == "vfprintf" || option == "exit" || option == "abort")
109 {
110 // not supported
111 }
112 else if (pInitArgs->ignoreUnrecognized == JNIEnv.JNI_FALSE)
113 {
114 return JNIEnv.JNI_ERR;
115 }
116 }
117
118 // initialize the JVM properties
119 foreach (var kvp in properties)
120 JVM.Properties.User[kvp.Key] = kvp.Value;
121
122 java.lang.Thread.currentThread();
123 *p_vm = JavaVM.pJavaVM;
124
125 return JavaVM.AttachCurrentThread(JavaVM.pJavaVM, p_env, null);
126 }

◆ GetCreatedJavaVMs()

static int IKVM.Runtime.JNI.JNIVM.GetCreatedJavaVMs ( JavaVM ** ppvmBuf,
jsize bufLen,
jsize * nVMs )
static

Implements the JNI_GetCreatedJavaVMs native function.

Parameters
ppvmBuf
bufLen
nVMs
Returns

Definition at line 146 of file JNIVM.cs.

147 {
148 if (jvmCreated)
149 {
150 if (bufLen >= 1)
151 *ppvmBuf = JavaVM.pJavaVM;
152
153 if (nVMs != null)
154 *nVMs = 1;
155 }
156 else if (nVMs != null)
157 *nVMs = 0;
158
159 return JNIEnv.JNI_OK;
160 }

◆ GetDefaultJavaVMInitArgs()

static int IKVM.Runtime.JNI.JNIVM.GetDefaultJavaVMInitArgs ( void * vm_args)
static

Implements the JNI_GetDefaultJavaVMInitArgs native function.

Parameters
vm_args
Returns

Definition at line 133 of file JNIVM.cs.

134 {
135 // This is only used for JDK 1.1 JavaVMInitArgs, and we don't support those.
136 return JNIEnv.JNI_ERR;
137 }

The documentation for this class was generated from the following file: