--- a/src/JavaVM.st Wed Nov 16 13:33:38 2011 +0000
+++ b/src/JavaVM.st Wed Nov 16 14:39:06 2011 +0000
@@ -1601,6 +1601,7 @@
WaitTable := IdentityDictionary new.
WaitTableAccess := Semaphore "RecursionLock" forMutualExclusion.
WaitTableAccess name: 'JavaVM wait table access mutex'.
+ Logger log: 'Clearing EnteredMonitorsPerProcess' severity:#info facility:#JVM.
EnteredMonitorsPerProcess := IdentityDictionary new.
self initializePrimitiveClasses.
self initializeOpenFileTable.
@@ -2009,8 +2010,12 @@
WaitTable := IdentityDictionary new.
WaitTableAccess := Semaphore "RecursionLock" forMutualExclusion.
WaitTableAccess name: 'JavaVM wait table access mutex'.
- EnteredMonitorsPerProcess size > 0 ifTrue: [ self breakPoint: #mh ].
+ EnteredMonitorsPerProcess notNil ifTrue: [
+ EnteredMonitorsPerProcess
+ keysAndValuesDo: [:p :value | value size > 0 ifTrue: [ self breakPoint: #mh ] ]
+ ].
self releaseLeftOverMonitors.
+ Logger log: 'Clearing EnteredMonitorsPerProcess' severity:#info facility:#JVM.
EnteredMonitorsPerProcess := IdentityDictionary new.
"
@@ -2019,7 +2024,7 @@
"Created: / 02-01-1998 / 18:04:05 / cg"
"Modified: / 07-01-1998 / 22:58:10 / cg"
"Modified: / 25-10-2010 / 19:14:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 16-11-2011 / 14:26:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 16-11-2011 / 15:02:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
releaseAllStreams
@@ -16034,6 +16039,15 @@
"Created: / 8.1.1999 / 14:02:02 / cg"
!
+enteredMonitorsOfProcessAt: aProcess
+ "does not create empty collection like enteredMonitorsOfProcess"
+
+ ^ EnteredMonitorsPerProcess at: aProcess ifAbsent: nil.
+
+ "Created: / 08-01-1999 / 14:02:02 / cg"
+ "Created: / 16-11-2011 / 15:37:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
monitorEnter: someObject in: aJavaContext
| mon thisProcess objString |
self assert: (aJavaContext isJavaContext).
@@ -16064,7 +16078,7 @@
!
monitorExit: someObject in: aJavaContext
- | mon thisProcess wasBlocked lastMon objString |
+ | mon thisProcess wasBlocked lastMon objString enteredMonitors |
self assert: (aJavaContext isJavaContext).
someObject isNil ifTrue: [
self throwNullPointerException.
@@ -16092,10 +16106,12 @@
severity: #info
facility: #JVM.
].
- lastMon := (self enteredMonitorsOfProcess: thisProcess) removeLast.
+ enteredMonitors := self enteredMonitorsOfProcessAt: thisProcess.
+ enteredMonitors notNil ifTrue: [
+ lastMon := enteredMonitors removeLast.
lastMon ~~ someObject ifTrue: [
self halt: 'oops - monitor enter/exit nesting wrong'
- ].
+ ]] ifFalse: [Logger log: ('Seems that monitors of %1 were already released' bindWith: thisProcess) severity:#info facility:#JVM].
wasBlocked := OperatingSystem blockInterrupts.
"mon count == 0 ifTrue: [ LeftMonitorObject := someObject ]."
wasBlocked ifFalse: [ OperatingSystem unblockInterrupts ]
@@ -16167,6 +16183,7 @@
(such an exception in native method)"
| monitors |
+ self breakPoint:#mh.
monitors := EnteredMonitorsPerProcess at: aProcess ifAbsent: nil.
monitors notNil ifTrue: [
monitors do: [
@@ -16184,12 +16201,11 @@
].
].
].
- EnteredMonitorsPerProcess removeKey: aProcess
- .
+ EnteredMonitorsPerProcess removeKey: aProcess.
].
"Created: / 04-11-2011 / 22:15:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 08-11-2011 / 15:07:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 16-11-2011 / 15:09:14 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
releaseSemaphoreFor:someObject