This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
Patch: Threads and RawData
- To: java-patches at sourceware dot cygnus dot com
- Subject: Patch: Threads and RawData
- From: Bryce McKinlay <bryce at albatross dot co dot nz>
- Date: Thu, 18 May 2000 22:19:34 +1200
RawData fields are fields that don't get marked by the garbage
collector. In java.lang.Thread, the "data" field is used to store a
native struct containing native thread fields. However, we allocate
"data" through the collector! That means crashes in threaded programs.
This patch changes "data" to Object, and changes the documentation for
RawData to better reflect what it actually does.
I have checked this in.
regards
[ bryce ]
2000-05-18 Bryce McKinlay <bryce@albatross.co.nz>
* java/lang/Thread.java: Declare `data' as Object, not RawData.
* java/lang/natThread.java (initialize_native): Cast `data' to
jobject.
* gnu/gcj/RawData.java: Clarify documentation.
Index: java/lang/natThread.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/natThread.cc,v
retrieving revision 1.17
diff -u -r1.17 natThread.cc
--- natThread.cc 2000/04/02 15:34:17 1.17
+++ natThread.cc 2000/05/18 10:02:28
@@ -23,7 +23,6 @@
#include <java/lang/IllegalThreadStateException.h>
#include <java/lang/InterruptedException.h>
#include <java/lang/NullPointerException.h>
-#include <gnu/gcj/RawData.h>
#include <jni.h>
@@ -62,7 +61,7 @@
// own finalizer then we will need to reinitialize this structure at
// any "interesting" point.
natThread *nt = (natThread *) _Jv_AllocBytes (sizeof (natThread));
- data = reinterpret_cast<gnu::gcj::RawData *> (nt);
+ data = reinterpret_cast<jobject> (nt);
_Jv_MutexInit (&nt->join_mutex);
_Jv_CondInit (&nt->join_cond);
_Jv_ThreadInitData (&nt->thread, this);
Index: java/lang/Thread.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/Thread.java,v
retrieving revision 1.9
diff -u -r1.9 Thread.java
--- Thread.java 2000/03/28 02:22:24 1.9
+++ Thread.java 2000/05/18 10:02:36
@@ -10,8 +10,6 @@
package java.lang;
-import gnu.gcj.RawData;
-
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date August 24, 1998
@@ -292,7 +290,7 @@
private boolean startable_flag;
// Our native data.
- private RawData data;
+ private Object data;
// Next thread number to assign.
private static int nextThreadNumber = 0;
Index: gnu/gcj/RawData.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/gnu/gcj/RawData.java,v
retrieving revision 1.4
diff -u -r1.4 RawData.java
--- RawData.java 2000/03/07 19:55:24 1.4
+++ RawData.java 2000/05/18 10:02:36
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999 Free Software Foundation
+/* Copyright (C) 1999, 2000 Free Software Foundation
This file is part of libgcj.
@@ -8,7 +8,8 @@
package gnu.gcj;
-/** A type uses to indicate pointers to non-Java data. */
+/** A type used to indicate special data used by native code that should not
+ be marked by the garbage collector. */
public final class RawData
{