IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
UNIXProcess.cs
Go to the documentation of this file.
1using System;
2using System.Diagnostics;
3using System.Runtime.InteropServices;
4
5using IKVM.Runtime;
8
10{
11
12 static class UNIXProcess
13 {
14
15#if FIRST_PASS == false
16
17 static UNIXProcessAccessor unixProcessAccessor;
18
19 static UNIXProcessAccessor UNIXProcessAccessor => JVM.Internal.BaseAccessors.Get(ref unixProcessAccessor);
20
21 static global::ikvm.@internal.CallerID __callerID;
22 delegate void __jniDelegate__init(IntPtr jniEnv, IntPtr clazz);
23 static __jniDelegate__init __jniPtr__init;
24
25#endif
26
35 public static unsafe void init()
36 {
37#if FIRST_PASS
38 throw new NotImplementedException();
39#else
40 if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
41 return;
42
43 // get size of sigaction structure and allocate space
44 var size = LibIkvm.Instance.sig_get_size_sigaction();
45 Debug.Assert(size > 0);
46 var save = stackalloc byte[size];
47
48 // save old SIGCHLD structure
49 if (LibIkvm.Instance.sig_get_chld_action(save) != 0)
50 throw new InternalException("Could not save SIGCHLD handler.");
51
52 try
53 {
54 __callerID ??= global::ikvm.@internal.CallerID.create(UNIXProcessAccessor.Type.TypeHandle);
55 __jniPtr__init ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__init>(JNIFrame.GetFuncPtr(__callerID, "java/lang/UNIXProcess", nameof(init), "()V"));
56 var jniFrm = new JNIFrame();
57 var jniEnv = jniFrm.Enter(__callerID);
58 try
59 {
60 __jniPtr__init(jniEnv, jniFrm.MakeLocalRef(typeof(ClassLiteral<>).MakeGenericType(UNIXProcessAccessor.Type)));
61 }
62 catch (Exception ex)
63 {
64 global::System.Console.WriteLine("*** exception in native code ***");
65 global::System.Console.WriteLine(ex);
66 throw;
67 }
68 finally
69 {
70 jniFrm.Leave();
71 }
72 }
73 finally
74 {
75 // restore old SIGCHLD structure
76 if (LibIkvm.Instance.sig_set_chld_action(save) != 0)
77 throw new InternalException("Could not restore SIGCHLD handler.");
78 }
79#endif
80 }
81
82 }
83
84}
static unsafe void init()
Implements the native method 'init'.
Provides a static cache of java.lang.Class instances per .NET type.
Represents an internal error that occurred within IKVM.
Main state of the running JVM.
static nint GetFuncPtr(object callerID, string clazz, string name, string sig)
Invoked by managed code to acquire a function pointer to a native JNI method.
Definition JNIFrame.cs:43