454
|
1 |
"
|
2151
|
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
3 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
2200
|
4 |
SWING Research Group, Czech Technical University in Prague (*)
|
454
|
5 |
|
|
6 |
This software is furnished under a license and may be used
|
|
7 |
only in accordance with the terms of that license and with the
|
|
8 |
inclusion of the above copyright notice. This software may not
|
|
9 |
be provided or otherwise made available to, or used by, any
|
|
10 |
other person. No title to or ownership of the software is
|
|
11 |
hereby transferred.
|
2151
|
12 |
|
2200
|
13 |
(*) extensions, changes and fixes for java1.1 compatibility.
|
|
14 |
For a list of changes, see a list of diffs against the last stable version before 2011-08.
|
2151
|
15 |
"
|
713
|
16 |
"{ Package: 'stx:libjava' }"
|
|
17 |
|
56
|
18 |
Process subclass:#JavaProcess
|
|
19 |
instanceVariableNames:'suspendedContext'
|
|
20 |
classVariableNames:''
|
|
21 |
poolDictionaries:''
|
713
|
22 |
category:'Languages-Java-Classes'
|
56
|
23 |
!
|
|
24 |
|
2151
|
25 |
Object subclass:#Helper
|
|
26 |
instanceVariableNames:'javaThreadObject javaProcess'
|
|
27 |
classVariableNames:''
|
|
28 |
poolDictionaries:''
|
|
29 |
privateIn:JavaProcess
|
|
30 |
!
|
|
31 |
|
454
|
32 |
!JavaProcess class methodsFor:'documentation'!
|
|
33 |
|
|
34 |
copyright
|
|
35 |
"
|
2151
|
36 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
37 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
2200
|
38 |
SWING Research Group, Czech Technical University in Prague (*)
|
454
|
39 |
|
|
40 |
This software is furnished under a license and may be used
|
|
41 |
only in accordance with the terms of that license and with the
|
|
42 |
inclusion of the above copyright notice. This software may not
|
|
43 |
be provided or otherwise made available to, or used by, any
|
|
44 |
other person. No title to or ownership of the software is
|
|
45 |
hereby transferred.
|
2151
|
46 |
|
2200
|
47 |
(*) extensions, changes and fixes for java1.1 compatibility.
|
|
48 |
For a list of changes, see a list of diffs against the last stable version before 2011-08.
|
2151
|
49 |
|
2107
|
50 |
"
|
2151
|
51 |
! !
|
749
|
52 |
|
2151
|
53 |
!JavaProcess class methodsFor:'instance creation'!
|
|
54 |
|
|
55 |
newHelper
|
|
56 |
|
|
57 |
^Helper new
|
|
58 |
|
|
59 |
"Created: / 15-12-2010 / 11:11:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
454
|
60 |
! !
|
56
|
61 |
|
58
|
62 |
!JavaProcess methodsFor:'accessing'!
|
|
63 |
|
|
64 |
suspendedContext
|
261
|
65 |
|con|
|
|
66 |
|
313
|
67 |
"/ suspendedContext notNil ifTrue:[^ suspendedContext].
|
|
68 |
"/ state ~~ #debug ifTrue:[
|
|
69 |
"/ "/ hide non-JAVA contexts ...
|
|
70 |
"/ con := super suspendedContext.
|
|
71 |
"/ [con notNil] whileTrue:[
|
|
72 |
"/ (con isMemberOf:JavaContext) ifTrue:[^ con].
|
|
73 |
"/ con := con sender.
|
|
74 |
"/ ].
|
|
75 |
"/ ].
|
261
|
76 |
^ super suspendedContext
|
58
|
77 |
|
261
|
78 |
"Created: / 7.5.1996 / 09:02:03 / cg"
|
313
|
79 |
"Modified: / 4.2.1998 / 20:44:31 / cg"
|
58
|
80 |
!
|
|
81 |
|
|
82 |
suspendedContext:aContext
|
|
83 |
suspendedContext := aContext
|
|
84 |
|
|
85 |
"Created: 7.5.1996 / 09:02:12 / cg"
|
|
86 |
! !
|
|
87 |
|
221
|
88 |
!JavaProcess methodsFor:'interrupts'!
|
|
89 |
|
|
90 |
clearInterruptActions
|
|
91 |
interruptActions := nil
|
|
92 |
|
|
93 |
"Created: 14.8.1997 / 17:27:22 / cg"
|
|
94 |
!
|
|
95 |
|
|
96 |
isInterrupted
|
|
97 |
^ interruptActions notNil
|
|
98 |
|
|
99 |
"Created: 14.8.1997 / 17:26:40 / cg"
|
338
|
100 |
!
|
|
101 |
|
|
102 |
markInterrupted
|
|
103 |
super interruptWith:[]
|
|
104 |
|
|
105 |
"Modified: / 10.4.1998 / 15:20:58 / cg"
|
|
106 |
"Created: / 10.4.1998 / 15:21:15 / cg"
|
221
|
107 |
! !
|
|
108 |
|
2151
|
109 |
!JavaProcess methodsFor:'suspend & resume'!
|
|
110 |
|
|
111 |
terminateNoSignal
|
|
112 |
|
|
113 |
| jThread |
|
|
114 |
jThread := Java threads keyAtValue: self.
|
|
115 |
JavaVM wakeup: jThread.
|
|
116 |
|
|
117 |
super terminateNoSignal
|
|
118 |
|
|
119 |
"Created: / 15-12-2010 / 00:18:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
120 |
"Modified: / 15-12-2010 / 11:19:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
121 |
! !
|
|
122 |
|
|
123 |
!JavaProcess::Helper methodsFor:'initialization'!
|
|
124 |
|
|
125 |
javaProcess:something
|
|
126 |
javaProcess := something.
|
|
127 |
!
|
|
128 |
|
|
129 |
javaThreadObject:something
|
|
130 |
javaThreadObject := something.
|
|
131 |
! !
|
|
132 |
|
|
133 |
!JavaProcess::Helper methodsFor:'support'!
|
|
134 |
|
|
135 |
value
|
|
136 |
|procName|
|
|
137 |
|
|
138 |
Object abortSignal
|
|
139 |
handle:[:ex |
|
|
140 |
procName := javaProcess name.
|
|
141 |
(procName startsWith:'JAVA-AWT-EventQueue') ifTrue:[
|
|
142 |
('JAVA [info]: thread ' , procName , ' aborted - restarting process.')
|
|
143 |
infoPrintCR.
|
|
144 |
ex restart.
|
|
145 |
] ifFalse:[
|
|
146 |
(javaProcess == (Smalltalk at:#'JavaVM:JavaScreenUpdaterThread')
|
|
147 |
or:[javaProcess == (Smalltalk at:#'JavaVM:JavaEventQueueThread')])
|
|
148 |
ifTrue:[
|
|
149 |
('JAVA [info]: thread ' , procName , ' aborted - restarting process.')
|
|
150 |
infoPrintCR.
|
|
151 |
ex restart
|
|
152 |
]
|
|
153 |
ifFalse:[('JAVA [info]: thread ' , procName , ' aborted.') infoPrintCR.]
|
|
154 |
].
|
|
155 |
]
|
|
156 |
do:[
|
|
157 |
[
|
|
158 |
JavaVM javaExceptionSignal
|
|
159 |
handle:[:ex |
|
|
160 |
|exClass|
|
|
161 |
|
|
162 |
procName := javaProcess name.
|
|
163 |
exClass := ex parameter class.
|
|
164 |
exClass == (Java at:'java.lang.ThreadDeath') ifTrue:[
|
|
165 |
('JAVA: thread ' , procName , ' terminated') infoPrintCR.
|
|
166 |
] ifFalse:[
|
|
167 |
Transcript
|
|
168 |
showCR:('JAVA: thread ''' , procName , ''' terminated with exception: '
|
|
169 |
, exClass name).
|
|
170 |
].
|
|
171 |
ex return.
|
|
172 |
]
|
|
173 |
do:[
|
|
174 |
Object messageNotUnderstoodSignal
|
|
175 |
handle:[:ex |
|
|
176 |
|
|
|
177 |
"/ remap doesNotUnderstand with nil-receiver to
|
|
178 |
"/ a nullPointerException ...
|
|
179 |
con m|
|
|
180 |
|
|
181 |
con := ex suspendedContext.
|
|
182 |
con receiver isNil ifTrue:[
|
|
183 |
((m := con sender method) notNil and:[m isJavaMethod]) ifTrue:[
|
|
184 |
JavaVM throwNullPointerException.
|
|
185 |
AbortSignal raise.
|
|
186 |
|
|
187 |
"/ ex proceed.
|
|
188 |
]
|
|
189 |
].
|
|
190 |
ex reject.
|
|
191 |
]
|
|
192 |
do:[
|
|
193 |
"/ Transcript showCR:(Timestamp now printString , 'start thread: ', stProcess name).
|
|
194 |
javaThreadObject perform:#'run()V'.
|
|
195 |
(Smalltalk at:#'JavaVM:ThreadTrace') == true ifTrue:[
|
|
196 |
('JAVA: thread ' , javaProcess name , ' terminated') infoPrintCR.
|
|
197 |
].
|
|
198 |
javaThreadObject perform:#'exit()V'.
|
|
199 |
(Smalltalk at:#'JavaVM:ThreadTrace') == true ifTrue:[
|
|
200 |
('JAVA: after exit of thread ' , javaProcess name) infoPrintCR.
|
|
201 |
]
|
|
202 |
]
|
|
203 |
]
|
|
204 |
] ensure:[
|
|
205 |
|monitors|
|
|
206 |
|
|
207 |
monitors := (Smalltalk at:#'JavaVM:EnteredMonitorsPerProcess')
|
|
208 |
at:javaProcess
|
|
209 |
ifAbsent:nil.
|
|
210 |
monitors notNil ifTrue:[
|
|
211 |
monitors do:[:obj |
|
|
212 |
|mon|
|
|
213 |
|
|
214 |
mon := JavaVM monitorFor:obj.
|
|
215 |
mon notNil ifTrue:[
|
|
216 |
mon owningProcess == javaProcess ifTrue:[
|
|
217 |
('JAVA: release monitor owned by dying thread: ' , javaProcess name)
|
|
218 |
infoPrintCR.
|
|
219 |
self breakPoint: #jv.
|
|
220 |
mon exit
|
|
221 |
].
|
|
222 |
].
|
|
223 |
].
|
|
224 |
(Smalltalk at:#'JavaVM:EnteredMonitorsPerProcess') removeKey:javaProcess.
|
|
225 |
javaProcess == (Smalltalk at:#'JavaVM:JavaScreenUpdaterThread') ifTrue:[
|
|
226 |
Smalltalk at:#'JavaVM:JavaScreenUpdaterThread' put:nil.
|
|
227 |
].
|
|
228 |
javaProcess == (Smalltalk at:#'JavaVM:JavaEventQueueThread') ifTrue:[
|
|
229 |
Smalltalk at:#'JavaVM:JavaEventQueueThread' put:nil.
|
|
230 |
].
|
|
231 |
|
|
232 |
"/ screenUpdaterClass := Java at:'sun.awt.ScreenUpdater'.
|
|
233 |
"/ screenUpdaterClass notNil ifTrue:[
|
|
234 |
"/ screenUpdaterClass instVarNamed:'updater' put:nil.
|
|
235 |
"/ ].
|
|
236 |
].
|
|
237 |
Java threads removeKey:javaThreadObject ifAbsent:[].
|
|
238 |
]
|
|
239 |
]
|
|
240 |
|
|
241 |
"Created: / 15-12-2010 / 11:06:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
242 |
! !
|
|
243 |
|
133
|
244 |
!JavaProcess class methodsFor:'documentation'!
|
56
|
245 |
|
|
246 |
version
|
2200
|
247 |
^ '$Header: /cvs/stx/stx/libjava/JavaProcess.st,v 1.16 2011-11-24 11:14:05 cg Exp $'
|
|
248 |
!
|
|
249 |
|
|
250 |
version_CVS
|
|
251 |
^ '$Header: /cvs/stx/stx/libjava/JavaProcess.st,v 1.16 2011-11-24 11:14:05 cg Exp $'
|
2151
|
252 |
!
|
|
253 |
|
|
254 |
version_SVN
|
2200
|
255 |
^ '§Id: JavaProcess.st,v 1.15 2011/08/18 18:42:48 vrany Exp §'
|
2107
|
256 |
! !
|