IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
CompilerFactory.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2015 Jeroen Frijters
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 Jeroen Frijters
21 jeroen@frijters.net
22
23*/
24using System;
25
26#if IMPORTER
27using IKVM.Reflection;
29
30using Type = IKVM.Reflection.Type;
31#else
32using System.Reflection;
33using System.Reflection.Emit;
34#endif
35
36
37namespace IKVM.Runtime
38{
43 {
44
45 readonly RuntimeContext context;
46 readonly bool bootstrap;
47
48 MethodInfo unmapExceptionMethod;
49 MethodInfo fixateExceptionMethod;
50 MethodInfo suppressFillInStackTraceMethod;
51 MethodInfo getTypeFromHandleMethod;
52 MethodInfo getTypeMethod;
53 MethodInfo keepAliveMethod;
54 RuntimeJavaMethod getClassFromTypeHandle;
55 RuntimeJavaMethod getClassFromTypeHandle2;
56
62 public CompilerFactory(RuntimeContext context, bool bootstrap)
63 {
64 this.context = context;
65 this.bootstrap = bootstrap;
66
67 if (bootstrap && Throwable.TypeAsBaseType is TypeBuilder)
68 foreach (var m in Throwable.GetMethods())
69 m.Link();
70
73 }
74
75 public RuntimeJavaType Throwable => context.JavaBase.TypeOfjavaLangThrowable;
76
77 public MethodInfo UnmapExceptionMethod => unmapExceptionMethod ??= bootstrap ? (MethodInfo)Throwable.GetMethod("__<unmap>", "(Ljava.lang.Throwable;)Ljava.lang.Throwable;", false).GetMethod() : Throwable.TypeAsBaseType.GetMethod("__<unmap>", new Type[] { context.Types.Exception });
78
79 public MethodInfo FixateExceptionMethod => fixateExceptionMethod ??= bootstrap ? (MethodInfo)Throwable.GetMethod("__<fixate>", "(Ljava.lang.Throwable;)Ljava.lang.Throwable;", false).GetMethod() : Throwable.TypeAsBaseType.GetMethod("__<fixate>", new Type[] { context.Types.Exception });
80
81 public MethodInfo SuppressFillInStackTraceMethod => suppressFillInStackTraceMethod ??= bootstrap ? (MethodInfo)Throwable.GetMethod("__<suppressFillInStackTrace>", "()V", false).GetMethod() : Throwable.TypeAsBaseType.GetMethod("__<suppressFillInStackTrace>", Type.EmptyTypes);
82
83 public MethodInfo GetTypeFromHandleMethod => getTypeFromHandleMethod ??= context.Types.Type.GetMethod("GetTypeFromHandle", BindingFlags.Static | BindingFlags.Public, null, [context.Types.RuntimeTypeHandle], null);
84
85 public MethodInfo GetTypeMethod => getTypeMethod ??= context.Types.Object.GetMethod("GetType", BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, null);
86
87 public MethodInfo KeepAliveMethod => keepAliveMethod ??= context.Resolver.ResolveCoreType(typeof(GC).FullName).AsReflection().GetMethod("KeepAlive", BindingFlags.Static | BindingFlags.Public, null, [context.Types.Object], null);
88
89 public RuntimeJavaMethod GetClassFromTypeHandle => getClassFromTypeHandle ??= context.ClassLoaderFactory.LoadClassCritical("ikvm.runtime.Util").GetMethod("getClassFromTypeHandle", "(Lcli.System.RuntimeTypeHandle;)Ljava.lang.Class;", false);
90
91 public RuntimeJavaMethod GetClassFromTypeHandle2 => getClassFromTypeHandle2 ??= context.ClassLoaderFactory.LoadClassCritical("ikvm.runtime.Util").GetMethod("getClassFromTypeHandle", "(Lcli.System.RuntimeTypeHandle;I)Ljava.lang.Class;", false);
92
93 }
94
95}
java.lang.Throwable Throwable
IKVM.Reflection.Type Type
IKVM.Reflection.MethodInfo MethodInfo
Manages instances of Compiler.
CompilerFactory(RuntimeContext context, bool bootstrap)
Initializes a new instance.
RuntimeJavaMethod GetClassFromTypeHandle2
RuntimeJavaMethod GetClassFromTypeHandle
Maintains services relevant to an instane of the IKVM runtime.