interrupt test passes jk_new_structure
authorhlopkmar
Wed, 30 Nov 2011 11:21:29 +0000
branchjk_new_structure
changeset 1188 1460e12fc954
parent 1187 6f46a5bd8da1
child 1189 51abd77770ff
interrupt test passes
src/JavaVM.st
src/extensions.st
--- a/src/JavaVM.st	Wed Nov 30 11:10:18 2011 +0000
+++ b/src/JavaVM.st	Wed Nov 30 11:21:29 2011 +0000
@@ -3624,6 +3624,13 @@
     "Created: / 14.1.1998 / 23:17:02 / cg"
 !
 
+throwInterruptedException: message 
+    ^ self throwExceptionClassName: 'java.lang.InterruptedException'
+        withMessage:message
+
+    "Created: / 30-11-2011 / 12:23:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
 throwLinkageError: message
     ^ self 
         throwExceptionClassName:'java.lang.LinkageError' 
@@ -6686,18 +6693,15 @@
 
 _java_lang_Thread_interrupt0: nativeContext 
     <javanative: 'java/lang/Thread' name: 'interrupt0()V'>
-    "ask if a thread is interrupted (clear interruptState if arg is true)"
-    
     | jThread  stProcess |
     jThread := nativeContext receiver.
     stProcess := self stProcessForJavaThread: jThread.
     self assert: stProcess notNil.
-
     stProcess setInterrupted.
 
     "Modified: / 02-01-1998 / 21:49:06 / cg"
     "Created: / 10-04-1998 / 15:21:43 / cg"
-    "Modified: / 30-11-2011 / 11:03:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 30-11-2011 / 12:22:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 _java_lang_Thread_isAlive: nativeContext
@@ -6735,12 +6739,12 @@
     wasInterrupted := stProcess isInterrupted.
     clearInterrupt ~~ 0 ifTrue: [ stProcess clearInterrupted ].
     stProcess isDead ifTrue: [ ^ 0 ].
-    ^ wasInterrupted.
+    wasInterrupted ifTrue: [ ^ 1 ] ifFalse: [ ^ 0 ].
 
     "Modified: / 02-01-1998 / 21:49:06 / cg"
     "Created: / 07-01-1998 / 18:50:26 / cg"
     "Modified: / 05-08-2011 / 22:21:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 30-11-2011 / 10:49:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 30-11-2011 / 12:22:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 _java_lang_Thread_registerNatives: aJavaContext
--- a/src/extensions.st	Wed Nov 30 11:10:18 2011 +0000
+++ b/src/extensions.st	Wed Nov 30 11:21:29 2011 +0000
@@ -217,7 +217,9 @@
 !Process methodsFor:'Java protocol'!
 
 isInterrupted
-    ^JavaVM threadInterrupts at: self ifAbsent: [ JavaVM threadInterrupts at: self put: false.]
+
+    ^ JavaVM threadInterrupts at: self
+        ifAbsent: [ JavaVM threadInterrupts at: self put: false. ]
 
     "Created: / 30-11-2011 / 12:12:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
@@ -233,7 +235,8 @@
 !Process methodsFor:'Java protocol'!
 
 setInterrupted
- JavaVM threadInterrupts at: self put: true.
+
+    JavaVM threadInterrupts at: self put: true.
 
     "Created: / 30-11-2011 / 10:44:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !