OSDN Git Service

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