diff options
author | Per Bothner <per@bothner.com> | 2001-08-31 18:26:14 -0700 |
---|---|---|
committer | Per Bothner <bothner@gcc.gnu.org> | 2001-08-31 18:26:14 -0700 |
commit | dee45a7f96660c4e19bef6462ff1b2d1932220e4 (patch) | |
tree | 40ffb4869b613a505e9bd67230d85e2c05f97315 /libjava | |
parent | 8635bb79f219f8d11e47b8403e54c5111712176b (diff) | |
download | gcc-dee45a7f96660c4e19bef6462ff1b2d1932220e4.zip gcc-dee45a7f96660c4e19bef6462ff1b2d1932220e4.tar.gz gcc-dee45a7f96660c4e19bef6462ff1b2d1932220e4.tar.bz2 |
javaprims.h (_Jv_RegisterClassHook): New extern declaration.
* gcj/javaprims.h (_Jv_RegisterClassHook): New extern declaration.
(_Jv_RegisterClassHookDefault): Likewise.
* java/lang/Class.h (_Jv_RegisterClassHookDefault): Declare as friend.
* java/lang/natClassLoader.cc (_Jv_RegisterClassHook): New variable.
(_Jv_RegisterClassHookDefault): New.function.
(_Jv_RegisterClasses): Call _Jv_RegisterClassHook.
From-SVN: r45344
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 7 | ||||
-rw-r--r-- | libjava/gcj/javaprims.h | 2 | ||||
-rw-r--r-- | libjava/java/lang/Class.h | 1 | ||||
-rw-r--r-- | libjava/java/lang/natClassLoader.cc | 20 |
4 files changed, 27 insertions, 3 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 5170b9a..250258a 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,12 @@ 2001-08-31 Per Bothner <per@bothner.com> + * gcj/javaprims.h (_Jv_RegisterClassHook): New extern declaration. + (_Jv_RegisterClassHookDefault): Likewise. + * java/lang/Class.h (_Jv_RegisterClassHookDefault): Declare as friend. + * java/lang/natClassLoader.cc (_Jv_RegisterClassHook): New variable. + (_Jv_RegisterClassHookDefault): New.function. + (_Jv_RegisterClasses): Call _Jv_RegisterClassHook. + * java/lang/ClassLoader.java (system): Remove static field. (getSystemClassLoader): Get gnu.gcj.runtime.VMClassLoader.instance directly instead of using it to set the system field. diff --git a/libjava/gcj/javaprims.h b/libjava/gcj/javaprims.h index 5fb00c8..d48ae17 100644 --- a/libjava/gcj/javaprims.h +++ b/libjava/gcj/javaprims.h @@ -411,6 +411,8 @@ extern "C" void _Jv_Throw (jthrowable) __attribute__ ((__noreturn__)); extern "C" void* _Jv_Malloc (jsize) __attribute__((__malloc__)); extern "C" void* _Jv_Realloc (void *, jsize); extern "C" void _Jv_Free (void*); +extern void (*_Jv_RegisterClassHook) (jclass cl); +extern "C" void _Jv_RegisterClassHookDefault (jclass); typedef unsigned short _Jv_ushort __attribute__((__mode__(__HI__))); typedef unsigned int _Jv_uint __attribute__((__mode__(__SI__))); diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h index dfef0a6..9d106c5 100644 --- a/libjava/java/lang/Class.h +++ b/libjava/java/lang/Class.h @@ -298,6 +298,7 @@ private: friend void _Jv_WaitForState (jclass, int); friend void _Jv_RegisterClasses (jclass *classes); + friend void _Jv_RegisterClassHookDefault (jclass klass); friend void _Jv_RegisterInitiatingLoader (jclass,java::lang::ClassLoader*); friend void _Jv_UnregisterClass (jclass); friend jclass _Jv_FindClass (_Jv_Utf8Const *name, diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc index f0794c7..890a4a7 100644 --- a/libjava/java/lang/natClassLoader.cc +++ b/libjava/java/lang/natClassLoader.cc @@ -439,9 +439,8 @@ _Jv_RegisterClasses (jclass *classes) for (; *classes; ++classes) { jclass klass = *classes; - jint hash = HASH_UTF (klass->name); - klass->next = loaded_classes[hash]; - loaded_classes[hash] = klass; + + (*_Jv_RegisterClassHook) (klass); // registering a compiled class causes // it to be immediately "prepared". @@ -451,6 +450,21 @@ _Jv_RegisterClasses (jclass *classes) } void +_Jv_RegisterClassHookDefault (jclass klass) +{ + jint hash = HASH_UTF (klass->name); + klass->next = loaded_classes[hash]; + loaded_classes[hash] = klass; +} + +// A pointer to a function that actually registers a class. +// Normally _Jv_RegisterClassHookDefault, but could be some other function +// that registers the class in e.g. a ClassLoader-local table. +// Should synchronize on Class:class$ while setting/restore this variable. + +void (*_Jv_RegisterClassHook) (jclass cl) = _Jv_RegisterClassHookDefault; + +void _Jv_RegisterClass (jclass klass) { jclass classes[2]; |