src/JavaVM.st
branchjk_new_structure
changeset 1248 a9583765fa58
parent 1247 59574ba88702
child 1249 3c82fe50483c
--- a/src/JavaVM.st	Thu Dec 08 20:27:02 2011 +0000
+++ b/src/JavaVM.st	Fri Dec 09 10:14:53 2011 +0000
@@ -3777,6 +3777,19 @@
     "Modified: / 13-08-2011 / 01:10:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+throwNullPointerException:message
+    NullPointerExceptionDebug == true ifTrue: [
+        self halt: 'Null Pointer exception'.
+    ].
+    ^ self throwExceptionClassName: 'java.lang.NullPointerException'
+        withMessage: message
+
+    "Created: / 09-01-1998 / 02:26:08 / cg"
+    "Modified: / 28-01-1998 / 02:30:09 / cg"
+    "Modified: / 13-08-2011 / 01:10:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 09-12-2011 / 11:13:40 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
 throwNumberFormatException 
     ^ self 
 	throwExceptionClassName:'java.lang.NumberFormatException' 
@@ -6834,12 +6847,15 @@
 
 _java_lang_Thread_holdsLock: aJavaContext 
     <javanative: 'java/lang/Thread' name: 'holdsLock'>
-    | obj |
+    | obj  mon  thisProcess |
     obj := aJavaContext argAt: 1.
-    ^ self has: (Processor activeProcess) enteredMonitorFor: obj.
+    obj isNil ifTrue: [self throwNullPointerException:'null given to _java_lang_Thread_holdsLock'].
+    mon := self monitorFor: obj.
+    thisProcess := Processor activeProcess.
+    (mon isOwnedBy: thisProcess) ifTrue: [ ^ 1 ] ifFalse: [ ^ 0 ].
 
     "Created: / 30-04-2011 / 22:06:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 17-11-2011 / 16:29:40 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 09-12-2011 / 11:13:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 _java_lang_Thread_interrupt0: nativeContext