diff options
author | Bryce McKinlay <bryce@albatross.co.nz> | 2000-03-07 09:52:56 +0000 |
---|---|---|
committer | Bryce McKinlay <bryce@gcc.gnu.org> | 2000-03-07 09:52:56 +0000 |
commit | ddf0fc6c9f1eb8747c9cf6b69e48f11f779632d2 (patch) | |
tree | 3d1200ab45d37376fcbddeff18a6199837857dca /libjava/java/lang/Class.h | |
parent | 173f556ccc41ea93cf66896d0c7778241467407f (diff) | |
download | gcc-ddf0fc6c9f1eb8747c9cf6b69e48f11f779632d2.zip gcc-ddf0fc6c9f1eb8747c9cf6b69e48f11f779632d2.tar.gz gcc-ddf0fc6c9f1eb8747c9cf6b69e48f11f779632d2.tar.bz2 |
resolve.cc (_Jv_SearchMethodInClass): New function.
2000-03-07 Bryce McKinlay <bryce@albatross.co.nz>
* resolve.cc (_Jv_SearchMethodInClass): New function.
(_Jv_ResolvePoolEntry): Search superinterfaces for interface
methods.
* java/lang/Class.h (_Jv_SearchMethodInClass): New prototype.
2000-03-07 Bryce McKinlay <bryce@albatross.co.nz>
* java/lang/Class.h (union _Jv_IDispatchTable): New declaration.
(struct _Jv_ifaces): New declaration.
JV_CLASS: New macro definition.
(getComponentType): Relocate below isArray() for inlining.
(getModifiers): Declare `inline'.
(getSuperclass): Ditto.
(isArray): Ditto.
(isPrimitive): Ditto.
(_Jv_IsAssignableFrom): New prototype.
(_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C"
linkage.
(_Jv_InitClass): Move from natClass.cc. Declare `inline'.
Check for JV_STATE_DONE before invoking initializeClass().
(_Jv_PrepareConstantTimeTables): New prototype.
(_Jv_GetInterfaces): Ditto.
(_Jv_GenerateITable): Ditto.
(_Jv_GetMethodString): Ditto.
(_Jv_AppendPartialITable): Ditto.
(_Jv_FindIIndex): Ditto.
depth, ancestors, idt: New class fields.
* java/lang/natClass.cc (isAssignableFrom): Move functionality to
inline function `_Jv_IsAssignableFrom'. Use that function.
(isInstance): Declare `inline'.
(initializeClass): Get lock on class before checking `state'. Unlock
before calling resolveClass0. Call _Jv_PrepareConstantTimeTables
with the lock held.
(_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString.
(_Jv_IsAssignableFrom): New inline function. Test assignability
using class->depth and ancestor table.
(_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom.
(_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and
_Jv_IsAssignableFrom.
(_Jv_CheckArrayStore): Ditto.
(_Jv_LookupInterfaceMethodIdx): New function.
INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines.
(_Jv_PrepareConstantTimeTables): New function.
(_Jv_IndexOf): Ditto.
(_Jv_GetInterfaces): Ditto.
(_Jv_GenerateITable): Ditto.
(_Jv_GetMethodString): Ditto.
(_Jv_AppendPartialITable): Ditto.
iindex_mutex, iindex_mutex_initialized: New static fields.
(_Jv_FindIIndex): New function.
* java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields.
* prims.cc (_Jv_CheckCast): Moved to natClass.cc.
(_Jv_CheckArrayStore): Ditto.
(JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray,
JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray):
Moved to gcj/array.h.
(_Jv_Realloc): New function.
* gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h.
* gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h.
(JvNewCharArray, JvNewBooleanArray, JvNewByteArray,
JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray,
JvNewDoubleArray): Implementations moved from prims.cc and
declared `inline'.
* gcj/javaprims.h (_Jv_Realloc): Prototype.
* include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype.
From-SVN: r32382
Diffstat (limited to 'libjava/java/lang/Class.h')
-rw-r--r-- | libjava/java/lang/Class.h | 88 |
1 files changed, 73 insertions, 15 deletions
diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h index 717eed7..8aefb70 100644 --- a/libjava/java/lang/Class.h +++ b/libjava/java/lang/Class.h @@ -22,6 +22,10 @@ details. */ extern "C" void _Jv_InitClass (jclass klass); extern "C" void _Jv_RegisterClasses (jclass *classes); +// This must be predefined with "C" linkage. +extern "C" void *_Jv_LookupInterfaceMethodIdx (jclass klass, jclass iface, + int meth_idx); + // These are the possible values for the `state' field of the class // structure. Note that ordering is important here. Whenever the // state changes, one should notify all waiters of this class. @@ -60,13 +64,41 @@ struct _Jv_Method _Jv_Utf8Const *signature; _Jv_ushort accflags; void *ncode; - _Jv_Method *getNextMethod () { return this + 1; } }; +// Interface Dispatch Tables +union _Jv_IDispatchTable +{ + struct + { + // Index into interface's ioffsets. + jshort iindex; + jshort itable_length; + // Class Interface dispatch table. + void **itable; + } cls; + + struct + { + // Offsets into implementation class itables. + jshort *ioffsets; + } iface; +}; + +// Used by _Jv_GetInterfaces () +struct _Jv_ifaces +{ + jclass *list; + jshort len; + jshort count; +}; + #define JV_PRIMITIVE_VTABLE ((_Jv_VTable *) -1) +#define JV_CLASS(Obj) ((jclass) (*(_Jv_VTable **) Obj)->clas) + class java::lang::Class : public java::lang::Object { public: @@ -78,11 +110,6 @@ public: return loader; } - jclass getComponentType (void) - { - return isArray () ? (* (jclass *) &methods) : 0; - } - java::lang::reflect::Constructor *getConstructor (JArray<jclass> *); JArray<java::lang::reflect::Constructor *> *getConstructors (void); java::lang::reflect::Constructor *getDeclaredConstructor (JArray<jclass> *); @@ -112,7 +139,7 @@ public: java::lang::reflect::Method *getMethod (jstring, JArray<jclass> *); JArray<java::lang::reflect::Method *> *getMethods (void); - jint getModifiers (void) + inline jint getModifiers (void) { return accflags; } @@ -123,21 +150,26 @@ public: java::io::InputStream *getResourceAsStream (jstring resourceName); JArray<jobject> *getSigners (void); - jclass getSuperclass (void) + inline jclass getSuperclass (void) { return superclass; } - jboolean isArray (void) + inline jboolean isArray (void) { return name->data[0] == '['; } + inline jclass getComponentType (void) + { + return isArray () ? (* (jclass *) &methods) : 0; + } + jboolean isAssignableFrom (jclass cls); jboolean isInstance (jobject obj); jboolean isInterface (void); - - jboolean isPrimitive (void) + + inline jboolean isPrimitive (void) { return vtable == JV_PRIMITIVE_VTABLE; } @@ -150,11 +182,12 @@ public: { return size_in_bytes; } - + // finalization void finalize (); -private: +private: + void checkMemberAccess (jint flags); void initializeClass (void); @@ -162,10 +195,19 @@ private: // Friend functions implemented in natClass.cc. friend _Jv_Method *_Jv_GetMethodLocal (jclass klass, _Jv_Utf8Const *name, _Jv_Utf8Const *signature); + friend jboolean _Jv_IsAssignableFrom(jclass, jclass); + friend void *_Jv_LookupInterfaceMethodIdx (jclass klass, jclass iface, + int method_idx); + + inline friend void + _Jv_InitClass (jclass klass) + { + if (klass->state != JV_STATE_DONE) + klass->initializeClass (); + } + friend _Jv_Method* _Jv_LookupDeclaredMethod (jclass, _Jv_Utf8Const *, _Jv_Utf8Const*); - friend void _Jv_InitClass (jclass klass); - friend jfieldID JvGetFirstInstanceField (jclass); friend jint JvNumInstanceFields (jclass); friend jfieldID JvGetFirstStaticField (jclass); @@ -205,6 +247,12 @@ private: java::lang::ClassLoader *loader); friend void _Jv_PrepareCompiledClass (jclass); + friend void _Jv_PrepareConstantTimeTables (jclass); + friend jshort _Jv_GetInterfaces (jclass, _Jv_ifaces *); + friend void _Jv_GenerateITable (jclass, _Jv_ifaces *, jshort *); + friend jstring _Jv_GetMethodString(jclass, _Jv_Utf8Const *); + friend jshort _Jv_AppendPartialITable (jclass, jclass, void **, jshort); + friend jshort _Jv_FindIIndex (jclass *, jshort *, jshort); #ifdef INTERPRETER friend jboolean _Jv_IsInterpretedClass (jclass); @@ -213,6 +261,10 @@ private: _Jv_Utf8Const*); friend void _Jv_InitField (jobject, jclass, int); friend _Jv_word _Jv_ResolvePoolEntry (jclass, int); + friend _Jv_Method *_Jv_SearchMethodInClass (jclass cls, jclass klass, + _Jv_Utf8Const *method_name, + _Jv_Utf8Const *method_signature); + friend void _Jv_PrepareClass (jclass); friend class _Jv_ClassReader; @@ -265,6 +317,12 @@ private: // The thread which has locked this class. Used during class // initialization. java::lang::Thread *thread; + // How many levels of "extends" this class is removed from Object. + jshort depth; + // Vector of this class's superclasses, ordered by decreasing depth. + jclass *ancestors; + // Interface Dispatch Table. + _Jv_IDispatchTable *idt; }; #endif /* __JAVA_LANG_CLASS_H__ */ |