OSDN Git Service

d0cf5af7e9f76e6b493d6b486825bbc67de47e1d
[pf3gnuchains/gcc-fork.git] / libjava / java / lang / Class.h
1 // 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" 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);
48
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);
53
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
58 {
59   JV_STATE_NOTHING = 0,         // Set by compiler.
60
61   JV_STATE_PRELOADING = 1,      // Can do _Jv_FindClass.
62
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.
73
74   JV_STATE_COMPILED = 6,        // This was a compiled class.
75
76   JV_STATE_PREPARED = 7,        // Layout & static init done.
77   JV_STATE_LINKED = 9,          // Strings interned.
78
79   JV_STATE_IN_PROGRESS = 10,    // <clinit> running.
80
81   JV_STATE_ERROR = 12,
82
83   JV_STATE_PHANTOM = 13,        // Bytecode is missing. In many cases we can
84                                 // work around that. If not, throw a
85                                 // NoClassDefFoundError.
86
87   JV_STATE_DONE = 14,           // Must be last.
88
89
90 };
91
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;
100 class _Jv_InterpreterEngine;
101
102 #ifdef INTERPRETER
103 class _Jv_ClassReader;
104 class _Jv_InterpClass;
105 class _Jv_InterpMethod;
106 #endif
107
108 struct _Jv_Constants
109 {
110   jint size;
111   jbyte *tags;
112   _Jv_word *data;
113 };
114
115 struct _Jv_Method
116 {
117   // Method name.
118   _Jv_Utf8Const *name;
119   // Method signature.
120   _Jv_Utf8Const *signature;
121   // Access flags.
122   _Jv_ushort accflags;
123   // Method's index in the vtable.
124   _Jv_ushort index;
125   // Pointer to underlying function.
126   void *ncode;
127   // NULL-terminated list of exception class names; can be NULL if
128   // there are none such.
129   _Jv_Utf8Const **throws;
130
131   _Jv_Method *getNextMethod ()
132   { return this + 1; }
133 };
134
135 // The table used to resolve interface calls.
136 struct _Jv_IDispatchTable
137 {
138   // Index into interface's ioffsets.
139   jshort iindex;
140   jshort itable_length;
141   // Class Interface dispatch table.
142   void *itable[0];
143 };
144
145 // Used by _Jv_Linker::get_interfaces ()
146 struct _Jv_ifaces
147 {
148   jclass *list;
149   jshort len;
150   jshort count;
151 };
152
153 struct _Jv_MethodSymbol
154 {
155   _Jv_Utf8Const *class_name;
156   _Jv_Utf8Const *name;
157   _Jv_Utf8Const *signature;
158 };
159
160 struct _Jv_OffsetTable
161 {
162   jint state;
163   jint offsets[];
164 };
165
166 struct _Jv_AddressTable
167 {
168   jint state;
169   void *addresses[];
170 };
171
172 struct _Jv_CatchClass
173 {
174   java::lang::Class **address;
175   _Jv_Utf8Const *classname;
176 };
177
178 // Possible values for the assertion_code field in the type assertion table.
179 enum
180 {
181   JV_ASSERT_END_OF_TABLE = 0,
182   JV_ASSERT_TYPES_COMPATIBLE = 1,
183   JV_ASSERT_IS_INSTANTIABLE = 2
184 };
185
186 // Entry in the type assertion table, used to validate type constraints
187 // for binary compatibility.
188 struct _Jv_TypeAssertion
189 {
190   jint assertion_code;
191   _Jv_Utf8Const *op1;
192   _Jv_Utf8Const *op2;
193 };
194
195 typedef enum
196 {
197   JV_CLASS_ATTR,
198   JV_METHOD_ATTR,
199   JV_FIELD_ATTR,
200   JV_DONE_ATTR
201 } jv_attr_type;
202
203 typedef enum
204 {
205   JV_INNER_CLASSES_KIND,
206   JV_ENCLOSING_METHOD_KIND,
207   JV_SIGNATURE_KIND,
208   JV_ANNOTATIONS_KIND,
209   JV_PARAMETER_ANNOTATIONS_KIND,
210   JV_ANNOTATION_DEFAULT_KIND
211 } jv_attr_kind;
212
213 #define JV_PRIMITIVE_VTABLE ((_Jv_VTable *) -1)
214
215 #define JV_CLASS(Obj) ((jclass) (*(_Jv_VTable **) Obj)->clas)
216
217 // Forward declarations for friends of java::lang::Class
218
219 // Friend functions implemented in natClass.cc.
220 _Jv_Method *_Jv_GetMethodLocal (jclass klass, _Jv_Utf8Const *name,
221                                 _Jv_Utf8Const *signature);
222 jboolean _Jv_IsAssignableFrom (jclass, jclass);
223 jboolean _Jv_IsAssignableFromSlow (jclass, jclass);
224 jboolean _Jv_InterfaceAssignableFrom (jclass, jclass);
225
226 _Jv_Method* _Jv_LookupDeclaredMethod (jclass, _Jv_Utf8Const *, 
227                                       _Jv_Utf8Const*, jclass * = NULL);
228 jfieldID JvGetFirstInstanceField (jclass);
229 jint JvNumInstanceFields (jclass);
230 jfieldID JvGetFirstStaticField (jclass);
231 jint JvNumStaticFields (jclass);
232
233 jobject _Jv_AllocObject (jclass);
234 void *_Jv_AllocObj (jint, jclass);
235 void *_Jv_AllocPtrFreeObj (jint, jclass);
236 void *_Jv_AllocArray (jint, jclass);
237
238 bool _Jv_getInterfaceMethod(jclass, jclass&, int&, 
239                             const _Jv_Utf8Const*,
240                             const _Jv_Utf8Const*);
241
242 jobject _Jv_JNI_ToReflectedField (_Jv_JNIEnv *, jclass, jfieldID,
243                                   jboolean);
244 jobject _Jv_JNI_ToReflectedMethod (_Jv_JNIEnv *, jclass, jmethodID,
245                                    jboolean);
246 jfieldID _Jv_FromReflectedField (java::lang::reflect::Field *);
247
248 jmethodID _Jv_FromReflectedMethod (java::lang::reflect::Method *);
249 jmethodID _Jv_FromReflectedConstructor (java::lang::reflect::Constructor *);
250 jint JvNumMethods (jclass);
251 jmethodID JvGetFirstMethod (jclass);
252 _Jv_Utf8Const *_Jv_GetClassNameUtf8 (jclass);
253
254 #ifdef INTERPRETER
255 // Finds a desired interpreter method in the given class or NULL if not found
256 class _Jv_MethodBase;
257 _Jv_MethodBase *_Jv_FindInterpreterMethod (jclass, jmethodID);
258 #endif
259
260 // Friend classes and functions to implement the ClassLoader
261 class java::lang::ClassLoader;
262 class java::lang::VMClassLoader;
263
264 class java::io::ObjectOutputStream;
265 class java::io::ObjectInputStream;
266 class java::io::ObjectStreamClass;
267
268 void _Jv_RegisterClassHookDefault (jclass klass);
269 void _Jv_RegisterInitiatingLoader (jclass,java::lang::ClassLoader*);
270 void _Jv_UnregisterInitiatingLoader (jclass,java::lang::ClassLoader*);
271 void _Jv_UnregisterClass (jclass);
272 jclass _Jv_FindClassNoException (_Jv_Utf8Const *name,
273                       java::lang::ClassLoader *loader);
274 jclass _Jv_FindClass (_Jv_Utf8Const *name,
275                       java::lang::ClassLoader *loader);
276 jclass _Jv_FindClassInCache (_Jv_Utf8Const *name);
277 jclass _Jv_PopClass (void);
278 void _Jv_PushClass (jclass k);
279 void _Jv_NewArrayClass (jclass element,
280                         java::lang::ClassLoader *loader,
281                         _Jv_VTable *array_vtable = 0);
282 jclass _Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
283                      java::lang::ClassLoader *loader);
284 void _Jv_InitNewClassFields (jclass klass);
285
286 // Friend functions and classes in prims.cc
287 void _Jv_InitPrimClass (jclass, const char *, char, int);
288 jstring _Jv_GetMethodString (jclass, _Jv_Method *, jclass = NULL);
289
290 jboolean _Jv_CheckAccess (jclass self_klass, jclass other_klass,
291                           jint flags);
292 jclass _Jv_GetArrayClass (jclass klass, java::lang::ClassLoader *loader);
293
294 jboolean _Jv_IsInterpretedClass (jclass);
295 jboolean _Jv_IsBinaryCompatibilityABI (jclass);
296
297 jboolean _Jv_IsPhantomClass (jclass);
298
299 void _Jv_CopyClassesToSystemLoader (gnu::gcj::runtime::SystemClassLoader *);
300
301 #ifdef INTERPRETER
302 void _Jv_InitField (jobject, jclass, int);
303 #endif
304
305 class _Jv_StackTrace;
306 class _Jv_BytecodeVerifier;
307 class java::io::VMObjectStreamClass;
308
309 void _Jv_sharedlib_register_hook (jclass klass);
310
311 /* Find the class that defines the given method. Returns NULL
312    if it cannot be found. Searches both interpreted and native
313    classes. */
314 jclass _Jv_GetMethodDeclaringClass (jmethodID method);
315
316 class java::lang::Class : public java::lang::Object
317 {
318 public:
319   static jclass forName (jstring className, jboolean initialize, 
320                          java::lang::ClassLoader *loader);
321   static jclass forName (jstring className);
322   JArray<jclass> *getClasses (void);
323
324   java::lang::ClassLoader *getClassLoader (void);
325 private:
326   java::lang::ClassLoader *getClassLoader (jclass caller);
327 public:
328   // This is an internal method that circumvents the usual security
329   // checks when getting the class loader.
330   java::lang::ClassLoader *getClassLoaderInternal (void)
331   {
332     return loader;
333   }
334
335   java::lang::reflect::Constructor *getConstructor (JArray<jclass> *);
336   JArray<java::lang::reflect::Constructor *> *getConstructors (void);
337   java::lang::reflect::Constructor *getDeclaredConstructor (JArray<jclass> *);
338   JArray<java::lang::reflect::Constructor *> *getDeclaredConstructors (jboolean);
339   java::lang::reflect::Field *getDeclaredField (jstring);
340   JArray<java::lang::reflect::Field *> *getDeclaredFields ();
341   JArray<java::lang::reflect::Field *> *getDeclaredFields (jboolean);
342   java::lang::reflect::Method *getDeclaredMethod (jstring, JArray<jclass> *);
343   JArray<java::lang::reflect::Method *> *getDeclaredMethods (void);
344
345   JArray<jclass> *getDeclaredClasses (void);
346   JArray<jclass> *getDeclaredClasses (jboolean);
347   jclass getDeclaringClass (void);
348
349   java::lang::reflect::Field *getField (jstring);
350 private:
351   JArray<java::lang::reflect::Field *> internalGetFields ();
352   java::lang::reflect::Field *getField (jstring, jint);
353   jint _getMethods (JArray<java::lang::reflect::Method *> *result,
354                     jint offset);
355   java::lang::reflect::Field *getPrivateField (jstring);
356   java::lang::reflect::Method *getPrivateMethod (jstring, JArray<jclass> *);
357   java::security::ProtectionDomain *getProtectionDomain0 ();
358
359   java::lang::reflect::Method *_getMethod (jstring, JArray<jclass> *);
360   java::lang::reflect::Method *_getDeclaredMethod (jstring, JArray<jclass> *);
361
362   jstring getReflectionSignature (jint /*jv_attr_type*/ type,
363                                   jint obj_index);
364   jstring getReflectionSignature (::java::lang::reflect::Method *);
365   jstring getReflectionSignature (::java::lang::reflect::Constructor *);
366   jstring getReflectionSignature (::java::lang::reflect::Field *);
367
368   jstring getClassSignature();
369   jobject getMethodDefaultValue (::java::lang::reflect::Method *);
370
371 public:
372   JArray<java::lang::reflect::Field *> *getFields (void);
373
374   JArray<jclass> *getInterfaces (void);
375
376   void getSignature (java::lang::StringBuffer *buffer);
377   static jstring getSignature (JArray<jclass> *, jboolean is_constructor);
378   JArray<java::lang::reflect::Method *> *getMethods (void);
379
380   inline jint getModifiers (void)
381   {
382     return accflags & java::lang::reflect::Modifier::ALL_FLAGS;
383   }
384
385   jstring getName (void);
386
387   java::net::URL        *getResource (jstring resourceName);
388   java::io::InputStream *getResourceAsStream (jstring resourceName);
389   JArray<jobject> *getSigners (void);
390   void setSigners(JArray<jobject> *);
391
392   inline jclass getSuperclass (void)
393   {
394     return superclass;
395   }
396
397   inline jclass getInterface (jint n)
398   {
399     return interfaces[n];
400   }
401
402   inline jboolean isArray (void)
403     {
404       return name->first() == '[';
405     }
406
407   inline jclass getComponentType (void)
408     {
409       return isArray () ? element_type : 0;
410     }
411
412   jboolean isAssignableFrom (jclass cls);
413   jboolean isInstance (jobject obj);
414
415   inline jboolean isInterface (void)
416   {
417     return (accflags & java::lang::reflect::Modifier::INTERFACE) != 0;
418   }
419   
420   inline jboolean isPrimitive (void)
421     {
422       return vtable == JV_PRIMITIVE_VTABLE;
423     }
424
425   jobject newInstance (void);
426   java::security::ProtectionDomain *getProtectionDomain (void);
427   java::lang::Package *getPackage (void);
428   jstring toString (void);
429   jboolean desiredAssertionStatus (void);
430
431   JArray<java::lang::reflect::TypeVariable *> *getTypeParameters (void);
432
433   jint getEnclosingMethodData(void);
434   java::lang::Class *getEnclosingClass (void);
435   java::lang::reflect::Constructor *getEnclosingConstructor (void);
436   java::lang::reflect::Method *getEnclosingMethod (void);
437   jobjectArray getDeclaredAnnotations(jint, jint, jint);
438   jobjectArray getDeclaredAnnotations(::java::lang::reflect::Method *,
439                                       jboolean);
440   jobjectArray getDeclaredAnnotations(::java::lang::reflect::Constructor *,
441                                       jboolean);
442   jobjectArray getDeclaredAnnotations(::java::lang::reflect::Field *);
443   JArray< ::java::lang::annotation::Annotation *> *getDeclaredAnnotationsInternal();
444
445   jboolean isEnum (void)
446   {
447     return (accflags & 0x4000) != 0;
448   }
449   jboolean isSynthetic (void)
450   {
451     return (accflags & 0x1000) != 0;
452   }
453   jboolean isAnnotation (void)
454   {
455     return (accflags & 0x2000) != 0;
456   }
457
458   jboolean isAnonymousClass();
459   jboolean isLocalClass();
460   jboolean isMemberClass();
461
462   // FIXME: this probably shouldn't be public.
463   jint size (void)
464   {
465     return size_in_bytes;
466   }
467
468   // The index of the first method we declare ourself (as opposed to
469   // inheriting).
470   inline jint firstMethodIndex (void)
471   {
472     return vtable_method_count - method_count;
473   }
474     
475   // finalization
476   void finalize ();
477
478   // This constructor is used to create Class object for the primitive
479   // types. See prims.cc.
480   Class ();
481
482   // Given the BC ABI version, return the size of an Class initializer.
483   static jlong initializerSize (jlong ABI)
484   {
485     unsigned long version = ABI & 0xfffff;
486     int abi_rev = version % 100;
487     
488     // The reflection_data field was added by abi_rev 1.
489     if (abi_rev == 0)
490       return ((char*)(&::java::lang::Class::class$.reflection_data)
491               - (char*)&::java::lang::Class::class$);
492     
493     return sizeof (::java::lang::Class);
494   }
495
496   static java::lang::Class class$;
497
498 private:   
499
500   void memberAccessCheck (jint flags);
501
502   void initializeClass (void);
503
504   static jstring getPackagePortion (jstring);
505
506   void set_state (jint nstate)
507   {
508     state = nstate;
509     notifyAll ();
510   }
511
512   jint findInnerClassAttribute();
513   jint findDeclaredClasses(JArray<jclass> *, jboolean, jint);
514
515   // Friend functions implemented in natClass.cc.
516   friend _Jv_Method *::_Jv_GetMethodLocal (jclass klass, _Jv_Utf8Const *name,
517                                            _Jv_Utf8Const *signature);
518   friend jboolean (::_Jv_IsAssignableFrom) (jclass, jclass);
519   friend jboolean (::_Jv_IsAssignableFromSlow) (jclass, jclass);
520   friend jboolean (::_Jv_InterfaceAssignableFrom) (jclass, jclass);
521   friend void *::_Jv_LookupInterfaceMethodIdx (jclass klass, jclass iface, 
522                                                int method_idx);
523
524   friend void ::_Jv_InitClass (jclass klass);
525   friend java::lang::Class* ::_Jv_NewClassFromInitializer (const char *class_initializer);
526   friend void _Jv_RegisterNewClasses (void **classes);
527
528   friend _Jv_Method* ::_Jv_LookupDeclaredMethod (jclass, _Jv_Utf8Const *, 
529                                                  _Jv_Utf8Const*, jclass *);
530   friend jfieldID (::JvGetFirstInstanceField) (jclass);
531   friend jint (::JvNumInstanceFields) (jclass);
532   friend jfieldID (::JvGetFirstStaticField) (jclass);
533   friend jint (::JvNumStaticFields) (jclass);
534
535   friend jobject (::_Jv_AllocObject) (jclass);
536   friend void *::_Jv_AllocObj (jint, jclass);
537   friend void *::_Jv_AllocPtrFreeObj (jint, jclass);
538   friend void *::_Jv_AllocArray (jint, jclass);
539
540   friend jobject (::_Jv_JNI_ToReflectedField) (_Jv_JNIEnv *, jclass, jfieldID,
541                                                jboolean);
542   friend jobject (::_Jv_JNI_ToReflectedMethod) (_Jv_JNIEnv *, jclass, jmethodID,
543                                                 jboolean);
544   friend jfieldID (::_Jv_FromReflectedField) (java::lang::reflect::Field *);
545
546   friend jmethodID (::_Jv_FromReflectedMethod) (java::lang::reflect::Method *);
547   friend jmethodID (::_Jv_FromReflectedConstructor) (java::lang::reflect::Constructor *);
548   friend jint (::JvNumMethods) (jclass);
549   friend jmethodID (::JvGetFirstMethod) (jclass);
550   friend _Jv_Utf8Const *::_Jv_GetClassNameUtf8 (jclass);
551 #ifdef INTERPRETER
552   friend _Jv_MethodBase *(::_Jv_FindInterpreterMethod) (jclass klass,
553                                                         jmethodID desired_method);
554 #endif
555
556   // Friends classes and functions to implement the ClassLoader
557   friend class java::lang::ClassLoader;
558   friend class java::lang::VMClassLoader;
559
560   friend class java::io::ObjectOutputStream;
561   friend class java::io::ObjectInputStream;
562   friend class java::io::ObjectStreamClass;
563
564   friend void ::_Jv_RegisterClasses (const jclass *classes);
565   friend void ::_Jv_RegisterClasses_Counted (const jclass *classes, 
566                                              size_t count);
567   friend void ::_Jv_RegisterClassHookDefault (jclass klass);
568   friend void ::_Jv_RegisterInitiatingLoader (jclass,java::lang::ClassLoader*);
569   friend void ::_Jv_UnregisterInitiatingLoader (jclass,java::lang::ClassLoader*);
570   friend void ::_Jv_UnregisterClass (jclass);
571   friend jclass (::_Jv_FindClassNoException) (_Jv_Utf8Const *name,
572                                    java::lang::ClassLoader *loader);
573   friend jclass (::_Jv_FindClass) (_Jv_Utf8Const *name,
574                                    java::lang::ClassLoader *loader);
575   friend jclass (::_Jv_FindClassInCache) (_Jv_Utf8Const *name);
576   friend jclass (::_Jv_PopClass) (void);
577   friend void ::_Jv_PushClass (jclass k);
578   friend void ::_Jv_NewArrayClass (jclass element,
579                                    java::lang::ClassLoader *loader,
580                                    _Jv_VTable *array_vtable);
581   friend jclass (::_Jv_NewClass) (_Jv_Utf8Const *name, jclass superclass,
582                                   java::lang::ClassLoader *loader);
583   friend void ::_Jv_InitNewClassFields (jclass klass);
584
585   // in prims.cc
586   friend void ::_Jv_InitPrimClass (jclass, const char *, char, int);
587
588   friend jstring (::_Jv_GetMethodString) (jclass, _Jv_Method *, jclass);
589
590   friend jboolean (::_Jv_CheckAccess) (jclass self_klass, jclass other_klass,
591                                    jint flags);
592   
593   friend bool (::_Jv_getInterfaceMethod) (jclass, jclass&, int&, 
594                                           const _Jv_Utf8Const*,
595                                           const _Jv_Utf8Const*);
596
597   friend jclass (::_Jv_GetArrayClass) (jclass klass,
598                                        java::lang::ClassLoader *loader);
599
600   friend jboolean (::_Jv_IsInterpretedClass) (jclass);
601   friend jboolean (::_Jv_IsBinaryCompatibilityABI) (jclass);
602
603   friend jboolean (::_Jv_IsPhantomClass) (jclass);
604
605 #ifdef INTERPRETER
606   friend void ::_Jv_InitField (jobject, jclass, int);
607
608   friend class ::_Jv_ClassReader;       
609   friend class ::_Jv_InterpClass;
610   friend class ::_Jv_InterpMethod;
611 #endif
612   friend class ::_Jv_StackTrace;
613
614 #ifdef JV_MARKOBJ_DECL
615   friend JV_MARKOBJ_DECL;
616 #endif
617
618   friend class ::_Jv_BytecodeVerifier;
619   friend class java::io::VMObjectStreamClass;
620
621   friend class ::_Jv_Linker;
622   friend class ::_Jv_ExecutionEngine;
623   friend class ::_Jv_CompiledEngine;
624   friend class ::_Jv_IndirectCompiledEngine;
625   friend class ::_Jv_InterpreterEngine;
626
627   friend void ::_Jv_sharedlib_register_hook (jclass klass);
628
629   friend void *::_Jv_ResolvePoolEntry (jclass this_class, jint index);
630
631   friend void ::_Jv_CopyClassesToSystemLoader (gnu::gcj::runtime::SystemClassLoader *);
632
633   friend class java::lang::reflect::Field;
634   friend class java::lang::reflect::Method;
635   friend class java::lang::reflect::Constructor;
636   friend class java::lang::reflect::VMProxy;
637
638   // Chain for class pool.  This also doubles as the ABI version
639   // number.  It is only used for this purpose at class registration
640   // time, and only for precompiled classes.
641   jclass next_or_version;
642   // Name of class.
643   _Jv_Utf8Const *name;
644   // Access flags for class.
645   _Jv_ushort accflags;
646   // The superclass, or null for Object.
647   jclass superclass;
648   // Class constants.
649   _Jv_Constants constants;
650   // Methods.  If this is an array class, then this field holds a
651   // pointer to the element type.
652   union
653   {
654     _Jv_Method *methods;
655     jclass element_type;
656   };
657   // Number of methods.  If this class is primitive, this holds the
658   // character used to represent this type in a signature.
659   jshort method_count;
660   // Number of methods in the vtable.
661   jshort vtable_method_count;
662   // The fields.
663   _Jv_Field *fields;
664   // Size of instance fields, in bytes.
665   jint size_in_bytes;
666   // Total number of fields (instance and static).
667   jshort field_count;
668   // Number of static fields.
669   jshort static_field_count;
670   // The vtbl for all objects of this class.
671   _Jv_VTable *vtable;
672   // Virtual method offset table.
673   _Jv_OffsetTable *otable;
674   // Offset table symbols.
675   _Jv_MethodSymbol *otable_syms;
676   // Address table
677   _Jv_AddressTable *atable;
678   _Jv_MethodSymbol *atable_syms;
679   // Interface table
680   _Jv_AddressTable *itable;
681   _Jv_MethodSymbol *itable_syms;
682   _Jv_CatchClass *catch_classes;
683   // Interfaces implemented by this class.
684   jclass *interfaces;
685   // The class loader for this class.
686   java::lang::ClassLoader *loader;
687   // Number of interfaces.
688   jshort interface_count;
689   // State of this class.
690   jbyte state;
691   // The thread which has locked this class.  Used during class
692   // initialization.
693   java::lang::Thread *thread;
694   // How many levels of "extends" this class is removed from Object.
695   jshort depth;
696   // Vector of this class's superclasses, ordered by decreasing depth.
697   jclass *ancestors;
698   // In a regular class, this field points to the Class Interface Dispatch 
699   // Table. In an interface, it points to the ioffsets table.
700   union 
701   {
702     _Jv_IDispatchTable *idt;
703     jshort *ioffsets;
704   };
705   // Pointer to the class that represents an array of this class.
706   jclass arrayclass;
707   // Security Domain to which this class belongs (or null).
708   java::security::ProtectionDomain *protectionDomain;
709   // Pointer to the type assertion table for this class.
710   _Jv_TypeAssertion *assertion_table;
711   // Signers of this class (or null).
712   JArray<jobject> *hack_signers;
713   // Used by Jv_PopClass and _Jv_PushClass to communicate with StackTrace.
714   jclass chain;
715   // Additional data, specific to the generator (JIT, native,
716   // interpreter) of this class.
717   void *aux_info;
718   // Execution engine.
719   _Jv_ExecutionEngine *engine;
720   // Reflection data.
721   unsigned char *reflection_data;
722 };
723
724 // Inline functions that are friends of java::lang::Class
725
726 inline void _Jv_InitClass (jclass klass)
727 {
728   if (__builtin_expect (klass->state == JV_STATE_DONE, true))
729     return;
730   klass->initializeClass ();  
731 }
732
733 // Return array class corresponding to element type KLASS, creating it if
734 // necessary.
735 inline jclass
736 _Jv_GetArrayClass (jclass klass, java::lang::ClassLoader *loader)
737 {
738   extern void _Jv_NewArrayClass (jclass element,
739                                  java::lang::ClassLoader *loader,
740                                  _Jv_VTable *array_vtable = 0);
741   if (__builtin_expect (!klass->arrayclass, false))
742     _Jv_NewArrayClass (klass, loader);
743   return klass->arrayclass;
744 }
745
746 #endif /* __JAVA_LANG_CLASS_H__ */