Assume x86-64 if a 32-bit processor supports SSE2 and 64-bit
[official-gcc.git] / libjava / java / lang / Class.h
blobccca2bc503471308bb22d8fb7a85be82c5fe457d
1 // Class.h - Header file for java.lang.Class. -*- c++ -*-
3 /* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9 details. */
11 // Written primary using compiler source and Class.java as guides.
12 #ifndef __JAVA_LANG_CLASS_H__
13 #define __JAVA_LANG_CLASS_H__
15 #pragma interface
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>
25 // Avoid including SystemClassLoader.h.
26 extern "Java"
28 namespace gnu
30 namespace gcj
32 namespace runtime
34 class SystemClassLoader;
40 // We declare these here to avoid including gcj/cni.h.
41 extern "C" void _Jv_InitClass (jclass klass);
42 extern "C" jclass _Jv_NewClassFromInitializer
43 (const char *class_initializer);
44 extern "C" void _Jv_RegisterNewClasses (char **classes);
45 extern "C" void _Jv_RegisterClasses (const jclass *classes);
46 extern "C" void _Jv_RegisterClasses_Counted (const jclass *classes,
47 size_t count);
49 // This must be predefined with "C" linkage.
50 extern "C" void *_Jv_LookupInterfaceMethodIdx (jclass klass, jclass iface,
51 int meth_idx);
52 extern "C" void *_Jv_ResolvePoolEntry (jclass this_class, jint index);
54 // These are the possible values for the `state' field of the class
55 // structure. Note that ordering is important here. Whenever the
56 // state changes, one should notify all waiters of this class.
57 enum
59 JV_STATE_NOTHING = 0, // Set by compiler.
61 JV_STATE_PRELOADING = 1, // Can do _Jv_FindClass.
63 // There is an invariant through libgcj that a class will always be
64 // at a state greater than or equal to JV_STATE_LOADING when it is
65 // returned by a class loader to user code. Hence, defineclass.cc
66 // installs supers before returning a class, C++-ABI-compiled
67 // classes are created with supers installed, and BC-ABI-compiled
68 // classes are linked to this state before being returned by their
69 // class loader.
70 JV_STATE_LOADING = 3, // Has super installed.
71 JV_STATE_READ = 4, // Has been completely defined.
72 JV_STATE_LOADED = 5, // Has Miranda methods defined.
74 JV_STATE_COMPILED = 6, // This was a compiled class.
76 JV_STATE_PREPARED = 7, // Layout & static init done.
77 JV_STATE_LINKED = 9, // Strings interned.
79 JV_STATE_IN_PROGRESS = 10, // <clinit> running.
81 JV_STATE_ERROR = 12,
83 JV_STATE_PHANTOM = 13, // Bytecode is missing. In many cases we can
84 // work around that. If not, throw a
85 // NoClassDefFoundError.
87 JV_STATE_DONE = 14, // Must be last.
92 struct _Jv_Field;
93 struct _Jv_VTable;
94 union _Jv_word;
95 struct _Jv_ArrayVTable;
96 class _Jv_Linker;
97 class _Jv_ExecutionEngine;
98 class _Jv_CompiledEngine;
99 class _Jv_IndirectCompiledEngine;
101 #ifdef INTERPRETER
102 class _Jv_InterpreterEngine;
103 class _Jv_ClassReader;
104 class _Jv_InterpClass;
105 class _Jv_InterpMethod;
106 #endif
108 class _Jv_ClosureList
110 _Jv_ClosureList *next;
111 void *ptr;
112 public:
113 void registerClosure (jclass klass, void *ptr);
114 static void releaseClosures (_Jv_ClosureList **closures);
117 struct _Jv_Constants
119 jint size;
120 jbyte *tags;
121 _Jv_word *data;
124 struct _Jv_Method
126 // Method name.
127 _Jv_Utf8Const *name;
128 // Method signature.
129 _Jv_Utf8Const *signature;
130 // Access flags.
131 _Jv_ushort accflags;
132 // Method's index in the vtable.
133 _Jv_ushort index;
134 // Pointer to underlying function.
135 void *ncode;
136 // NULL-terminated list of exception class names; can be NULL if
137 // there are none such.
138 _Jv_Utf8Const **throws;
140 _Jv_Method *getNextMethod ()
141 { return this + 1; }
144 // The table used to resolve interface calls.
145 struct _Jv_IDispatchTable
147 // Index into interface's ioffsets.
148 jshort iindex;
149 jshort itable_length;
150 // Class Interface dispatch table.
151 void *itable[0];
154 // Used by _Jv_Linker::get_interfaces ()
155 struct _Jv_ifaces
157 jclass *list;
158 jshort len;
159 jshort count;
162 struct _Jv_MethodSymbol
164 _Jv_Utf8Const *class_name;
165 _Jv_Utf8Const *name;
166 _Jv_Utf8Const *signature;
169 struct _Jv_OffsetTable
171 jint state;
172 jint offsets[];
175 struct _Jv_AddressTable
177 jint state;
178 void *addresses[];
181 struct _Jv_CatchClass
183 java::lang::Class **address;
184 _Jv_Utf8Const *classname;
187 // Possible values for the assertion_code field in the type assertion table.
188 enum
190 JV_ASSERT_END_OF_TABLE = 0,
191 JV_ASSERT_TYPES_COMPATIBLE = 1,
192 JV_ASSERT_IS_INSTANTIABLE = 2
195 // Entry in the type assertion table, used to validate type constraints
196 // for binary compatibility.
197 struct _Jv_TypeAssertion
199 jint assertion_code;
200 _Jv_Utf8Const *op1;
201 _Jv_Utf8Const *op2;
204 typedef enum
206 JV_CLASS_ATTR,
207 JV_METHOD_ATTR,
208 JV_FIELD_ATTR,
209 JV_DONE_ATTR
210 } jv_attr_type;
212 typedef enum
214 JV_INNER_CLASSES_KIND,
215 JV_ENCLOSING_METHOD_KIND,
216 JV_SIGNATURE_KIND,
217 JV_ANNOTATIONS_KIND,
218 JV_PARAMETER_ANNOTATIONS_KIND,
219 JV_ANNOTATION_DEFAULT_KIND
220 } jv_attr_kind;
222 #define JV_PRIMITIVE_VTABLE ((_Jv_VTable *) -1)
224 #define JV_CLASS(Obj) ((jclass) (*(_Jv_VTable **) Obj)->clas)
226 // Forward declarations for friends of java::lang::Class
228 // Friend functions implemented in natClass.cc.
229 _Jv_Method *_Jv_GetMethodLocal (jclass klass, _Jv_Utf8Const *name,
230 _Jv_Utf8Const *signature);
231 jboolean _Jv_IsAssignableFrom (jclass, jclass);
232 jboolean _Jv_IsAssignableFromSlow (jclass, jclass);
233 jboolean _Jv_InterfaceAssignableFrom (jclass, jclass);
235 _Jv_Method* _Jv_LookupDeclaredMethod (jclass, _Jv_Utf8Const *,
236 _Jv_Utf8Const*, jclass * = NULL);
237 java::lang::reflect::Method *_Jv_GetReflectedMethod (jclass klass,
238 _Jv_Utf8Const *name,
239 _Jv_Utf8Const *signature);
240 jfieldID JvGetFirstInstanceField (jclass);
241 jint JvNumInstanceFields (jclass);
242 jfieldID JvGetFirstStaticField (jclass);
243 jint JvNumStaticFields (jclass);
245 jobject _Jv_AllocObject (jclass);
246 void *_Jv_AllocObj (jint, jclass);
247 void *_Jv_AllocPtrFreeObj (jint, jclass);
248 void *_Jv_AllocArray (jint, jclass);
250 bool _Jv_getInterfaceMethod(jclass, jclass&, int&,
251 const _Jv_Utf8Const*,
252 const _Jv_Utf8Const*);
254 jobject JNICALL _Jv_JNI_ToReflectedField (_Jv_JNIEnv *, jclass, jfieldID,
255 jboolean);
256 jobject JNICALL _Jv_JNI_ToReflectedMethod (_Jv_JNIEnv *, jclass, jmethodID,
257 jboolean);
258 jfieldID _Jv_FromReflectedField (java::lang::reflect::Field *);
260 jmethodID _Jv_FromReflectedMethod (java::lang::reflect::Method *);
261 jmethodID _Jv_FromReflectedConstructor (java::lang::reflect::Constructor *);
262 jint JvNumMethods (jclass);
263 jmethodID JvGetFirstMethod (jclass);
264 _Jv_Utf8Const *_Jv_GetClassNameUtf8 (jclass);
266 #ifdef INTERPRETER
267 // Finds a desired interpreter method in the given class or NULL if not found
268 class _Jv_MethodBase;
269 _Jv_MethodBase *_Jv_FindInterpreterMethod (jclass, jmethodID);
270 jstring _Jv_GetInterpClassSourceFile (jclass);
271 #endif
273 jbyte _Jv_GetClassState (jclass);
275 void _Jv_RegisterClassHookDefault (jclass klass);
276 void _Jv_RegisterInitiatingLoader (jclass,java::lang::ClassLoader*);
277 void _Jv_UnregisterInitiatingLoader (jclass,java::lang::ClassLoader*);
278 void _Jv_UnregisterClass (jclass);
279 jclass _Jv_FindClassNoException (_Jv_Utf8Const *name,
280 java::lang::ClassLoader *loader);
281 jclass _Jv_FindClass (_Jv_Utf8Const *name,
282 java::lang::ClassLoader *loader);
283 jclass _Jv_FindClassInCache (_Jv_Utf8Const *name);
284 jclass _Jv_PopClass (void);
285 void _Jv_PushClass (jclass k);
286 void _Jv_NewArrayClass (jclass element,
287 java::lang::ClassLoader *loader,
288 _Jv_VTable *array_vtable = 0);
289 jclass _Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
290 java::lang::ClassLoader *loader);
291 void _Jv_InitNewClassFields (jclass klass);
293 // Friend functions and classes in prims.cc
294 void _Jv_InitPrimClass (jclass, const char *, char, int);
295 jstring _Jv_GetMethodString (jclass, _Jv_Method *, jclass = NULL);
297 jboolean _Jv_CheckAccess (jclass self_klass, jclass other_klass,
298 jint flags);
299 jclass _Jv_GetArrayClass (jclass klass, java::lang::ClassLoader *loader);
301 jboolean _Jv_IsInterpretedClass (jclass);
302 jboolean _Jv_IsBinaryCompatibilityABI (jclass);
304 jboolean _Jv_IsPhantomClass (jclass);
306 void _Jv_CopyClassesToSystemLoader (gnu::gcj::runtime::SystemClassLoader *);
308 #ifdef INTERPRETER
309 void _Jv_InitField (jobject, jclass, int);
310 #endif
312 class _Jv_StackTrace;
313 class _Jv_BytecodeVerifier;
315 void _Jv_sharedlib_register_hook (jclass klass);
317 /* Find the class that defines the given method. Returns NULL
318 if it cannot be found. Searches both interpreted and native
319 classes. */
320 jclass _Jv_GetMethodDeclaringClass (jmethodID method);
322 class java::lang::Class : public java::lang::Object
324 public:
325 static jclass forName (jstring className, jboolean initialize,
326 java::lang::ClassLoader *loader);
327 static jclass forName (jstring className);
328 JArray<jclass> *getClasses (void);
330 java::lang::ClassLoader *getClassLoader (void);
331 private:
332 java::lang::ClassLoader *getClassLoader (jclass caller);
333 public:
334 // This is an internal method that circumvents the usual security
335 // checks when getting the class loader.
336 java::lang::ClassLoader *getClassLoaderInternal (void)
338 return loader;
341 java::lang::reflect::Constructor *getConstructor (JArray<jclass> *);
342 JArray<java::lang::reflect::Constructor *> *getConstructors (void);
343 java::lang::reflect::Constructor *getDeclaredConstructor (JArray<jclass> *);
344 JArray<java::lang::reflect::Constructor *> *getDeclaredConstructors (jboolean);
345 java::lang::reflect::Field *getDeclaredField (jstring);
346 JArray<java::lang::reflect::Field *> *getDeclaredFields ();
347 JArray<java::lang::reflect::Field *> *getDeclaredFields (jboolean);
348 java::lang::reflect::Method *getDeclaredMethod (jstring, JArray<jclass> *);
349 JArray<java::lang::reflect::Method *> *getDeclaredMethods (void);
351 JArray<jclass> *getDeclaredClasses (void);
352 JArray<jclass> *getDeclaredClasses (jboolean);
353 jclass getDeclaringClass (void);
355 java::lang::reflect::Field *getField (jstring);
356 private:
357 JArray<java::lang::reflect::Field *> internalGetFields ();
358 java::lang::reflect::Field *getField (jstring, jint);
359 jint _getMethods (JArray<java::lang::reflect::Method *> *result,
360 jint offset);
361 java::lang::reflect::Field *getPrivateField (jstring);
362 java::lang::reflect::Method *getPrivateMethod (jstring, JArray<jclass> *);
363 java::security::ProtectionDomain *getProtectionDomain0 ();
365 java::lang::reflect::Method *_getMethod (jstring, JArray<jclass> *);
366 java::lang::reflect::Method *_getDeclaredMethod (jstring, JArray<jclass> *);
368 jstring getReflectionSignature (jint /*jv_attr_type*/ type,
369 jint obj_index);
370 jstring getReflectionSignature (::java::lang::reflect::Method *);
371 jstring getReflectionSignature (::java::lang::reflect::Constructor *);
372 jstring getReflectionSignature (::java::lang::reflect::Field *);
374 jstring getClassSignature();
375 jobject getMethodDefaultValue (::java::lang::reflect::Method *);
377 public:
378 JArray<java::lang::reflect::Field *> *getFields (void);
380 JArray<jclass> *getInterfaces (void);
382 void getSignature (java::lang::StringBuffer *buffer);
383 static jstring getSignature (JArray<jclass> *, jboolean is_constructor);
384 JArray<java::lang::reflect::Method *> *getMethods (void);
386 inline jint getModifiers (void)
388 return accflags & java::lang::reflect::Modifier::ALL_FLAGS;
391 jstring getName (void);
393 java::net::URL *getResource (jstring resourceName);
394 java::io::InputStream *getResourceAsStream (jstring resourceName);
395 JArray<jobject> *getSigners (void);
396 void setSigners(JArray<jobject> *);
398 inline jclass getSuperclass (void)
400 return superclass;
403 inline jclass getInterface (jint n)
405 return interfaces[n];
408 inline jboolean isArray (void)
410 return name->first() == '[';
413 inline jclass getComponentType (void)
415 return isArray () ? element_type : 0;
418 jboolean isAssignableFrom (jclass cls);
419 jboolean isInstance (jobject obj);
421 inline jboolean isInterface (void)
423 return (accflags & java::lang::reflect::Modifier::INTERFACE) != 0;
426 inline jboolean isPrimitive (void)
428 return vtable == JV_PRIMITIVE_VTABLE;
431 jobject newInstance (void);
432 java::security::ProtectionDomain *getProtectionDomain (void);
433 java::lang::Package *getPackage (void);
434 jstring toString (void);
435 jboolean desiredAssertionStatus (void);
437 JArray<java::lang::reflect::TypeVariable *> *getTypeParameters (void);
439 jint getEnclosingMethodData(void);
440 java::lang::Class *getEnclosingClass (void);
441 java::lang::reflect::Constructor *getEnclosingConstructor (void);
442 java::lang::reflect::Method *getEnclosingMethod (void);
443 jobjectArray getDeclaredAnnotations(jint, jint, jint);
444 jobjectArray getDeclaredAnnotations(::java::lang::reflect::Method *,
445 jboolean);
446 jobjectArray getDeclaredAnnotations(::java::lang::reflect::Constructor *,
447 jboolean);
448 jobjectArray getDeclaredAnnotations(::java::lang::reflect::Field *);
449 JArray< ::java::lang::annotation::Annotation *> *getDeclaredAnnotationsInternal();
451 jboolean isEnum (void)
453 return (accflags & 0x4000) != 0;
455 jboolean isSynthetic (void)
457 return (accflags & 0x1000) != 0;
459 jboolean isAnnotation (void)
461 return (accflags & 0x2000) != 0;
464 jboolean isAnonymousClass();
465 jboolean isLocalClass();
466 jboolean isMemberClass();
468 // FIXME: this probably shouldn't be public.
469 jint size (void)
471 return size_in_bytes;
474 // The index of the first method we declare ourself (as opposed to
475 // inheriting).
476 inline jint firstMethodIndex (void)
478 return vtable_method_count - method_count;
481 // finalization
482 void finalize ();
484 // This constructor is used to create Class object for the primitive
485 // types. See prims.cc.
486 Class ();
488 // Given the BC ABI version, return the size of an Class initializer.
489 static jlong initializerSize (jlong ABI)
491 unsigned long version = ABI & 0xfffff;
492 int abi_rev = version % 100;
494 // The reflection_data field was added by abi_rev 1.
495 if (abi_rev == 0)
496 return ((char*)(&::java::lang::Class::class$.reflection_data)
497 - (char*)&::java::lang::Class::class$);
499 return sizeof (::java::lang::Class);
502 static java::lang::Class class$;
504 private:
506 void memberAccessCheck (jint flags);
508 void initializeClass (void);
510 static jstring getPackagePortion (jstring);
512 void set_state (jint nstate)
514 state = nstate;
515 notifyAll ();
518 jint findInnerClassAttribute();
519 jint findDeclaredClasses(JArray<jclass> *, jboolean, jint);
521 // Friend functions implemented in natClass.cc.
522 friend _Jv_Method *::_Jv_GetMethodLocal (jclass klass, _Jv_Utf8Const *name,
523 _Jv_Utf8Const *signature);
524 friend jboolean (::_Jv_IsAssignableFrom) (jclass, jclass);
525 friend jboolean (::_Jv_IsAssignableFromSlow) (jclass, jclass);
526 friend jboolean (::_Jv_InterfaceAssignableFrom) (jclass, jclass);
527 friend void *::_Jv_LookupInterfaceMethodIdx (jclass klass, jclass iface,
528 int method_idx);
530 friend void ::_Jv_InitClass (jclass klass);
531 friend java::lang::Class* ::_Jv_NewClassFromInitializer (const char *class_initializer);
532 friend void _Jv_RegisterNewClasses (void **classes);
534 friend _Jv_Method* ::_Jv_LookupDeclaredMethod (jclass, _Jv_Utf8Const *,
535 _Jv_Utf8Const*, jclass *);
536 friend java::lang::reflect::Method* ::_Jv_GetReflectedMethod (jclass klass,
537 _Jv_Utf8Const *name,
538 _Jv_Utf8Const *signature);
539 friend jfieldID (::JvGetFirstInstanceField) (jclass);
540 friend jint (::JvNumInstanceFields) (jclass);
541 friend jfieldID (::JvGetFirstStaticField) (jclass);
542 friend jint (::JvNumStaticFields) (jclass);
544 friend jobject (::_Jv_AllocObject) (jclass);
545 friend void *::_Jv_AllocObj (jint, jclass);
546 friend void *::_Jv_AllocPtrFreeObj (jint, jclass);
547 friend void *::_Jv_AllocArray (jint, jclass);
549 friend jobject JNICALL (::_Jv_JNI_ToReflectedField) (_Jv_JNIEnv *, jclass, jfieldID,
550 jboolean);
551 friend jobject (::_Jv_JNI_ToReflectedMethod) (_Jv_JNIEnv *, jclass, jmethodID,
552 jboolean);
553 friend jfieldID (::_Jv_FromReflectedField) (java::lang::reflect::Field *);
555 friend jmethodID (::_Jv_FromReflectedMethod) (java::lang::reflect::Method *);
556 friend jmethodID (::_Jv_FromReflectedConstructor) (java::lang::reflect::Constructor *);
557 friend jint (::JvNumMethods) (jclass);
558 friend jmethodID (::JvGetFirstMethod) (jclass);
559 friend _Jv_Utf8Const *::_Jv_GetClassNameUtf8 (jclass);
560 #ifdef INTERPRETER
561 friend _Jv_MethodBase *(::_Jv_FindInterpreterMethod) (jclass klass,
562 jmethodID desired_method);
563 friend jstring ::_Jv_GetInterpClassSourceFile (jclass);
564 #endif
565 friend jbyte (::_Jv_GetClassState) (jclass klass);
567 // Friends classes and functions to implement the ClassLoader
568 friend class java::lang::ClassLoader;
569 friend class java::lang::VMClassLoader;
571 friend class java::io::ObjectOutputStream;
572 friend class java::io::ObjectInputStream;
573 friend class java::io::ObjectStreamClass;
575 friend void ::_Jv_RegisterClasses (const jclass *classes);
576 friend void ::_Jv_RegisterClasses_Counted (const jclass *classes,
577 size_t count);
578 friend void ::_Jv_RegisterClassHookDefault (jclass klass);
579 friend void ::_Jv_RegisterInitiatingLoader (jclass,java::lang::ClassLoader*);
580 friend void ::_Jv_UnregisterInitiatingLoader (jclass,java::lang::ClassLoader*);
581 friend void ::_Jv_UnregisterClass (jclass);
582 friend jclass (::_Jv_FindClassNoException) (_Jv_Utf8Const *name,
583 java::lang::ClassLoader *loader);
584 friend jclass (::_Jv_FindClass) (_Jv_Utf8Const *name,
585 java::lang::ClassLoader *loader);
586 friend jclass (::_Jv_FindClassInCache) (_Jv_Utf8Const *name);
587 friend jclass (::_Jv_PopClass) (void);
588 friend void ::_Jv_PushClass (jclass k);
589 friend void ::_Jv_NewArrayClass (jclass element,
590 java::lang::ClassLoader *loader,
591 _Jv_VTable *array_vtable);
592 friend jclass (::_Jv_NewClass) (_Jv_Utf8Const *name, jclass superclass,
593 java::lang::ClassLoader *loader);
594 friend void ::_Jv_InitNewClassFields (jclass klass);
596 // in prims.cc
597 friend void ::_Jv_InitPrimClass (jclass, const char *, char, int);
599 friend jstring (::_Jv_GetMethodString) (jclass, _Jv_Method *, jclass);
601 friend jboolean (::_Jv_CheckAccess) (jclass self_klass, jclass other_klass,
602 jint flags);
604 friend bool (::_Jv_getInterfaceMethod) (jclass, jclass&, int&,
605 const _Jv_Utf8Const*,
606 const _Jv_Utf8Const*);
608 friend jclass (::_Jv_GetArrayClass) (jclass klass,
609 java::lang::ClassLoader *loader);
611 friend jboolean (::_Jv_IsInterpretedClass) (jclass);
612 friend jboolean (::_Jv_IsBinaryCompatibilityABI) (jclass);
614 friend jboolean (::_Jv_IsPhantomClass) (jclass);
616 #ifdef INTERPRETER
617 friend void ::_Jv_InitField (jobject, jclass, int);
619 friend class ::_Jv_ClassReader;
620 friend class ::_Jv_InterpClass;
621 friend class ::_Jv_InterpMethod;
622 friend class ::_Jv_InterpreterEngine;
623 #endif
624 friend class ::_Jv_StackTrace;
626 #ifdef JV_MARKOBJ_DECL
627 friend JV_MARKOBJ_DECL;
628 #endif
630 friend class ::_Jv_BytecodeVerifier;
631 friend class java::io::VMObjectStreamClass;
633 friend class ::_Jv_Linker;
634 friend class ::_Jv_ExecutionEngine;
635 friend class ::_Jv_CompiledEngine;
636 friend class ::_Jv_IndirectCompiledEngine;
637 friend class ::_Jv_ClosureList;
639 friend void ::_Jv_sharedlib_register_hook (jclass klass);
641 friend void *::_Jv_ResolvePoolEntry (jclass this_class, jint index);
643 friend void ::_Jv_CopyClassesToSystemLoader (gnu::gcj::runtime::SystemClassLoader *);
645 friend class java::lang::reflect::Field;
646 friend class java::lang::reflect::Method;
647 friend class java::lang::reflect::Constructor;
648 friend class java::lang::reflect::VMProxy;
650 // Chain for class pool. This also doubles as the ABI version
651 // number. It is only used for this purpose at class registration
652 // time, and only for precompiled classes.
653 jclass next_or_version;
654 // Name of class.
655 _Jv_Utf8Const *name;
656 // Access flags for class.
657 _Jv_ushort accflags;
658 // The superclass, or null for Object.
659 jclass superclass;
660 // Class constants.
661 _Jv_Constants constants;
662 // Methods. If this is an array class, then this field holds a
663 // pointer to the element type.
664 union
666 _Jv_Method *methods;
667 jclass element_type;
669 // Number of methods. If this class is primitive, this holds the
670 // character used to represent this type in a signature.
671 jshort method_count;
672 // Number of methods in the vtable.
673 jshort vtable_method_count;
674 // The fields.
675 _Jv_Field *fields;
676 // Size of instance fields, in bytes.
677 jint size_in_bytes;
678 // Total number of fields (instance and static).
679 jshort field_count;
680 // Number of static fields.
681 jshort static_field_count;
682 // The vtbl for all objects of this class.
683 _Jv_VTable *vtable;
684 // Virtual method offset table.
685 _Jv_OffsetTable *otable;
686 // Offset table symbols.
687 _Jv_MethodSymbol *otable_syms;
688 // Address table
689 _Jv_AddressTable *atable;
690 _Jv_MethodSymbol *atable_syms;
691 // Interface table
692 _Jv_AddressTable *itable;
693 _Jv_MethodSymbol *itable_syms;
694 _Jv_CatchClass *catch_classes;
695 // Interfaces implemented by this class.
696 jclass *interfaces;
697 // The class loader for this class.
698 java::lang::ClassLoader *loader;
699 // Number of interfaces.
700 jshort interface_count;
701 // State of this class.
702 jbyte state;
703 // The thread which has locked this class. Used during class
704 // initialization.
705 java::lang::Thread *thread;
706 // How many levels of "extends" this class is removed from Object.
707 jshort depth;
708 // Vector of this class's superclasses, ordered by decreasing depth.
709 jclass *ancestors;
710 // In a regular class, this field points to the Class Interface Dispatch
711 // Table. In an interface, it points to the ioffsets table.
712 union
714 _Jv_IDispatchTable *idt;
715 jshort *ioffsets;
717 // Pointer to the class that represents an array of this class.
718 jclass arrayclass;
719 // Security Domain to which this class belongs (or null).
720 java::security::ProtectionDomain *protectionDomain;
721 // Pointer to the type assertion table for this class.
722 _Jv_TypeAssertion *assertion_table;
723 // Signers of this class (or null).
724 JArray<jobject> *hack_signers;
725 // Used by Jv_PopClass and _Jv_PushClass to communicate with StackTrace.
726 jclass chain;
727 // Additional data, specific to the generator (JIT, native,
728 // interpreter) of this class.
729 void *aux_info;
730 // Execution engine.
731 _Jv_ExecutionEngine *engine;
732 // Reflection data.
733 unsigned char *reflection_data;
736 // Inline functions that are friends of java::lang::Class
738 inline void _Jv_InitClass (jclass klass)
740 if (__builtin_expect (klass->state == JV_STATE_DONE, true))
741 return;
742 klass->initializeClass ();
745 // Return array class corresponding to element type KLASS, creating it if
746 // necessary.
747 inline jclass
748 _Jv_GetArrayClass (jclass klass, java::lang::ClassLoader *loader)
750 extern void _Jv_NewArrayClass (jclass element,
751 java::lang::ClassLoader *loader,
752 _Jv_VTable *array_vtable = 0);
753 if (__builtin_expect (!klass->arrayclass, false))
754 _Jv_NewArrayClass (klass, loader);
755 return klass->arrayclass;
758 #endif /* __JAVA_LANG_CLASS_H__ */