This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
Patch: Class initialization fix
- To: java-patches@sourceware.cygnus.com
- Subject: Patch: Class initialization fix
- From: Matt Welsh <mdw@cs.berkeley.edu>
- Date: Wed, 01 Sep 1999 20:15:00 -0700
- Reply-To: Matt Welsh <mdw@cs.berkeley.edu>
The enclosed patch fixes problems when multiple threads are blocked
waiting for a class initialization to be done by another thread;
notify() has been changed to notifyWait(). There may be other class
state transitions which require a patch of this sort.
1999-09-01 Matt Welsh <mdw@cs.berkeley.edu>
* java/lang/natClass.cc: Fixed notification of threads
when class initialization is complete.
Index: natClass.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/natClass.cc,v
retrieving revision 1.4
diff -c -3 -p -r1.4 natClass.cc
*** natClass.cc 1999/08/18 14:16:41 1.4
--- natClass.cc 1999/09/02 03:08:27
*************** java::lang::Class::initializeClass (void
*** 421,427 ****
java::lang::Thread *self = java::lang::Thread::currentThread();
// FIXME: `self' can be null at startup. Hence this nasty trick.
self = (java::lang::Thread *) ((long) self | 1);
! while (state == JV_STATE_IN_PROGRESS && thread && thread != self)
wait ();
// Steps 3 & 4.
--- 421,427 ----
java::lang::Thread *self = java::lang::Thread::currentThread();
// FIXME: `self' can be null at startup. Hence this nasty trick.
self = (java::lang::Thread *) ((long) self | 1);
! while (state == JV_STATE_IN_PROGRESS && thread && thread != self)
wait ();
// Steps 3 & 4.
*************** java::lang::Class::initializeClass (void
*** 455,461 ****
// Caught an exception.
_Jv_MonitorEnter (this);
state = JV_STATE_ERROR;
! notify ();
_Jv_MonitorExit (this);
JvThrow (except);
}
--- 455,461 ----
// Caught an exception.
_Jv_MonitorEnter (this);
state = JV_STATE_ERROR;
! notifyAll ();
_Jv_MonitorExit (this);
JvThrow (except);
}
*************** java::lang::Class::initializeClass (void
*** 482,488 ****
_Jv_MonitorEnter (this);
state = JV_STATE_ERROR;
}
! notify ();
_Jv_MonitorExit (this);
if (except)
JvThrow (except);
--- 482,488 ----
_Jv_MonitorEnter (this);
state = JV_STATE_ERROR;
}
! notifyAll ();
_Jv_MonitorExit (this);
if (except)
JvThrow (except);