IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IKVM.Runtime.ClassFile Class Referencesealed
Inheritance diagram for IKVM.Runtime.ClassFile:

Classes

struct  BootstrapMethod
 
class  ConstantPoolItem
 Type-model representation of a constant pool item.
 
class  ConstantPoolItemClass
 Type-model representation of a class constant.
 
class  ConstantPoolItemFieldref
 Type-model representation of a fieldRef constant.
 
class  ConstantPoolItemFMI
 Type-model representation of a field, method or interface reference.
 
class  ConstantPoolItemInterfaceMethodref
 
class  ConstantPoolItemInvokeDynamic
 Type-model representation of a invokedynamic constant.
 
class  ConstantPoolItemMethodHandle
 Type-model representation of a methodhandle constant.
 
class  ConstantPoolItemMethodref
 Type-model representation of a methodref constant.
 
class  ConstantPoolItemMethodType
 Type-model representation of a methodtype constant.
 
class  ConstantPoolItemMI
 Type-model representation of a methodref or interfaceref constant.
 
class  Field
 
class  FieldOrMethod
 
struct  InnerClass
 
class  Method
 

Public Member Functions

void Link (RuntimeJavaType thisType, LoadMode mode)
 Initiates linkage of this class file to the specified java type instance.
 
void Dispose ()
 

Static Public Member Functions

static bool IsValidMethodName (string name, ClassFormatVersion version)
 Returns true if the given string is a valid method name given the specified class format version.
 
static bool IsValidMethodName (ReadOnlySpan< char > name, ClassFormatVersion version)
 Returns true if the given string is a valid method name given the specified class format version.
 
static bool IsValidFieldName (string name, ClassFormatVersion version)
 Returns true if the given string is a valid field name given the specified class format version.
 
static bool IsValidFieldName (ReadOnlySpan< char > name, ClassFormatVersion version)
 Returns true if the given string is a valid field name given the specified class format version.
 
static bool IsValidPre49Identifier (string name)
 Returns true if the given string is a valid identifier for pre-49 class files.
 
static bool IsValidPre49Identifier (ReadOnlySpan< char > name)
 Returns true if the given string is a valid identifier for pre-49 class files.
 
static bool IsValidFieldDescriptor (string descriptor)
 Returns true if the specified descriptor is a valid field descriptor.
 
static bool IsValidFieldDescriptor (string descriptor, int start, int end)
 Returns true if the specified descriptor is a valid field descriptor.
 
static bool IsValidFieldDescriptor (ReadOnlySpan< char > descriptor)
 Returns true if the specified descriptor is a valid field descriptor.
 
static bool IsValidMethodDescriptor (string descriptor)
 Returns true if the specified descriptor is a valid method descriptor.
 
static bool IsValidMethodDescriptor (ReadOnlySpan< char > descriptor)
 Returns true if the specified descriptor is a valid method descriptor.
 

Properties

int MajorVersion [get]
 Gets the major version of the class.
 
Modifiers Modifiers [get]
 Gets the modifiers of the class.
 
bool IsAbstract [get]
 Gets whether this class file represents an abstract class.
 
bool IsFinal [get]
 Gets whether this class file represents a final class.
 
bool IsPublic [get]
 Gets whether this class file represents a public class.
 
bool IsInterface [get]
 Gets whether this class file represents an interface.
 
bool IsEnum [get]
 Gets whether this class file represents an enum.
 
bool IsAnnotation [get]
 Gets whether this class file represents an annotation.
 
bool IsSuper [get]
 Gets whether this class file is a super.
 

Detailed Description

Definition at line 28 of file ClassFile.SupportedVersions.cs.

Member Function Documentation

◆ Dispose()

void IKVM.Runtime.ClassFile.Dispose ( )

Definition at line 1447 of file ClassFile.cs.

1448 {
1449 clazz.Dispose();
1450 }

◆ IsValidFieldDescriptor() [1/3]

static bool IKVM.Runtime.ClassFile.IsValidFieldDescriptor ( ReadOnlySpan< char > descriptor)
static

Returns true if the specified descriptor is a valid field descriptor.

Parameters
descriptor
Returns

Definition at line 178 of file ClassFile.cs.

179 {
180 if (descriptor.IsEmpty)
181 return false;
182
183 switch (descriptor[0])
184 {
185 case 'L':
186 // skip L, next semicolon should be last character
187 descriptor = descriptor.Slice(1);
188 return descriptor.Length >= 2 && descriptor.IndexOf(';') == descriptor.Length - 1;
189 case '[':
190 // advance past [ values
191 while (descriptor[0] == '[')
192 {
193 descriptor = descriptor.Slice(1);
194 if (descriptor.IsEmpty)
195 return false;
196 }
197
198 return IsValidFieldDescriptor(descriptor);
199 case 'B':
200 case 'Z':
201 case 'C':
202 case 'S':
203 case 'I':
204 case 'J':
205 case 'F':
206 case 'D':
207 // skip char, should be empty
208 descriptor = descriptor.Slice(1);
209 return descriptor.IsEmpty;
210 default:
211 return false;
212 }
213 }
static bool IsValidFieldDescriptor(string descriptor)
Returns true if the specified descriptor is a valid field descriptor.
Definition ClassFile.cs:152

◆ IsValidFieldDescriptor() [2/3]

static bool IKVM.Runtime.ClassFile.IsValidFieldDescriptor ( string descriptor)
static

Returns true if the specified descriptor is a valid field descriptor.

Parameters
descriptor
Returns

Definition at line 152 of file ClassFile.cs.

153 {
154 if (descriptor is null)
155 throw new ArgumentNullException(nameof(descriptor));
156
157 return IsValidFieldDescriptor(descriptor.AsSpan());
158 }

◆ IsValidFieldDescriptor() [3/3]

static bool IKVM.Runtime.ClassFile.IsValidFieldDescriptor ( string descriptor,
int start,
int end )
static

Returns true if the specified descriptor is a valid field descriptor.

Parameters
descriptor
Returns

Definition at line 165 of file ClassFile.cs.

166 {
167 if (descriptor is null)
168 throw new ArgumentNullException(nameof(descriptor));
169
170 return IsValidFieldDescriptor(descriptor.AsSpan());
171 }

◆ IsValidFieldName() [1/2]

static bool IKVM.Runtime.ClassFile.IsValidFieldName ( ReadOnlySpan< char > name,
ClassFormatVersion version )
static

Returns true if the given string is a valid field name given the specified class format version.

Parameters
name
version
Returns

Definition at line 98 of file ClassFile.cs.

99 {
100 if (name.Length == 0)
101 return false;
102
103 for (int i = 0; i < name.Length; i++)
104 if (".;[/".Contains(name[i]))
105 return false;
106
107 return version >= 49 || IsValidPre49Identifier(name);
108 }
static bool IsValidPre49Identifier(string name)
Returns true if the given string is a valid identifier for pre-49 class files.
Definition ClassFile.cs:115

◆ IsValidFieldName() [2/2]

static bool IKVM.Runtime.ClassFile.IsValidFieldName ( string name,
ClassFormatVersion version )
static

Returns true if the given string is a valid field name given the specified class format version.

Parameters
name
version
Returns

Definition at line 84 of file ClassFile.cs.

85 {
86 if (name is null)
87 throw new ArgumentNullException(nameof(name));
88
89 return IsValidFieldName(name.AsSpan(), version);
90 }
static bool IsValidFieldName(string name, ClassFormatVersion version)
Returns true if the given string is a valid field name given the specified class format version.
Definition ClassFile.cs:84

◆ IsValidMethodDescriptor() [1/2]

static bool IKVM.Runtime.ClassFile.IsValidMethodDescriptor ( ReadOnlySpan< char > descriptor)
static

Returns true if the specified descriptor is a valid method descriptor.

Parameters
descriptor
Returns

Definition at line 233 of file ClassFile.cs.

234 {
235 if (descriptor.Length < 3 || descriptor[0] != '(')
236 return false;
237
238 int end = descriptor.IndexOf(')');
239 if (end == -1)
240 return false;
241
242 if (!descriptor.EndsWith(")V".AsSpan()) && !IsValidFieldDescriptor(descriptor[(end + 1)..]))
243 return false;
244
245 for (int i = 1; i < end; i++)
246 {
247 switch (descriptor[i])
248 {
249 case 'B':
250 case 'Z':
251 case 'C':
252 case 'S':
253 case 'I':
254 case 'J':
255 case 'F':
256 case 'D':
257 break;
258 case 'L':
259 var p = descriptor.Slice(i).IndexOf(';');
260 i = p == -1 ? -1 : p + i;
261 break;
262 case '[':
263 while (descriptor[i] == '[')
264 i++;
265
266 if ("BZCSIJFDL".Contains(descriptor[i]) == false)
267 return false;
268
269 if (descriptor[i] == 'L')
270 {
271 var o = descriptor.Slice(i).IndexOf(';');
272 i = o == -1 ? -1 : o + i;
273 }
274
275 break;
276 default:
277 return false;
278 }
279
280 if (i == -1 || i >= end)
281 return false;
282 }
283
284 return true;
285 }

◆ IsValidMethodDescriptor() [2/2]

static bool IKVM.Runtime.ClassFile.IsValidMethodDescriptor ( string descriptor)
static

Returns true if the specified descriptor is a valid method descriptor.

Parameters
descriptor
Returns

Definition at line 220 of file ClassFile.cs.

221 {
222 if (descriptor is null)
223 throw new ArgumentNullException(nameof(descriptor));
224
225 return IsValidMethodDescriptor(descriptor.AsSpan());
226 }
static bool IsValidMethodDescriptor(string descriptor)
Returns true if the specified descriptor is a valid method descriptor.
Definition ClassFile.cs:220

◆ IsValidMethodName() [1/2]

static bool IKVM.Runtime.ClassFile.IsValidMethodName ( ReadOnlySpan< char > name,
ClassFormatVersion version )
static

Returns true if the given string is a valid method name given the specified class format version.

Parameters
name
version
Returns

Definition at line 66 of file ClassFile.cs.

67 {
68 if (name.Length == 0)
69 return false;
70
71 for (int i = 0; i < name.Length; i++)
72 if (".;[/<>".Contains(name[i]))
73 return false;
74
75 return version >= 49 || IsValidPre49Identifier(name);
76 }

◆ IsValidMethodName() [2/2]

static bool IKVM.Runtime.ClassFile.IsValidMethodName ( string name,
ClassFormatVersion version )
static

Returns true if the given string is a valid method name given the specified class format version.

Parameters
name
version
Returns

Definition at line 45 of file ClassFile.cs.

46 {
47 if (name is null)
48 throw new ArgumentNullException(nameof(name));
49
50 if (name.Length == 0)
51 return false;
52
53 for (int i = 0; i < name.Length; i++)
54 if (".;[/<>".Contains(name[i]))
55 return false;
56
57 return version >= 49 || IsValidPre49Identifier(name);
58 }

◆ IsValidPre49Identifier() [1/2]

static bool IKVM.Runtime.ClassFile.IsValidPre49Identifier ( ReadOnlySpan< char > name)
static

Returns true if the given string is a valid identifier for pre-49 class files.

Parameters
name
Returns

Definition at line 135 of file ClassFile.cs.

136 {
137 if (!char.IsLetter(name[0]) && "$_".Contains(name[0]) == false)
138 return false;
139
140 for (int i = 1; i < name.Length; i++)
141 if (!char.IsLetterOrDigit(name[i]) && "$_".Contains(name[i]) == false)
142 return false;
143
144 return true;
145 }

◆ IsValidPre49Identifier() [2/2]

static bool IKVM.Runtime.ClassFile.IsValidPre49Identifier ( string name)
static

Returns true if the given string is a valid identifier for pre-49 class files.

Parameters
name
Returns

Definition at line 115 of file ClassFile.cs.

116 {
117 if (name is null)
118 throw new ArgumentNullException(nameof(name));
119
120 if (!char.IsLetter(name[0]) && "$_".Contains(name[0]) == false)
121 return false;
122
123 for (int i = 1; i < name.Length; i++)
124 if (!char.IsLetterOrDigit(name[i]) && "$_".Contains(name[i]) == false)
125 return false;
126
127 return true;
128 }

◆ Link()

void IKVM.Runtime.ClassFile.Link ( RuntimeJavaType thisType,
LoadMode mode )

Initiates linkage of this class file to the specified java type instance.

Parameters
thisType
mode

Definition at line 967 of file ClassFile.cs.

968 {
969 // this is not just an optimization, it's required for anonymous classes to be able to refer to themselves
970 ((ConstantPoolItemClass)constantpool[clazz.This.Slot]).LinkSelf(thisType);
971
972 for (int i = 1; i < constantpool.Length; i++)
973 if (constantpool[i] != null)
974 constantpool[i].Link(thisType, mode);
975 }

Property Documentation

◆ IsAbstract

bool IKVM.Runtime.ClassFile.IsAbstract
get

Gets whether this class file represents an abstract class.

Definition at line 985 of file ClassFile.cs.

◆ IsAnnotation

bool IKVM.Runtime.ClassFile.IsAnnotation
get

Gets whether this class file represents an annotation.

Definition at line 1010 of file ClassFile.cs.

◆ IsEnum

bool IKVM.Runtime.ClassFile.IsEnum
get

Gets whether this class file represents an enum.

Definition at line 1005 of file ClassFile.cs.

◆ IsFinal

bool IKVM.Runtime.ClassFile.IsFinal
get

Gets whether this class file represents a final class.

Definition at line 990 of file ClassFile.cs.

◆ IsInterface

bool IKVM.Runtime.ClassFile.IsInterface
get

Gets whether this class file represents an interface.

Definition at line 1000 of file ClassFile.cs.

◆ IsPublic

bool IKVM.Runtime.ClassFile.IsPublic
get

Gets whether this class file represents a public class.

Definition at line 995 of file ClassFile.cs.

◆ IsSuper

bool IKVM.Runtime.ClassFile.IsSuper
get

Gets whether this class file is a super.

Definition at line 1015 of file ClassFile.cs.

◆ MajorVersion

int IKVM.Runtime.ClassFile.MajorVersion
get

Gets the major version of the class.

Definition at line 960 of file ClassFile.cs.

◆ Modifiers

Modifiers IKVM.Runtime.ClassFile.Modifiers
get

Gets the modifiers of the class.

Definition at line 980 of file ClassFile.cs.


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