--- a/src/JavaVM.st Wed Nov 16 09:00:13 2011 +0000
+++ b/src/JavaVM.st Wed Nov 16 13:29:09 2011 +0000
@@ -1326,6 +1326,7 @@
deinitialize
StandardThreadGroup := nil.
+
KnownWindows notNil ifTrue: [
KnownWindows do: [:v | v isTopView ifTrue: [ v destroy ] ]
].
@@ -1341,7 +1342,7 @@
"Created: / 03-01-1998 / 21:28:14 / cg"
"Modified: / 03-12-1998 / 20:33:21 / cg"
"Modified: / 28-01-2011 / 14:11:35 / Marcel Hlopko <hlopik@gmail.com>"
- "Modified: / 02-11-2011 / 22:07:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 16-11-2011 / 09:46:49 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
deinitializeAdditionalJavaProtocol
@@ -1593,6 +1594,26 @@
"Modified: / 23.12.1999 / 19:27:42 / cg"
!
+initializeJavaResources
+ LockTable := WeakIdentityDictionary new.
+ LockTableAccess := Semaphore "RecursionLock" forMutualExclusion.
+ LockTableAccess name: 'JavaVM lock table access mutex'.
+ WaitTable := IdentityDictionary new.
+ WaitTableAccess := Semaphore "RecursionLock" forMutualExclusion.
+ WaitTableAccess name: 'JavaVM wait table access mutex'.
+ EnteredMonitorsPerProcess := IdentityDictionary new.
+ self initializePrimitiveClasses.
+ self initializeOpenFileTable.
+
+ "
+ JavaVM releaseAllMonitors"
+
+ "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>"
+ "Created: / 16-11-2011 / 14:23:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
initializeOpenFileTable
OpenFileTable := OrderedCollection
with:Stdin
@@ -1823,7 +1844,7 @@
JavaContext autoload.
MonitorTrace ifNil: [ self initialize ].
self initializeAdditionalJavaProtocol.
- self releaseAllJavaResources.
+ self initializeJavaResources.
JavaConsoleStream := Transcript.
Java initAllStaticFields.
Java markAllClassesUninitialized.
@@ -1876,7 +1897,7 @@
"Modified: / 14-12-1999 / 18:58:56 / cg"
"Modified: / 15-10-2010 / 15:27:45 / Jan Kurs <kurs.jan@post.cz>"
"Modified: / 01-11-2011 / 22:16:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 03-11-2011 / 19:17:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 16-11-2011 / 14:27:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
initializeVMIfNoEventThreadRunning
@@ -1967,8 +1988,7 @@
self initializePrimitiveClasses.
self terminateAllThreads.
-
- self releaseAllMonitors.
+self releaseAllMonitors.
self releaseAllWindows.
self releaseAllStreams.
@@ -1979,25 +1999,27 @@
"Created: / 07-01-1998 / 22:49:42 / cg"
"Modified: / 24-12-1999 / 02:33:11 / cg"
"Modified: / 17-12-2010 / 17:51:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 16-11-2011 / 09:46:55 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
releaseAllMonitors
LockTable := WeakIdentityDictionary new.
- LockTableAccess := Semaphore"RecursionLock" forMutualExclusion.
+ LockTableAccess := Semaphore "RecursionLock" forMutualExclusion.
LockTableAccess name: 'JavaVM lock table access mutex'.
WaitTable := IdentityDictionary new.
- WaitTableAccess := Semaphore"RecursionLock" forMutualExclusion.
+ WaitTableAccess := Semaphore "RecursionLock" forMutualExclusion.
WaitTableAccess name: 'JavaVM wait table access mutex'.
-
+ EnteredMonitorsPerProcess size > 0 ifTrue: [ self breakPoint: #mh ].
+ self releaseLeftOverMonitors.
EnteredMonitorsPerProcess := IdentityDictionary new.
"
- JavaVM releaseAllMonitors
- "
+ JavaVM releaseAllMonitors"
"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>"
!
releaseAllStreams
@@ -2045,30 +2067,33 @@
releaseLeftOverMonitors
"release monitors held by dead processes"
-
- |deadProcesses|
-
+
+ | deadProcesses |
deadProcesses := IdentitySet new.
-
- EnteredMonitorsPerProcess keysAndValuesDo:[:p :monitors |
- p isDead ifTrue:[
- monitors do:[:mon |
- Logger log: 'release leftover monitor ...' severity: #info facility: 'JVM'.
- mon release
- ].
- deadProcesses add:p.
- ]
- ].
- deadProcesses do:[:p |
- EnteredMonitorsPerProcess removeKey:p
- ].
-
- "
- JavaVM releaseLeftOverMonitors
- "
+ EnteredMonitorsPerProcess
+ keysAndValuesDo: [
+ :p :monitors |
+ p isDead ifTrue: [
+ self breakPoint:#mh.
+ monitors do: [
+ :mon |
+ Logger
+ log: 'release leftover monitor ...'
+ severity: #info
+ facility: 'JVM'.
+ mon release
+ ].
+ deadProcesses add: p.
+ ]
+ ].
+ deadProcesses do: [:p | EnteredMonitorsPerProcess removeKey: p ].
+
+ "
+ JavaVM releaseLeftOverMonitors"
"Created: / 08-01-1998 / 17:29:26 / cg"
"Modified: / 14-09-2011 / 22:06:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 16-11-2011 / 14:26:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
systemProperties
@@ -7382,16 +7407,12 @@
FileIOTrace ifTrue:[
('JAVA: socket bind to ' , hostName printString, ' port ' , port printString) infoPrintCR
].
- [
- ok := sock bindTo:port address:nil "hostName".
- ] on: Error do:[:ex|
- self throwIOExceptionWithMessage:'bind failed: ' , ex description.
- ^nil.
- ].
+
+ ok := sock bindTo:port address:nil "hostName".
ok ifFalse:[
err := OperatingSystem lastErrorString.
- self throwIOExceptionWithMessage:'bind failed: ', (err ? 'unknown error') asString.
- ^nil
+ Transcript showCR:'sock err: ' , err printString.
+ self throwIOExceptionWithMessage:'bind failed'.
].
jsock instVarNamed: #localport put: sock port.
jsock instVarNamed: #address put: jaddr.
@@ -7399,7 +7420,7 @@
"Created: / 04-02-1998 / 15:06:20 / cg"
"Modified: / 30-12-1998 / 20:10:16 / cg"
- "Modified: / 16-11-2011 / 00:09:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 15-11-2011 / 00:44:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_net_PlainSocketImpl_socketClose0: nativeContext
@@ -7744,14 +7765,14 @@
].
[
- nread := sock readInto: data startingAt: off + 1 count: len.
+ nread := sock readInto: data startingAt: off count: len.
] on: Error do:[:ex|
self throwSocketException: 'Error when reading: ', ex description.
].
^nread
- "Modified: / 15-11-2011 / 23:25:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 13-11-2011 / 23:49:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_net_SocketOutputStream_init: nativeContext
@@ -7782,12 +7803,12 @@
sock := self validateFile: fdObj.
[
- sock nextPutBytes: len from: data startingAt: off + 1.
+ sock nextPutBytes: len from: data startingAt: off.
] on: Error do:[:ex|
self throwIOExceptionWithMessage: 'Error when writing: ', ex description.
].
- "Modified: / 16-11-2011 / 00:03:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 13-11-2011 / 23:53:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaVM class methodsFor:'native - java.security'!
@@ -16196,7 +16217,6 @@
syncMonitorCache
| mO mC mP mon wasBlocked enteredMonitors |
- self breakPoint:#mh.
wasBlocked := OperatingSystem blockInterrupts.
(mO := EnteredMonitorObject) notNil ifTrue: [
mC := EnteredMonitorObjectCount.
@@ -16211,7 +16231,7 @@
"Created: / 08-01-1999 / 13:59:17 / cg"
"Modified: / 09-01-1999 / 00:39:55 / cg"
- "Modified: / 09-11-2011 / 14:21:14 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 16-11-2011 / 09:37:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
unwindHandlerForJavaContext: aJavaContext