IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
RuntimeByteCodeJavaType.FinishedTypeImpl.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;
25using System.Diagnostics;
26
27using IKVM.Attributes;
28
29#if IMPORTER
30using IKVM.Reflection;
33
34using Type = IKVM.Reflection.Type;
35#else
36using System.Reflection;
37using System.Reflection.Emit;
38#endif
39
40namespace IKVM.Runtime
41{
42
43 partial class RuntimeByteCodeJavaType
44 {
45
46 sealed class FinishedTypeImpl : DynamicImpl
47 {
48
49 readonly Type type;
50 readonly RuntimeJavaType[] innerclasses;
51 readonly RuntimeJavaType declaringTypeWrapper;
52 readonly Modifiers reflectiveModifiers;
53 readonly MethodInfo clinitMethod;
54 readonly MethodInfo finalizeMethod;
55 readonly Metadata metadata;
56 readonly RuntimeJavaType host;
57
58 internal FinishedTypeImpl(Type type, RuntimeJavaType[] innerclasses, RuntimeJavaType declaringTypeWrapper, Modifiers reflectiveModifiers, Metadata metadata, MethodInfo clinitMethod, MethodInfo finalizeMethod, RuntimeJavaType host)
59 {
60 this.type = type;
61 this.innerclasses = innerclasses;
62 this.declaringTypeWrapper = declaringTypeWrapper;
63 this.reflectiveModifiers = reflectiveModifiers;
64 this.clinitMethod = clinitMethod;
65 this.finalizeMethod = finalizeMethod;
66 this.metadata = metadata;
67 this.host = host;
68 }
69
70 internal override RuntimeJavaType[] InnerClasses
71 {
72 get
73 {
74 // TODO compute the innerclasses lazily (and fix JavaTypeImpl to not always compute them)
75 return innerclasses;
76 }
77 }
78
79 internal override RuntimeJavaType DeclaringTypeWrapper
80 {
81 get
82 {
83 // TODO compute lazily (and fix JavaTypeImpl to not always compute it)
84 return declaringTypeWrapper;
85 }
86 }
87
88 internal override Modifiers ReflectiveModifiers
89 {
90 get
91 {
92 return reflectiveModifiers;
93 }
94 }
95
96 internal override Type Type
97 {
98 get
99 {
100 return type;
101 }
102 }
103
104 internal override void EmitRunClassConstructor(CodeEmitter ilgen)
105 {
106 if (clinitMethod != null)
107 {
108 ilgen.Emit(OpCodes.Call, clinitMethod);
109 }
110 }
111
112 internal override DynamicImpl Finish()
113 {
114 return this;
115 }
116
117 internal override MethodBase LinkMethod(RuntimeJavaMethod mw)
118 {
119 // we should never be called, because all methods on a finished type are already linked
120 Debug.Assert(false);
121 return mw.GetMethod();
122 }
123
124 internal override FieldInfo LinkField(RuntimeJavaField fw)
125 {
126 // we should never be called, because all fields on a finished type are already linked
127 Debug.Assert(false);
128 return fw.GetField();
129 }
130
131 internal override string GetGenericSignature()
132 {
133 return Metadata.GetGenericSignature(metadata);
134 }
135
136 internal override string[] GetEnclosingMethod()
137 {
138 return Metadata.GetEnclosingMethod(metadata);
139 }
140
141 internal override string GetGenericMethodSignature(int index)
142 {
143 return Metadata.GetGenericMethodSignature(metadata, index);
144 }
145
146 internal override string GetGenericFieldSignature(int index)
147 {
148 return Metadata.GetGenericFieldSignature(metadata, index);
149 }
150
151 internal override object[] GetDeclaredAnnotations()
152 {
153 return Metadata.GetAnnotations(metadata);
154 }
155
156 internal override object GetMethodDefaultValue(int index)
157 {
158 return Metadata.GetMethodDefaultValue(metadata, index);
159 }
160
161 internal override object[] GetMethodAnnotations(int index)
162 {
163 return Metadata.GetMethodAnnotations(metadata, index);
164 }
165
166 internal override object[][] GetParameterAnnotations(int index)
167 {
168 return Metadata.GetMethodParameterAnnotations(metadata, index);
169 }
170
171 internal override MethodParametersEntry[] GetMethodParameters(int index)
172 {
173 return Metadata.GetMethodParameters(metadata, index);
174 }
175
176 internal override object[] GetFieldAnnotations(int index)
177 {
178 return Metadata.GetFieldAnnotations(metadata, index);
179 }
180
181 internal override MethodInfo GetFinalizeMethod()
182 {
183 return finalizeMethod;
184 }
185
186 internal override object[] GetConstantPool()
187 {
188 return Metadata.GetConstantPool(metadata);
189 }
190
191 internal override byte[] GetRawTypeAnnotations()
192 {
193 return Metadata.GetRawTypeAnnotations(metadata);
194 }
195
196 internal override byte[] GetMethodRawTypeAnnotations(int index)
197 {
198 return Metadata.GetMethodRawTypeAnnotations(metadata, index);
199 }
200
201 internal override byte[] GetFieldRawTypeAnnotations(int index)
202 {
203 return Metadata.GetFieldRawTypeAnnotations(metadata, index);
204 }
205
206 internal override RuntimeJavaType Host
207 {
208 get { return host; }
209 }
210
211 }
212
213 }
214
215}
IKVM.Reflection.Type Type
IKVM.Reflection.FieldInfo FieldInfo
IKVM.Reflection.MethodInfo MethodInfo
IKVM.Reflection.MethodBase MethodBase