--- a/src/JavaVM.st Fri Aug 17 01:15:59 2012 +0000
+++ b/src/JavaVM.st Fri Aug 17 17:10:45 2012 +0000
@@ -51,7 +51,7 @@
ClassRegistry SystemClassLoader ExtClassLoader StartupTime
FinalizationEnabled FinalizationLobby ParkUnparkSemaphores
ThreadInterrupts EagerResolvingEnabled OldspaceIncreased
- PerfCounters'
+ PerfCounters AboutToSnapshotAction SnapshotFinishedAction'
poolDictionaries:'JavaConstants'
category:'Languages-Java-Support'
!
@@ -1409,6 +1409,9 @@
FinalizationEnabled := true.
EagerResolvingEnabled := false.
+ ObjectMemory addDependent: self.
+
+
"
JavaVM initialize"
@@ -1416,7 +1419,7 @@
"Modified: / 02-12-1998 / 23:02:22 / cg"
"Modified: / 09-10-2011 / 20:29:10 / Marcel Hlopko <hlopik@gmail.com>"
"Modified: / 08-12-2011 / 21:06:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 30-07-2012 / 23:05:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 17-08-2012 / 11:16:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
initializeAdditionalJavaProtocol
@@ -1569,6 +1572,20 @@
!
initializeJavaResources
+ self initializeMonitorTable.
+ self initializePrimitiveClasses.
+ self initializeOpenFileTable.
+
+ "
+ JavaVM releaseAllMonitors"
+
+ "Created: / 02-01-1998 / 18:04:05 / cg"
+ "Modified: / 07-01-1998 / 22:58:10 / cg"
+ "Created: / 16-11-2011 / 14:23:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 17-08-2012 / 11:30:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+initializeMonitorTable
LockTable := WeakIdentityDictionary new:32000.
LockTableAccess := Semaphore "RecursionLock" forMutualExclusion.
LockTableAccess name: 'JavaVM lock table access mutex'.
@@ -1578,20 +1595,15 @@
facility: #JVM.
EnteredMonitorsPerProcess := IdentityDictionary new.
Logger
- log: 'Initializing AcquiredMonitorsPerProcess'
- severity: #debug
- facility: #JVM.
- AcquiredMonitorsPerProcess := IdentityDictionary new.
- self initializePrimitiveClasses.
- self initializeOpenFileTable.
-
- "
- JavaVM releaseAllMonitors"
-
- "Created: / 02-01-1998 / 18:04:05 / cg"
- "Modified: / 07-01-1998 / 22:58:10 / cg"
- "Created: / 16-11-2011 / 14:23:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 13-04-2012 / 00:34:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ log: 'Initializing AcquiredMonitorsPerProcess'
+ severity: #debug
+ facility: #JVM.
+ AcquiredMonitorsPerProcess := IdentityDictionary new.
+
+ "
+ JavaVM initializeMonitorTable"
+
+ "Created: / 17-08-2012 / 11:30:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
initializeOpenFileTable
@@ -1884,7 +1896,7 @@
ClassLoaderQuerySignal := Query new.
JavaObject autoload.
JavaContext autoload.
- MonitorTrace ifNil: [ self initialize ].
+ MonitorTrace isNil ifTrue: [ self initialize ].
MonitorTraceId := 0.
self initializeAdditionalJavaProtocol.
self initializeJavaResources.
@@ -1947,7 +1959,7 @@
"Modified: / 15-10-2010 / 15:27:45 / Jan Kurs <kurs.jan@post.cz>"
"Modified: / 24-02-2012 / 13:59:29 / Marcel Hlopko <hlopik@gmail.com>"
"Modified: / 24-02-2012 / 14:37:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 16-08-2012 / 21:58:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 17-08-2012 / 11:28:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
initializeVMIfNoEventThreadRunning
@@ -1985,6 +1997,15 @@
"Created: / 21-02-2012 / 18:10:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+reinitializeSockets
+ "Reopens all server-sockets (i.e., listening sockets bound to a port).
+ Called upon restarting from image"
+
+ OpenFileTable do:[:each|each isSocket ifTrue:[each reOpenIfPossible]]
+
+ "Created: / 17-08-2012 / 15:33:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
reinitializeVM
|classesToInit|
@@ -2174,17 +2195,36 @@
"Modified: / 3.1.1998 / 14:32:38 / cg"
!
-update:something with:aParameter from:changedObject
- something == #returnFromSnapshot ifTrue:[
-"/ self initializeVM
- ].
-
+update:what with:aParameter from:changedObject
+
+ "
+ #earlyRestart is send first, nothing has been setup yet.
+ (should be used to flush all device dependent entries)
+ "
+ what == #earlyRestart ifTrue:[
+ self initializeMonitorTable.
+
+ ^self.
+ ].
+
+ "#returnFromSnapshot is sent last (should be used to restart processes, reOpen
+ Streams which cannot be automatically be reopened (i.e. Sockets, Pipes) and so on.
+ (Notice that positionable fileStreams are already reopened and repositioned)
+ "
+ what == #returnFromSnapshot ifTrue:[
+ self reinitializeSockets.
+
+ ^self
+ ].
"
JavaVM initializeVM
"
- "Created: / 9.1.1998 / 10:30:13 / cg"
- "Modified: / 6.11.1998 / 00:40:53 / cg"
+ ObjectMemory dependents
+
+ "Created: / 09-01-1998 / 10:30:13 / cg"
+ "Modified: / 06-11-1998 / 00:40:53 / cg"
+ "Modified: / 17-08-2012 / 15:35:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaVM class methodsFor:'Signal constants'!
@@ -9322,21 +9362,22 @@
sock := self validateFile:jSock.
sock notNil ifTrue:[
- FileIOTrace ifTrue:[
- ('JAVA: socket listen with timeout ' , time printString) infoPrintCR.
- ].
- ok := sock listenWithBacklog:5.
- ok ifFalse:[
- self throwIOExceptionWithMessage:'listen failed'.
- ^ self.
- ].
- time ~~ 0 ifTrue:[
- sock readWaitWithTimeoutMs:time
- ]
- ].
-
- "Created: / 4.2.1998 / 15:17:48 / cg"
- "Modified: / 30.12.1998 / 20:10:46 / cg"
+ FileIOTrace ifTrue:[
+ ('JAVA: socket listen with timeout ' , time printString) infoPrintCR.
+ ].
+ ok := sock listenFor:5.
+ ok ifFalse:[
+ self throwIOExceptionWithMessage:'listen failed'.
+ ^ self.
+ ].
+ time ~~ 0 ifTrue:[
+ sock readWaitWithTimeoutMs:time
+ ]
+ ].
+
+ "Created: / 04-02-1998 / 15:17:48 / cg"
+ "Modified: / 30-12-1998 / 20:10:46 / cg"
+ "Modified: / 17-08-2012 / 15:27:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_net_PlainSocketImpl_socketSetOption: nativeContext