1 |
14 |
jlechner |
// Class.h - Header file for java.lang.Class. -*- c++ -*-
|
2 |
|
|
|
3 |
|
|
/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation
|
4 |
|
|
|
5 |
|
|
This file is part of libgcj.
|
6 |
|
|
|
7 |
|
|
This software is copyrighted work licensed under the terms of the
|
8 |
|
|
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
9 |
|
|
details. */
|
10 |
|
|
|
11 |
|
|
// Written primary using compiler source and Class.java as guides.
|
12 |
|
|
#ifndef __JAVA_LANG_CLASS_H__
|
13 |
|
|
#define __JAVA_LANG_CLASS_H__
|
14 |
|
|
|
15 |
|
|
#pragma interface
|
16 |
|
|
|
17 |
|
|
#include <stddef.h>
|
18 |
|
|
#include <java/lang/Object.h>
|
19 |
|
|
#include <java/lang/String.h>
|
20 |
|
|
#include <java/net/URL.h>
|
21 |
|
|
#include <java/lang/reflect/Modifier.h>
|
22 |
|
|
#include <java/security/ProtectionDomain.h>
|
23 |
|
|
#include <java/lang/Package.h>
|
24 |
|
|
|
25 |
|
|
// Avoid including SystemClassLoader.h.
|
26 |
|
|
extern "Java"
|
27 |
|
|
{
|
28 |
|
|
namespace gnu
|
29 |
|
|
{
|
30 |
|
|
namespace gcj
|
31 |
|
|
{
|
32 |
|
|
namespace runtime
|
33 |
|
|
{
|
34 |
|
|
class SystemClassLoader;
|
35 |
|
|
}
|
36 |
|
|
}
|
37 |
|
|
}
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
// We declare these here to avoid including gcj/cni.h.
|
41 |
|
|
extern "C" void _Jv_InitClass (jclass klass);
|
42 |
|
|
extern "C" void _Jv_RegisterClasses (const jclass *classes);
|
43 |
|
|
extern "C" void _Jv_RegisterClasses_Counted (const jclass *classes,
|
44 |
|
|
size_t count);
|
45 |
|
|
|
46 |
|
|
// This must be predefined with "C" linkage.
|
47 |
|
|
extern "C" void *_Jv_LookupInterfaceMethodIdx (jclass klass, jclass iface,
|
48 |
|
|
int meth_idx);
|
49 |
|
|
extern "C" void *_Jv_ResolvePoolEntry (jclass this_class, jint index);
|
50 |
|
|
|
51 |
|
|
// These are the possible values for the `state' field of the class
|
52 |
|
|
// structure. Note that ordering is important here. Whenever the
|
53 |
|
|
// state changes, one should notify all waiters of this class.
|
54 |
|
|
enum
|
55 |
|
|
{
|
56 |
|
|
JV_STATE_NOTHING = 0, // Set by compiler.
|
57 |
|
|
|
58 |
|
|
JV_STATE_PRELOADING = 1, // Can do _Jv_FindClass.
|
59 |
|
|
JV_STATE_LOADING = 3, // Has super installed.
|
60 |
|
|
JV_STATE_READ = 4, // Has been completely defined.
|
61 |
|
|
JV_STATE_LOADED = 5, // Has Miranda methods defined.
|
62 |
|
|
|
63 |
|
|
JV_STATE_COMPILED = 6, // This was a compiled class.
|
64 |
|
|
|
65 |
|
|
JV_STATE_PREPARED = 7, // Layout & static init done.
|
66 |
|
|
JV_STATE_LINKED = 9, // Strings interned.
|
67 |
|
|
|
68 |
|
|
JV_STATE_IN_PROGRESS = 10, // <clinit> running.
|
69 |
|
|
|
70 |
|
|
JV_STATE_ERROR = 12,
|
71 |
|
|
|
72 |
|
|
JV_STATE_DONE = 14 // Must be last.
|
73 |
|
|
};
|
74 |
|
|
|
75 |
|
|
struct _Jv_Field;
|
76 |
|
|
struct _Jv_VTable;
|
77 |
|
|
union _Jv_word;
|
78 |
|
|
struct _Jv_ArrayVTable;
|
79 |
|
|
class _Jv_Linker;
|
80 |
|
|
class _Jv_ExecutionEngine;
|
81 |
|
|
class _Jv_CompiledEngine;
|
82 |
|
|
class _Jv_InterpreterEngine;
|
83 |
|
|
|
84 |
|
|
struct _Jv_Constants
|
85 |
|
|
{
|
86 |
|
|
jint size;
|
87 |
|
|
jbyte *tags;
|
88 |
|
|
_Jv_word *data;
|
89 |
|
|
};
|
90 |
|
|
|
91 |
|
|
struct _Jv_Method
|
92 |
|
|
{
|
93 |
|
|
// Method name.
|
94 |
|
|
_Jv_Utf8Const *name;
|
95 |
|
|
// Method signature.
|
96 |
|
|
_Jv_Utf8Const *signature;
|
97 |
|
|
// Access flags.
|
98 |
|
|
_Jv_ushort accflags;
|
99 |
|
|
// Method's index in the vtable.
|
100 |
|
|
_Jv_ushort index;
|
101 |
|
|
// Pointer to underlying function.
|
102 |
|
|
void *ncode;
|
103 |
|
|
// NULL-terminated list of exception class names; can be NULL if
|
104 |
|
|
// there are none such.
|
105 |
|
|
_Jv_Utf8Const **throws;
|
106 |
|
|
|
107 |
|
|
_Jv_Method *getNextMethod ()
|
108 |
|
|
{ return this + 1; }
|
109 |
|
|
};
|
110 |
|
|
|
111 |
|
|
// Interface Dispatch Tables
|
112 |
|
|
union _Jv_IDispatchTable
|
113 |
|
|
{
|
114 |
|
|
struct
|
115 |
|
|
{
|
116 |
|
|
// Index into interface's ioffsets.
|
117 |
|
|
jshort iindex;
|
118 |
|
|
jshort itable_length;
|
119 |
|
|
// Class Interface dispatch table.
|
120 |
|
|
void **itable;
|
121 |
|
|
} cls;
|
122 |
|
|
|
123 |
|
|
struct
|
124 |
|
|
{
|
125 |
|
|
// Offsets into implementation class itables.
|
126 |
|
|
jshort *ioffsets;
|
127 |
|
|
} iface;
|
128 |
|
|
};
|
129 |
|
|
|
130 |
|
|
// Used by _Jv_Linker::get_interfaces ()
|
131 |
|
|
struct _Jv_ifaces
|
132 |
|
|
{
|
133 |
|
|
jclass *list;
|
134 |
|
|
jshort len;
|
135 |
|
|
jshort count;
|
136 |
|
|
};
|
137 |
|
|
|
138 |
|
|
struct _Jv_MethodSymbol
|
139 |
|
|
{
|
140 |
|
|
_Jv_Utf8Const *class_name;
|
141 |
|
|
_Jv_Utf8Const *name;
|
142 |
|
|
_Jv_Utf8Const *signature;
|
143 |
|
|
};
|
144 |
|
|
|
145 |
|
|
struct _Jv_OffsetTable
|
146 |
|
|
{
|
147 |
|
|
jint state;
|
148 |
|
|
jint offsets[];
|
149 |
|
|
};
|
150 |
|
|
|
151 |
|
|
struct _Jv_AddressTable
|
152 |
|
|
{
|
153 |
|
|
jint state;
|
154 |
|
|
void *addresses[];
|
155 |
|
|
};
|
156 |
|
|
|
157 |
|
|
struct _Jv_CatchClass
|
158 |
|
|
{
|
159 |
|
|
java::lang::Class **address;
|
160 |
|
|
_Jv_Utf8Const *classname;
|
161 |
|
|
};
|
162 |
|
|
|
163 |
|
|
// Possible values for the assertion_code field in the type assertion table.
|
164 |
|
|
enum
|
165 |
|
|
{
|
166 |
|
|
JV_ASSERT_END_OF_TABLE = 0,
|
167 |
|
|
JV_ASSERT_TYPES_COMPATIBLE = 1,
|
168 |
|
|
JV_ASSERT_IS_INSTANTIABLE = 2
|
169 |
|
|
};
|
170 |
|
|
|
171 |
|
|
// Entry in the type assertion table, used to validate type constraints
|
172 |
|
|
// for binary compatibility.
|
173 |
|
|
struct _Jv_TypeAssertion
|
174 |
|
|
{
|
175 |
|
|
jint assertion_code;
|
176 |
|
|
_Jv_Utf8Const *op1;
|
177 |
|
|
_Jv_Utf8Const *op2;
|
178 |
|
|
};
|
179 |
|
|
|
180 |
|
|
#define JV_PRIMITIVE_VTABLE ((_Jv_VTable *) -1)
|
181 |
|
|
|
182 |
|
|
#define JV_CLASS(Obj) ((jclass) (*(_Jv_VTable **) Obj)->clas)
|
183 |
|
|
|
184 |
|
|
// Forward declarations for friends of java::lang::Class
|
185 |
|
|
|
186 |
|
|
// Friend functions implemented in natClass.cc.
|
187 |
|
|
_Jv_Method *_Jv_GetMethodLocal (jclass klass, _Jv_Utf8Const *name,
|
188 |
|
|
_Jv_Utf8Const *signature);
|
189 |
|
|
jboolean _Jv_IsAssignableFrom (jclass, jclass);
|
190 |
|
|
jboolean _Jv_IsAssignableFromSlow (jclass, jclass);
|
191 |
|
|
jboolean _Jv_InterfaceAssignableFrom (jclass, jclass);
|
192 |
|
|
|
193 |
|
|
_Jv_Method* _Jv_LookupDeclaredMethod (jclass, _Jv_Utf8Const *,
|
194 |
|
|
_Jv_Utf8Const*, jclass * = NULL);
|
195 |
|
|
jfieldID JvGetFirstInstanceField (jclass);
|
196 |
|
|
jint JvNumInstanceFields (jclass);
|
197 |
|
|
jfieldID JvGetFirstStaticField (jclass);
|
198 |
|
|
jint JvNumStaticFields (jclass);
|
199 |
|
|
|
200 |
|
|
jobject _Jv_AllocObject (jclass);
|
201 |
|
|
void *_Jv_AllocObj (jint, jclass);
|
202 |
|
|
void *_Jv_AllocPtrFreeObj (jint, jclass);
|
203 |
|
|
void *_Jv_AllocArray (jint, jclass);
|
204 |
|
|
|
205 |
|
|
bool _Jv_getInterfaceMethod(jclass, jclass&, int&,
|
206 |
|
|
const _Jv_Utf8Const*,
|
207 |
|
|
const _Jv_Utf8Const*);
|
208 |
|
|
|
209 |
|
|
jobject _Jv_JNI_ToReflectedField (_Jv_JNIEnv *, jclass, jfieldID,
|
210 |
|
|
jboolean);
|
211 |
|
|
jobject _Jv_JNI_ToReflectedMethod (_Jv_JNIEnv *, jclass, jmethodID,
|
212 |
|
|
jboolean);
|
213 |
|
|
jfieldID _Jv_FromReflectedField (java::lang::reflect::Field *);
|
214 |
|
|
|
215 |
|
|
jmethodID _Jv_FromReflectedMethod (java::lang::reflect::Method *);
|
216 |
|
|
jmethodID _Jv_FromReflectedConstructor (java::lang::reflect::Constructor *);
|
217 |
|
|
jint JvNumMethods (jclass);
|
218 |
|
|
jmethodID JvGetFirstMethod (jclass);
|
219 |
|
|
|
220 |
|
|
// Friend classes and functions to implement the ClassLoader
|
221 |
|
|
class java::lang::ClassLoader;
|
222 |
|
|
class java::lang::VMClassLoader;
|
223 |
|
|
|
224 |
|
|
class java::io::ObjectOutputStream;
|
225 |
|
|
class java::io::ObjectInputStream;
|
226 |
|
|
class java::io::ObjectStreamClass;
|
227 |
|
|
|
228 |
|
|
void _Jv_RegisterClassHookDefault (jclass klass);
|
229 |
|
|
void _Jv_RegisterInitiatingLoader (jclass,java::lang::ClassLoader*);
|
230 |
|
|
void _Jv_UnregisterInitiatingLoader (jclass,java::lang::ClassLoader*);
|
231 |
|
|
void _Jv_UnregisterClass (jclass);
|
232 |
|
|
jclass _Jv_FindClass (_Jv_Utf8Const *name,
|
233 |
|
|
java::lang::ClassLoader *loader);
|
234 |
|
|
jclass _Jv_FindClassInCache (_Jv_Utf8Const *name);
|
235 |
|
|
jclass _Jv_PopClass (void);
|
236 |
|
|
void _Jv_PushClass (jclass k);
|
237 |
|
|
void _Jv_NewArrayClass (jclass element,
|
238 |
|
|
java::lang::ClassLoader *loader,
|
239 |
|
|
_Jv_VTable *array_vtable = 0);
|
240 |
|
|
jclass _Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
|
241 |
|
|
java::lang::ClassLoader *loader);
|
242 |
|
|
void _Jv_InitNewClassFields (jclass klass);
|
243 |
|
|
|
244 |
|
|
// Friend functions and classes in prims.cc
|
245 |
|
|
void _Jv_InitPrimClass (jclass, char *, char, int);
|
246 |
|
|
jstring _Jv_GetMethodString (jclass, _Jv_Method *, jclass = NULL);
|
247 |
|
|
|
248 |
|
|
jboolean _Jv_CheckAccess (jclass self_klass, jclass other_klass,
|
249 |
|
|
jint flags);
|
250 |
|
|
jclass _Jv_GetArrayClass (jclass klass, java::lang::ClassLoader *loader);
|
251 |
|
|
|
252 |
|
|
jboolean _Jv_IsInterpretedClass (jclass);
|
253 |
|
|
jboolean _Jv_IsBinaryCompatibilityABI (jclass);
|
254 |
|
|
|
255 |
|
|
void _Jv_CopyClassesToSystemLoader (gnu::gcj::runtime::SystemClassLoader *);
|
256 |
|
|
|
257 |
|
|
#ifdef INTERPRETER
|
258 |
|
|
void _Jv_InitField (jobject, jclass, int);
|
259 |
|
|
|
260 |
|
|
class _Jv_ClassReader;
|
261 |
|
|
class _Jv_InterpClass;
|
262 |
|
|
class _Jv_InterpMethod;
|
263 |
|
|
#endif
|
264 |
|
|
|
265 |
|
|
class _Jv_StackTrace;
|
266 |
|
|
class _Jv_BytecodeVerifier;
|
267 |
|
|
class java::io::VMObjectStreamClass;
|
268 |
|
|
|
269 |
|
|
void _Jv_sharedlib_register_hook (jclass klass);
|
270 |
|
|
|
271 |
|
|
|
272 |
|
|
class java::lang::Class : public java::lang::Object
|
273 |
|
|
{
|
274 |
|
|
public:
|
275 |
|
|
static jclass forName (jstring className, jboolean initialize,
|
276 |
|
|
java::lang::ClassLoader *loader);
|
277 |
|
|
static jclass forName (jstring className);
|
278 |
|
|
JArray<jclass> *getClasses (void);
|
279 |
|
|
|
280 |
|
|
java::lang::ClassLoader *getClassLoader (void);
|
281 |
|
|
|
282 |
|
|
// This is an internal method that circumvents the usual security
|
283 |
|
|
// checks when getting the class loader.
|
284 |
|
|
java::lang::ClassLoader *getClassLoaderInternal (void)
|
285 |
|
|
{
|
286 |
|
|
return loader;
|
287 |
|
|
}
|
288 |
|
|
|
289 |
|
|
java::lang::reflect::Constructor *getConstructor (JArray<jclass> *);
|
290 |
|
|
JArray<java::lang::reflect::Constructor *> *getConstructors (void);
|
291 |
|
|
java::lang::reflect::Constructor *getDeclaredConstructor (JArray<jclass> *);
|
292 |
|
|
JArray<java::lang::reflect::Constructor *> *getDeclaredConstructors (jboolean);
|
293 |
|
|
java::lang::reflect::Field *getDeclaredField (jstring);
|
294 |
|
|
JArray<java::lang::reflect::Field *> *getDeclaredFields ();
|
295 |
|
|
JArray<java::lang::reflect::Field *> *getDeclaredFields (jboolean);
|
296 |
|
|
java::lang::reflect::Method *getDeclaredMethod (jstring, JArray<jclass> *);
|
297 |
|
|
JArray<java::lang::reflect::Method *> *getDeclaredMethods (void);
|
298 |
|
|
|
299 |
|
|
JArray<jclass> *getDeclaredClasses (void);
|
300 |
|
|
JArray<jclass> *getDeclaredClasses (jboolean);
|
301 |
|
|
jclass getDeclaringClass (void);
|
302 |
|
|
|
303 |
|
|
java::lang::reflect::Field *getField (jstring);
|
304 |
|
|
private:
|
305 |
|
|
JArray<java::lang::reflect::Field *> internalGetFields ();
|
306 |
|
|
java::lang::reflect::Field *getField (jstring, jint);
|
307 |
|
|
jint _getMethods (JArray<java::lang::reflect::Method *> *result,
|
308 |
|
|
jint offset);
|
309 |
|
|
java::lang::reflect::Field *getPrivateField (jstring);
|
310 |
|
|
java::lang::reflect::Method *getPrivateMethod (jstring, JArray<jclass> *);
|
311 |
|
|
java::security::ProtectionDomain *getProtectionDomain0 ();
|
312 |
|
|
|
313 |
|
|
java::lang::reflect::Method *_getMethod (jstring, JArray<jclass> *);
|
314 |
|
|
java::lang::reflect::Method *_getDeclaredMethod (jstring, JArray<jclass> *);
|
315 |
|
|
|
316 |
|
|
public:
|
317 |
|
|
JArray<java::lang::reflect::Field *> *getFields (void);
|
318 |
|
|
|
319 |
|
|
JArray<jclass> *getInterfaces (void);
|
320 |
|
|
|
321 |
|
|
void getSignature (java::lang::StringBuffer *buffer);
|
322 |
|
|
static jstring getSignature (JArray<jclass> *, jboolean is_constructor);
|
323 |
|
|
JArray<java::lang::reflect::Method *> *getMethods (void);
|
324 |
|
|
|
325 |
|
|
inline jint getModifiers (void)
|
326 |
|
|
{
|
327 |
|
|
return accflags & java::lang::reflect::Modifier::ALL_FLAGS;
|
328 |
|
|
}
|
329 |
|
|
|
330 |
|
|
jstring getName (void);
|
331 |
|
|
|
332 |
|
|
java::net::URL *getResource (jstring resourceName);
|
333 |
|
|
java::io::InputStream *getResourceAsStream (jstring resourceName);
|
334 |
|
|
JArray<jobject> *getSigners (void);
|
335 |
|
|
void setSigners(JArray<jobject> *);
|
336 |
|
|
|
337 |
|
|
inline jclass getSuperclass (void)
|
338 |
|
|
{
|
339 |
|
|
return superclass;
|
340 |
|
|
}
|
341 |
|
|
|
342 |
|
|
inline jclass getInterface (jint n)
|
343 |
|
|
{
|
344 |
|
|
return interfaces[n];
|
345 |
|
|
}
|
346 |
|
|
|
347 |
|
|
inline jboolean isArray (void)
|
348 |
|
|
{
|
349 |
|
|
return name->first() == '[';
|
350 |
|
|
}
|
351 |
|
|
|
352 |
|
|
inline jclass getComponentType (void)
|
353 |
|
|
{
|
354 |
|
|
return isArray () ? (* (jclass *) &methods) : 0;
|
355 |
|
|
}
|
356 |
|
|
|
357 |
|
|
jboolean isAssignableFrom (jclass cls);
|
358 |
|
|
jboolean isInstance (jobject obj);
|
359 |
|
|
|
360 |
|
|
inline jboolean isInterface (void)
|
361 |
|
|
{
|
362 |
|
|
return (accflags & java::lang::reflect::Modifier::INTERFACE) != 0;
|
363 |
|
|
}
|
364 |
|
|
|
365 |
|
|
inline jboolean isPrimitive (void)
|
366 |
|
|
{
|
367 |
|
|
return vtable == JV_PRIMITIVE_VTABLE;
|
368 |
|
|
}
|
369 |
|
|
|
370 |
|
|
jobject newInstance (void);
|
371 |
|
|
java::security::ProtectionDomain *getProtectionDomain (void);
|
372 |
|
|
java::lang::Package *getPackage (void);
|
373 |
|
|
jstring toString (void);
|
374 |
|
|
jboolean desiredAssertionStatus (void);
|
375 |
|
|
|
376 |
|
|
// FIXME: this probably shouldn't be public.
|
377 |
|
|
jint size (void)
|
378 |
|
|
{
|
379 |
|
|
return size_in_bytes;
|
380 |
|
|
}
|
381 |
|
|
|
382 |
|
|
// The index of the first method we declare ourself (as opposed to
|
383 |
|
|
// inheriting).
|
384 |
|
|
inline jint firstMethodIndex (void)
|
385 |
|
|
{
|
386 |
|
|
return vtable_method_count - method_count;
|
387 |
|
|
}
|
388 |
|
|
|
389 |
|
|
// finalization
|
390 |
|
|
void finalize ();
|
391 |
|
|
|
392 |
|
|
// This constructor is used to create Class object for the primitive
|
393 |
|
|
// types. See prims.cc.
|
394 |
|
|
Class ();
|
395 |
|
|
|
396 |
|
|
static java::lang::Class class$;
|
397 |
|
|
|
398 |
|
|
private:
|
399 |
|
|
|
400 |
|
|
void memberAccessCheck (jint flags);
|
401 |
|
|
|
402 |
|
|
void initializeClass (void);
|
403 |
|
|
|
404 |
|
|
static jstring getPackagePortion (jstring);
|
405 |
|
|
|
406 |
|
|
void set_state (jint nstate)
|
407 |
|
|
{
|
408 |
|
|
state = nstate;
|
409 |
|
|
notifyAll ();
|
410 |
|
|
}
|
411 |
|
|
|
412 |
|
|
// Friend functions implemented in natClass.cc.
|
413 |
|
|
friend _Jv_Method *::_Jv_GetMethodLocal (jclass klass, _Jv_Utf8Const *name,
|
414 |
|
|
_Jv_Utf8Const *signature);
|
415 |
|
|
friend jboolean (::_Jv_IsAssignableFrom) (jclass, jclass);
|
416 |
|
|
friend jboolean (::_Jv_IsAssignableFromSlow) (jclass, jclass);
|
417 |
|
|
friend jboolean (::_Jv_InterfaceAssignableFrom) (jclass, jclass);
|
418 |
|
|
friend void *::_Jv_LookupInterfaceMethodIdx (jclass klass, jclass iface,
|
419 |
|
|
int method_idx);
|
420 |
|
|
|
421 |
|
|
friend void ::_Jv_InitClass (jclass klass);
|
422 |
|
|
|
423 |
|
|
friend _Jv_Method* ::_Jv_LookupDeclaredMethod (jclass, _Jv_Utf8Const *,
|
424 |
|
|
_Jv_Utf8Const*, jclass *);
|
425 |
|
|
friend jfieldID (::JvGetFirstInstanceField) (jclass);
|
426 |
|
|
friend jint (::JvNumInstanceFields) (jclass);
|
427 |
|
|
friend jfieldID (::JvGetFirstStaticField) (jclass);
|
428 |
|
|
friend jint (::JvNumStaticFields) (jclass);
|
429 |
|
|
|
430 |
|
|
friend jobject (::_Jv_AllocObject) (jclass);
|
431 |
|
|
friend void *::_Jv_AllocObj (jint, jclass);
|
432 |
|
|
friend void *::_Jv_AllocPtrFreeObj (jint, jclass);
|
433 |
|
|
friend void *::_Jv_AllocArray (jint, jclass);
|
434 |
|
|
|
435 |
|
|
friend jobject (::_Jv_JNI_ToReflectedField) (_Jv_JNIEnv *, jclass, jfieldID,
|
436 |
|
|
jboolean);
|
437 |
|
|
friend jobject (::_Jv_JNI_ToReflectedMethod) (_Jv_JNIEnv *, jclass, jmethodID,
|
438 |
|
|
jboolean);
|
439 |
|
|
friend jfieldID (::_Jv_FromReflectedField) (java::lang::reflect::Field *);
|
440 |
|
|
|
441 |
|
|
friend jmethodID (::_Jv_FromReflectedMethod) (java::lang::reflect::Method *);
|
442 |
|
|
friend jmethodID (::_Jv_FromReflectedConstructor) (java::lang::reflect::Constructor *);
|
443 |
|
|
friend jint (::JvNumMethods) (jclass);
|
444 |
|
|
friend jmethodID (::JvGetFirstMethod) (jclass);
|
445 |
|
|
|
446 |
|
|
// Friends classes and functions to implement the ClassLoader
|
447 |
|
|
friend class java::lang::ClassLoader;
|
448 |
|
|
friend class java::lang::VMClassLoader;
|
449 |
|
|
|
450 |
|
|
friend class java::io::ObjectOutputStream;
|
451 |
|
|
friend class java::io::ObjectInputStream;
|
452 |
|
|
friend class java::io::ObjectStreamClass;
|
453 |
|
|
|
454 |
|
|
friend void ::_Jv_RegisterClasses (const jclass *classes);
|
455 |
|
|
friend void ::_Jv_RegisterClasses_Counted (const jclass *classes,
|
456 |
|
|
size_t count);
|
457 |
|
|
friend void ::_Jv_RegisterClassHookDefault (jclass klass);
|
458 |
|
|
friend void ::_Jv_RegisterInitiatingLoader (jclass,java::lang::ClassLoader*);
|
459 |
|
|
friend void ::_Jv_UnregisterInitiatingLoader (jclass,java::lang::ClassLoader*);
|
460 |
|
|
friend void ::_Jv_UnregisterClass (jclass);
|
461 |
|
|
friend jclass (::_Jv_FindClass) (_Jv_Utf8Const *name,
|
462 |
|
|
java::lang::ClassLoader *loader);
|
463 |
|
|
friend jclass (::_Jv_FindClassInCache) (_Jv_Utf8Const *name);
|
464 |
|
|
friend jclass (::_Jv_PopClass) (void);
|
465 |
|
|
friend void ::_Jv_PushClass (jclass k);
|
466 |
|
|
friend void ::_Jv_NewArrayClass (jclass element,
|
467 |
|
|
java::lang::ClassLoader *loader,
|
468 |
|
|
_Jv_VTable *array_vtable);
|
469 |
|
|
friend jclass (::_Jv_NewClass) (_Jv_Utf8Const *name, jclass superclass,
|
470 |
|
|
java::lang::ClassLoader *loader);
|
471 |
|
|
friend void ::_Jv_InitNewClassFields (jclass klass);
|
472 |
|
|
|
473 |
|
|
// in prims.cc
|
474 |
|
|
friend void ::_Jv_InitPrimClass (jclass, char *, char, int);
|
475 |
|
|
|
476 |
|
|
friend jstring (::_Jv_GetMethodString) (jclass, _Jv_Method *, jclass);
|
477 |
|
|
|
478 |
|
|
friend jboolean (::_Jv_CheckAccess) (jclass self_klass, jclass other_klass,
|
479 |
|
|
jint flags);
|
480 |
|
|
|
481 |
|
|
friend bool (::_Jv_getInterfaceMethod) (jclass, jclass&, int&,
|
482 |
|
|
const _Jv_Utf8Const*,
|
483 |
|
|
const _Jv_Utf8Const*);
|
484 |
|
|
|
485 |
|
|
friend jclass (::_Jv_GetArrayClass) (jclass klass,
|
486 |
|
|
java::lang::ClassLoader *loader);
|
487 |
|
|
|
488 |
|
|
friend jboolean (::_Jv_IsInterpretedClass) (jclass);
|
489 |
|
|
friend jboolean (::_Jv_IsBinaryCompatibilityABI) (jclass);
|
490 |
|
|
|
491 |
|
|
#ifdef INTERPRETER
|
492 |
|
|
friend void ::_Jv_InitField (jobject, jclass, int);
|
493 |
|
|
|
494 |
|
|
friend class ::_Jv_ClassReader;
|
495 |
|
|
friend class ::_Jv_InterpClass;
|
496 |
|
|
friend class ::_Jv_InterpMethod;
|
497 |
|
|
#endif
|
498 |
|
|
friend class ::_Jv_StackTrace;
|
499 |
|
|
|
500 |
|
|
#ifdef JV_MARKOBJ_DECL
|
501 |
|
|
friend JV_MARKOBJ_DECL;
|
502 |
|
|
#endif
|
503 |
|
|
|
504 |
|
|
friend class ::_Jv_BytecodeVerifier;
|
505 |
|
|
friend class java::io::VMObjectStreamClass;
|
506 |
|
|
|
507 |
|
|
friend class ::_Jv_Linker;
|
508 |
|
|
friend class ::_Jv_ExecutionEngine;
|
509 |
|
|
friend class ::_Jv_CompiledEngine;
|
510 |
|
|
friend class ::_Jv_InterpreterEngine;
|
511 |
|
|
|
512 |
|
|
friend void ::_Jv_sharedlib_register_hook (jclass klass);
|
513 |
|
|
|
514 |
|
|
friend void *::_Jv_ResolvePoolEntry (jclass this_class, jint index);
|
515 |
|
|
|
516 |
|
|
friend void ::_Jv_CopyClassesToSystemLoader (gnu::gcj::runtime::SystemClassLoader *);
|
517 |
|
|
|
518 |
|
|
// Chain for class pool. This also doubles as the ABI version
|
519 |
|
|
// number. It is only used for this purpose at class registration
|
520 |
|
|
// time, and only for precompiled classes.
|
521 |
|
|
jclass next_or_version;
|
522 |
|
|
// Name of class.
|
523 |
|
|
_Jv_Utf8Const *name;
|
524 |
|
|
// Access flags for class.
|
525 |
|
|
_Jv_ushort accflags;
|
526 |
|
|
// The superclass, or null for Object.
|
527 |
|
|
jclass superclass;
|
528 |
|
|
// Class constants.
|
529 |
|
|
_Jv_Constants constants;
|
530 |
|
|
// Methods. If this is an array class, then this field holds a
|
531 |
|
|
// pointer to the element type.
|
532 |
|
|
_Jv_Method *methods;
|
533 |
|
|
// Number of methods. If this class is primitive, this holds the
|
534 |
|
|
// character used to represent this type in a signature.
|
535 |
|
|
jshort method_count;
|
536 |
|
|
// Number of methods in the vtable.
|
537 |
|
|
jshort vtable_method_count;
|
538 |
|
|
// The fields.
|
539 |
|
|
_Jv_Field *fields;
|
540 |
|
|
// Size of instance fields, in bytes.
|
541 |
|
|
jint size_in_bytes;
|
542 |
|
|
// Total number of fields (instance and static).
|
543 |
|
|
jshort field_count;
|
544 |
|
|
// Number of static fields.
|
545 |
|
|
jshort static_field_count;
|
546 |
|
|
// The vtbl for all objects of this class.
|
547 |
|
|
_Jv_VTable *vtable;
|
548 |
|
|
// Virtual method offset table.
|
549 |
|
|
_Jv_OffsetTable *otable;
|
550 |
|
|
// Offset table symbols.
|
551 |
|
|
_Jv_MethodSymbol *otable_syms;
|
552 |
|
|
// Address table
|
553 |
|
|
_Jv_AddressTable *atable;
|
554 |
|
|
_Jv_MethodSymbol *atable_syms;
|
555 |
|
|
// Interface table
|
556 |
|
|
_Jv_AddressTable *itable;
|
557 |
|
|
_Jv_MethodSymbol *itable_syms;
|
558 |
|
|
_Jv_CatchClass *catch_classes;
|
559 |
|
|
// Interfaces implemented by this class.
|
560 |
|
|
jclass *interfaces;
|
561 |
|
|
// The class loader for this class.
|
562 |
|
|
java::lang::ClassLoader *loader;
|
563 |
|
|
// Number of interfaces.
|
564 |
|
|
jshort interface_count;
|
565 |
|
|
// State of this class.
|
566 |
|
|
jbyte state;
|
567 |
|
|
// The thread which has locked this class. Used during class
|
568 |
|
|
// initialization.
|
569 |
|
|
java::lang::Thread *thread;
|
570 |
|
|
// How many levels of "extends" this class is removed from Object.
|
571 |
|
|
jshort depth;
|
572 |
|
|
// Vector of this class's superclasses, ordered by decreasing depth.
|
573 |
|
|
jclass *ancestors;
|
574 |
|
|
// Interface Dispatch Table.
|
575 |
|
|
_Jv_IDispatchTable *idt;
|
576 |
|
|
// Pointer to the class that represents an array of this class.
|
577 |
|
|
jclass arrayclass;
|
578 |
|
|
// Security Domain to which this class belongs (or null).
|
579 |
|
|
java::security::ProtectionDomain *protectionDomain;
|
580 |
|
|
// Pointer to the type assertion table for this class.
|
581 |
|
|
_Jv_TypeAssertion *assertion_table;
|
582 |
|
|
// Signers of this class (or null).
|
583 |
|
|
JArray<jobject> *hack_signers;
|
584 |
|
|
// Used by Jv_PopClass and _Jv_PushClass to communicate with StackTrace.
|
585 |
|
|
jclass chain;
|
586 |
|
|
// Additional data, specific to the generator (JIT, native,
|
587 |
|
|
// interpreter) of this class.
|
588 |
|
|
void *aux_info;
|
589 |
|
|
// Execution engine.
|
590 |
|
|
_Jv_ExecutionEngine *engine;
|
591 |
|
|
};
|
592 |
|
|
|
593 |
|
|
// Inline functions that are friends of java::lang::Class
|
594 |
|
|
|
595 |
|
|
inline void _Jv_InitClass (jclass klass)
|
596 |
|
|
{
|
597 |
|
|
if (__builtin_expect (klass->state == JV_STATE_DONE, true))
|
598 |
|
|
return;
|
599 |
|
|
klass->initializeClass ();
|
600 |
|
|
}
|
601 |
|
|
|
602 |
|
|
// Return array class corresponding to element type KLASS, creating it if
|
603 |
|
|
// necessary.
|
604 |
|
|
inline jclass
|
605 |
|
|
_Jv_GetArrayClass (jclass klass, java::lang::ClassLoader *loader)
|
606 |
|
|
{
|
607 |
|
|
extern void _Jv_NewArrayClass (jclass element,
|
608 |
|
|
java::lang::ClassLoader *loader,
|
609 |
|
|
_Jv_VTable *array_vtable = 0);
|
610 |
|
|
if (__builtin_expect (!klass->arrayclass, false))
|
611 |
|
|
_Jv_NewArrayClass (klass, loader);
|
612 |
|
|
return klass->arrayclass;
|
613 |
|
|
}
|
614 |
|
|
|
615 |
|
|
#endif /* __JAVA_LANG_CLASS_H__ */
|