[kaffe] Dummy holdsLock() in java.lang.Thread
jserv@linux2.cc.ntu.edu.tw
jserv@linux2.cc.ntu.edu.tw
Thu May 27 00:03:02 2004
--ZGiS0Q5IWpPtfppv
Content-Type: text/plain; charset=big5
Content-Disposition: inline
Hi all,
While getting GCJ's java-gui-branch working with Kaffe, I found
its Swing implementation needs holdsLock() in java.lang.Thread,
which is first introduced in JDK 1.4. However, I have no idea how
to query the theads locking state in Kaffe, so that I wrote a
dummy implementation.
Also, I'd like to acquire the way to implement similar functionality
as _Jv_ObjectCheckMonitor in GCJ.
Thanks,
Jim Huang
--ZGiS0Q5IWpPtfppv
Content-Type: text/plain; charset=big5
Content-Disposition: attachment; filename="dummy-holdslock.diff"
diff -u -r1.17 Thread.c
--- libraries/clib/native/Thread.c 21 May 2004 15:19:24 -0000 1.17
+++ libraries/clib/native/Thread.c 27 May 2004 06:39:51 -0000
@@ -78,3 +78,12 @@
{
exitThread();
}
+
+jboolean
+java_lang_Thread_holdsLock(jobject obj)
+{
+ if (!obj)
+ throwException(NullPointerException);
+ return false; /* !_Jv_ObjectCheckMonitor (obj) */
+}
+
diff -u -r1.45 Thread.java
--- libraries/javalib/java/lang/Thread.java 22 Mar 2004 11:24:47 -0000 1.45
+++ libraries/javalib/java/lang/Thread.java 27 May 2004 06:39:53 -0000
@@ -205,6 +205,16 @@
return (group);
}
+/**
+ * Return true if this Thread holds the object's lock, false otherwise.
+ *
+ * @param obj the object to test lock ownership on.
+ * @return true if the current thread is currently synchronized on obj
+ * @throws NullPointerException if obj is null.
+ * @since 1.4
+ */
+public static native boolean holdsLock(Object obj);
+
/*
* This method is used by java.lang.ThreadLocal. We don't
* allocate the hashtable with each thread until we have to.
--ZGiS0Q5IWpPtfppv--