"
COPYRIGHT (c) 1996-2011 by Claus Gittinger
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
SWING Research Group, Czech Technical University in Prague (*)
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
(*) extensions, changes and fixes for java1.1 compatibility.
For a list of changes, see a list of diffs against the last stable version before 2011-08.
"
"{ Package: 'stx:libjava' }"
Process subclass:#JavaProcess
instanceVariableNames:'suspendedContext'
classVariableNames:''
poolDictionaries:''
category:'Languages-Java-Classes'
!
Object subclass:#Helper
instanceVariableNames:'javaThreadObject javaProcess'
classVariableNames:''
poolDictionaries:''
privateIn:JavaProcess
!
!JavaProcess class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1996-2011 by Claus Gittinger
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
SWING Research Group, Czech Technical University in Prague (*)
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
(*) extensions, changes and fixes for java1.1 compatibility.
For a list of changes, see a list of diffs against the last stable version before 2011-08.
"
! !
!JavaProcess class methodsFor:'instance creation'!
newHelper
^Helper new
"Created: / 15-12-2010 / 11:11:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaProcess methodsFor:'accessing'!
suspendedContext
|con|
"/ suspendedContext notNil ifTrue:[^ suspendedContext].
"/ state ~~ #debug ifTrue:[
"/ "/ hide non-JAVA contexts ...
"/ con := super suspendedContext.
"/ [con notNil] whileTrue:[
"/ (con isMemberOf:JavaContext) ifTrue:[^ con].
"/ con := con sender.
"/ ].
"/ ].
^ super suspendedContext
"Created: / 7.5.1996 / 09:02:03 / cg"
"Modified: / 4.2.1998 / 20:44:31 / cg"
!
suspendedContext:aContext
suspendedContext := aContext
"Created: 7.5.1996 / 09:02:12 / cg"
! !
!JavaProcess methodsFor:'interrupts'!
clearInterruptActions
interruptActions := nil
"Created: 14.8.1997 / 17:27:22 / cg"
!
isInterrupted
^ interruptActions notNil
"Created: 14.8.1997 / 17:26:40 / cg"
!
markInterrupted
super interruptWith:[]
"Modified: / 10.4.1998 / 15:20:58 / cg"
"Created: / 10.4.1998 / 15:21:15 / cg"
! !
!JavaProcess methodsFor:'suspend & resume'!
terminateNoSignal
| jThread |
jThread := Java threads keyAtValue: self.
JavaVM wakeup: jThread.
super terminateNoSignal
"Created: / 15-12-2010 / 00:18:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 15-12-2010 / 11:19:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaProcess::Helper methodsFor:'initialization'!
javaProcess:something
javaProcess := something.
!
javaThreadObject:something
javaThreadObject := something.
! !
!JavaProcess::Helper methodsFor:'support'!
value
|procName|
Object abortSignal
handle:[:ex |
procName := javaProcess name.
(procName startsWith:'JAVA-AWT-EventQueue') ifTrue:[
('JAVA [info]: thread ' , procName , ' aborted - restarting process.')
infoPrintCR.
ex restart.
] ifFalse:[
(javaProcess == (Smalltalk at:#'JavaVM:JavaScreenUpdaterThread')
or:[javaProcess == (Smalltalk at:#'JavaVM:JavaEventQueueThread')])
ifTrue:[
('JAVA [info]: thread ' , procName , ' aborted - restarting process.')
infoPrintCR.
ex restart
]
ifFalse:[('JAVA [info]: thread ' , procName , ' aborted.') infoPrintCR.]
].
]
do:[
[
JavaVM javaExceptionSignal
handle:[:ex |
|exClass|
procName := javaProcess name.
exClass := ex parameter class.
exClass == (Java at:'java.lang.ThreadDeath') ifTrue:[
('JAVA: thread ' , procName , ' terminated') infoPrintCR.
] ifFalse:[
Transcript
showCR:('JAVA: thread ''' , procName , ''' terminated with exception: '
, exClass name).
].
ex return.
]
do:[
Object messageNotUnderstoodSignal
handle:[:ex |
|
"/ remap doesNotUnderstand with nil-receiver to
"/ a nullPointerException ...
con m|
con := ex suspendedContext.
con receiver isNil ifTrue:[
((m := con sender method) notNil and:[m isJavaMethod]) ifTrue:[
JavaVM throwNullPointerException.
AbortSignal raise.
"/ ex proceed.
]
].
ex reject.
]
do:[
"/ Transcript showCR:(Timestamp now printString , 'start thread: ', stProcess name).
javaThreadObject perform:#'run()V'.
(Smalltalk at:#'JavaVM:ThreadTrace') == true ifTrue:[
('JAVA: thread ' , javaProcess name , ' terminated') infoPrintCR.
].
javaThreadObject perform:#'exit()V'.
(Smalltalk at:#'JavaVM:ThreadTrace') == true ifTrue:[
('JAVA: after exit of thread ' , javaProcess name) infoPrintCR.
]
]
]
] ensure:[
|monitors|
monitors := (Smalltalk at:#'JavaVM:EnteredMonitorsPerProcess')
at:javaProcess
ifAbsent:nil.
monitors notNil ifTrue:[
monitors do:[:obj |
|mon|
mon := JavaVM monitorFor:obj.
mon notNil ifTrue:[
mon owningProcess == javaProcess ifTrue:[
('JAVA: release monitor owned by dying thread: ' , javaProcess name)
infoPrintCR.
self breakPoint: #jv.
mon exit
].
].
].
(Smalltalk at:#'JavaVM:EnteredMonitorsPerProcess') removeKey:javaProcess.
javaProcess == (Smalltalk at:#'JavaVM:JavaScreenUpdaterThread') ifTrue:[
Smalltalk at:#'JavaVM:JavaScreenUpdaterThread' put:nil.
].
javaProcess == (Smalltalk at:#'JavaVM:JavaEventQueueThread') ifTrue:[
Smalltalk at:#'JavaVM:JavaEventQueueThread' put:nil.
].
"/ screenUpdaterClass := Java at:'sun.awt.ScreenUpdater'.
"/ screenUpdaterClass notNil ifTrue:[
"/ screenUpdaterClass instVarNamed:'updater' put:nil.
"/ ].
].
Java threads removeKey:javaThreadObject ifAbsent:[].
]
]
"Created: / 15-12-2010 / 11:06:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaProcess class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libjava/JavaProcess.st,v 1.16 2011-11-24 11:14:05 cg Exp $'
!
version_CVS
^ '$Header: /cvs/stx/stx/libjava/JavaProcess.st,v 1.16 2011-11-24 11:14:05 cg Exp $'
!
version_SVN
^ '§Id: JavaProcess.st,v 1.15 2011/08/18 18:42:48 vrany Exp §'
! !