Patch: Remove Thread.stop

Tom Tromey tromey@cygnus.com
Thu Nov 4 08:40:00 GMT 1999


Thread.stop is deprecated just like Thread.suspend and Thread.resume.
Plus, the current implementation for POSIX threads is just broken.
Instead of spending a lot of time fixing it, I've decided to simply
make it officially unsupported.  This patch implements that.

1999-11-04  Tom Tromey  <tromey@cygnus.com>

	* include/quick-threads.h (_Jv_ThreadCancel): Removed.
	(_Jv_ThreadDestroy): Likewise.
	* include/no-threads.h (_Jv_ThreadCancel): Removed.
	(_Jv_ThreadDestroy): Likewise.
	* include/posix-threads.h (struct _Jv_Thread_t): Removed
	`exception' field.
	(_Jv_ThreadCancel): Removed decl.
	(_Jv_ThreadDestroy): Removed.
	* posix-threads.cc (_Jv_ThreadCancel): Removed.
	(throw_cleanup): Removed.
	(really_start): Don't push or pop cleanup.
	(_Jv_ThreadInitData): Don't initialize `exception' field.
	* java/lang/Thread.java (stop): Officially unimplemented.
	* java/lang/natThread.cc (stop): Officially unimplemented.

Tom

Index: posix-threads.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/posix-threads.cc,v
retrieving revision 1.12
diff -u -r1.12 posix-threads.cc
--- posix-threads.cc	1999/11/03 03:10:22	1.12
+++ posix-threads.cc	1999/11/04 16:36:11
@@ -284,7 +284,6 @@
   _Jv_Thread_t *info = new _Jv_Thread_t;
 
   info->flags = 0;
-  info->exception = NULL;
 
   // FIXME register a finalizer for INFO here.
   // FIXME also must mark INFO somehow.
@@ -304,26 +303,6 @@
     }
 }
 
-
-// This is called as a cleanup handler when a thread is exiting.  We
-// use it to throw the requested exception.  It's entirely possible
-// that this approach is doomed to failure, in which case we'll need
-// to adopt some alternate.  For instance, use a signal to implement
-// _Jv_ThreadCancel.
-static void
-throw_cleanup (void *data)
-{
-  _Jv_Thread_t *td = (_Jv_Thread_t *) data;
-  _Jv_Throw ((java::lang::Throwable *) td->exception);
-}
-
-void
-_Jv_ThreadCancel (_Jv_Thread_t *data, void *error)
-{
-  data->exception = error;
-  pthread_cancel (data->thread);
-}
-
 // This function is called when a thread is started.  We don't arrange
 // to call the `run' method directly, because this function must
 // return a value.
@@ -332,11 +311,9 @@
 {
   struct starter *info = (struct starter *) x;
 
-  pthread_cleanup_push (throw_cleanup, info->data);
   pthread_setspecific (_Jv_ThreadKey, info->object);
   pthread_setspecific (_Jv_ThreadDataKey, info->data);
   info->method (info->object);
-  pthread_cleanup_pop (0);
 
   if (! (info->data->flags & FLAG_DAEMON))
     {
Index: include/no-threads.h
===================================================================
RCS file: /cvs/java/libgcj/libjava/include/no-threads.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 no-threads.h
--- no-threads.h	1999/04/07 14:52:35	1.1.1.1
+++ no-threads.h	1999/11/04 16:36:13
@@ -125,19 +125,6 @@
 {
 }
 
-inline void
-_Jv_ThreadCancel (_Jv_Thread_t *, void *)
-{
-  JvFail ("_Jv_ThreadCancel");
-}
-
-// Like Cancel, but doesn't run cleanups.
-inline void
-_Jv_ThreadDestroy (_Jv_Thread_t *)
-{
-  JvFail ("_Jv_ThreadDestroy");
-}
-
 void _Jv_ThreadStart (java::lang::Thread *, _Jv_Thread_t *,
 		      _Jv_ThreadStartFunc *meth);
 
Index: include/posix-threads.h
===================================================================
RCS file: /cvs/java/libgcj/libjava/include/posix-threads.h,v
retrieving revision 1.8
diff -u -r1.8 posix-threads.h
--- posix-threads.h	1999/09/21 23:01:23	1.8
+++ posix-threads.h	1999/11/04 16:36:19
@@ -76,9 +76,6 @@
 
   // Actual thread id.
   pthread_t thread;
-
-  // Exception we want to throw when cancelled.
-  void *exception;
 } _Jv_Thread_t;
 typedef void _Jv_ThreadStartFunc (java::lang::Thread *);
 
@@ -267,15 +264,6 @@
 }
 
 void _Jv_ThreadSetPriority (_Jv_Thread_t *data, jint prio);
-
-void _Jv_ThreadCancel (_Jv_Thread_t *data, void *error);
-
-// Like Cancel, but doesn't run cleanups.
-inline void
-_Jv_ThreadDestroy (_Jv_Thread_t *)
-{
-  JvFail ("_Jv_ThreadDestroy");
-}
 
 void _Jv_ThreadStart (java::lang::Thread *thread, _Jv_Thread_t *data,
 		      _Jv_ThreadStartFunc *meth);
Index: include/quick-threads.h
===================================================================
RCS file: /cvs/java/libgcj/libjava/include/quick-threads.h,v
retrieving revision 1.2
diff -u -r1.2 quick-threads.h
--- quick-threads.h	1999/08/18 03:48:37	1.2
+++ quick-threads.h	1999/11/04 16:36:19
@@ -113,19 +113,6 @@
 {
 }
 
-inline void
-_Jv_ThreadCancel (_Jv_Thread_t *data, void *error)
-{
-  coop_terminate (*data, error);
-}
-
-// Like Cancel, but doesn't run cleanups.
-inline void
-_Jv_ThreadDestroy (_Jv_Thread_t *data)
-{
-  coop_terminate (*data, 0);
-}
-
 void _Jv_ThreadStart (java::lang::Thread *thread, _Jv_Thread_t *data,
 		      _Jv_ThreadStartFunc *meth);
 
Index: java/lang/Thread.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/Thread.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Thread.java
--- Thread.java	1999/04/07 14:52:38	1.1.1.1
+++ Thread.java	1999/11/04 16:36:19
@@ -181,7 +181,9 @@
 
   public final void stop ()
   {
-    stop (new ThreadDeath ());
+    // Argument doesn't matter, because this is no longer
+    // supported.
+    stop (null);
   }
 
   public final synchronized native void stop (Throwable e);
Index: java/lang/natThread.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/natThread.cc,v
retrieving revision 1.5
diff -u -r1.5 natThread.cc
--- natThread.cc	1999/09/10 22:03:08	1.5
+++ natThread.cc	1999/11/04 16:36:21
@@ -304,12 +304,7 @@
 void
 java::lang::Thread::stop (java::lang::Throwable *e)
 {
-  JvSynchronize sync (this);
-  checkAccess ();
-  if (! e)
-    _Jv_Throw (new NullPointerException);
-  natThread *nt = (natThread *) data;
-  _Jv_ThreadCancel (nt->thread, e);
+  JvFail ("java::lang::Thread::stop unimplemented");
 }
 
 void


More information about the Java-patches mailing list