--- a/src/JavaContext.st Wed Nov 09 16:17:19 2011 +0000
+++ b/src/JavaContext.st Wed Nov 09 16:39:15 2011 +0000
@@ -364,10 +364,11 @@
!
acquiredMonitorsDo: aBlock
- acqrMonitors isNil ifTrue: [ acqrMonitors := Stack new ].
+ acqrMonitors isNil ifTrue: [ ^self ].
acqrMonitors copy reverseDo: aBlock.
"Created: / 08-11-2011 / 15:03:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 08-11-2011 / 21:46:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
addMonitor: mon
@@ -435,43 +436,45 @@
!JavaContext methodsFor:'non local control flow'!
unwindAndRestartForJavaException
+
"Called by JavaVM>>throwException: unwinds the stack
up to this context and restarts it so an exception handler
executes"
-
- | con wasMarked |
- self breakPoint:#mh.
+
+ | con wasMarked |
+
"Each context that has a monitor acquired has
and unwind action that release all monitors acquired.
However, we DONT want my monitors to be released,
so we temporarily unmark this context for unwind and
then mark it again, eventually"
+
wasMarked := self isUnwindContext.
- wasMarked ifTrue: [ self unmarkForUnwind ].
- self senderIsNil ifFalse: [
- con := thisContext evaluateUnwindActionsUpTo: self.
+ wasMarked ifTrue:[self unmarkForUnwind].
+ self senderIsNil ifFalse:[
+ con := thisContext evaluateUnwindActionsUpTo:self.
].
- wasMarked ifTrue: [ self markForUnwind ].
- "oops, if nil, I am not on the calling chain;
+ wasMarked ifTrue:[self markForUnwind].
+
+ "oops, if nil, I am not on the calling chain;
(bad bad, unwind action have already been performed.
- should we check for this situation first and NOT evaluate
- the unwind actions in this case ?)
+ should we check for this situation first and NOT evaluate
+ the unwind actions in this case ?)
"
- con isNil ifTrue: [
+ con isNil ifTrue:[
"
tried to return to a context which is already dead
- (i.e. the method/block has already executed a return)"
- ^ self invalidReturnOrRestartError: #unwindAndRestart: with: nil
+ (i.e. the method/block has already executed a return)
+ "
+ ^ self invalidReturnOrRestartError:#'unwindAndRestart:' with:nil
].
- "
+ "
now, that all unwind-actions are done, I can use the
low-level restart ...
"
- self breakPoint: #mh.
^ self restart
"Created: / 08-11-2011 / 22:00:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 09-11-2011 / 16:56:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaContext methodsFor:'printing & storing'!