OSDN Git Service

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