752
|
1 |
"
|
877
|
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
3 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
4 |
SWING Research Group, Czech Technical University in Prague
|
|
5 |
|
|
6 |
Parts of the code written by Claus Gittinger are under following
|
|
7 |
license:
|
752
|
8 |
|
|
9 |
This software is furnished under a license and may be used
|
|
10 |
only in accordance with the terms of that license and with the
|
|
11 |
inclusion of the above copyright notice. This software may not
|
|
12 |
be provided or otherwise made available to, or used by, any
|
|
13 |
other person. No title to or ownership of the software is
|
|
14 |
hereby transferred.
|
877
|
15 |
|
|
16 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
|
|
17 |
|
|
18 |
Permission is hereby granted, free of charge, to any person
|
|
19 |
obtaining a copy of this software and associated documentation
|
|
20 |
files (the 'Software'), to deal in the Software without
|
|
21 |
restriction, including without limitation the rights to use,
|
|
22 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
23 |
copies of the Software, and to permit persons to whom the
|
|
24 |
Software is furnished to do so, subject to the following
|
|
25 |
conditions:
|
|
26 |
|
|
27 |
The above copyright notice and this permission notice shall be
|
|
28 |
included in all copies or substantial portions of the Software.
|
|
29 |
|
|
30 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
31 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
32 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
33 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
34 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
35 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
36 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
37 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
38 |
|
|
39 |
[1] Code written at SWING Research Group contain a signature
|
|
40 |
of one of the above copright owners.
|
752
|
41 |
"
|
|
42 |
"{ Package: 'stx:libjava' }"
|
|
43 |
|
|
44 |
Process subclass:#JavaProcess
|
|
45 |
instanceVariableNames:'suspendedContext'
|
|
46 |
classVariableNames:''
|
|
47 |
poolDictionaries:''
|
|
48 |
category:'Languages-Java-Classes'
|
|
49 |
!
|
|
50 |
|
|
51 |
Object subclass:#Helper
|
|
52 |
instanceVariableNames:'javaThreadObject javaProcess'
|
|
53 |
classVariableNames:''
|
|
54 |
poolDictionaries:''
|
|
55 |
privateIn:JavaProcess
|
|
56 |
!
|
|
57 |
|
|
58 |
!JavaProcess class methodsFor:'documentation'!
|
|
59 |
|
|
60 |
copyright
|
|
61 |
"
|
877
|
62 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
63 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
64 |
SWING Research Group, Czech Technical University in Prague
|
|
65 |
|
|
66 |
Parts of the code written by Claus Gittinger are under following
|
|
67 |
license:
|
752
|
68 |
|
|
69 |
This software is furnished under a license and may be used
|
|
70 |
only in accordance with the terms of that license and with the
|
|
71 |
inclusion of the above copyright notice. This software may not
|
|
72 |
be provided or otherwise made available to, or used by, any
|
|
73 |
other person. No title to or ownership of the software is
|
|
74 |
hereby transferred.
|
877
|
75 |
|
|
76 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
|
|
77 |
|
|
78 |
Permission is hereby granted, free of charge, to any person
|
|
79 |
obtaining a copy of this software and associated documentation
|
|
80 |
files (the 'Software'), to deal in the Software without
|
|
81 |
restriction, including without limitation the rights to use,
|
|
82 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
83 |
copies of the Software, and to permit persons to whom the
|
|
84 |
Software is furnished to do so, subject to the following
|
|
85 |
conditions:
|
|
86 |
|
|
87 |
The above copyright notice and this permission notice shall be
|
|
88 |
included in all copies or substantial portions of the Software.
|
|
89 |
|
|
90 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
91 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
92 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
93 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
94 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
95 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
96 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
97 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
98 |
|
|
99 |
[1] Code written at SWING Research Group contain a signature
|
|
100 |
of one of the above copright owners.
|
|
101 |
|
752
|
102 |
"
|
|
103 |
! !
|
|
104 |
|
|
105 |
!JavaProcess class methodsFor:'instance creation'!
|
|
106 |
|
|
107 |
newHelper
|
|
108 |
|
|
109 |
^Helper new
|
|
110 |
|
|
111 |
"Created: / 15-12-2010 / 11:11:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
112 |
! !
|
|
113 |
|
|
114 |
!JavaProcess methodsFor:'accessing'!
|
|
115 |
|
|
116 |
suspendedContext
|
|
117 |
|con|
|
|
118 |
|
|
119 |
"/ suspendedContext notNil ifTrue:[^ suspendedContext].
|
|
120 |
"/ state ~~ #debug ifTrue:[
|
|
121 |
"/ "/ hide non-JAVA contexts ...
|
|
122 |
"/ con := super suspendedContext.
|
|
123 |
"/ [con notNil] whileTrue:[
|
|
124 |
"/ (con isMemberOf:JavaContext) ifTrue:[^ con].
|
|
125 |
"/ con := con sender.
|
|
126 |
"/ ].
|
|
127 |
"/ ].
|
|
128 |
^ super suspendedContext
|
|
129 |
|
|
130 |
"Created: / 7.5.1996 / 09:02:03 / cg"
|
|
131 |
"Modified: / 4.2.1998 / 20:44:31 / cg"
|
|
132 |
!
|
|
133 |
|
|
134 |
suspendedContext:aContext
|
|
135 |
suspendedContext := aContext
|
|
136 |
|
|
137 |
"Created: 7.5.1996 / 09:02:12 / cg"
|
|
138 |
! !
|
|
139 |
|
|
140 |
!JavaProcess methodsFor:'interrupts'!
|
|
141 |
|
|
142 |
clearInterruptActions
|
|
143 |
interruptActions := nil
|
|
144 |
|
|
145 |
"Created: 14.8.1997 / 17:27:22 / cg"
|
|
146 |
!
|
|
147 |
|
|
148 |
isInterrupted
|
|
149 |
^ interruptActions notNil
|
|
150 |
|
|
151 |
"Created: 14.8.1997 / 17:26:40 / cg"
|
|
152 |
!
|
|
153 |
|
|
154 |
markInterrupted
|
|
155 |
super interruptWith:[]
|
|
156 |
|
|
157 |
"Modified: / 10.4.1998 / 15:20:58 / cg"
|
|
158 |
"Created: / 10.4.1998 / 15:21:15 / cg"
|
|
159 |
! !
|
|
160 |
|
|
161 |
!JavaProcess methodsFor:'suspend & resume'!
|
|
162 |
|
|
163 |
terminateNoSignal
|
|
164 |
|
|
165 |
| jThread |
|
|
166 |
jThread := Java threads keyAtValue: self.
|
|
167 |
JavaVM wakeup: jThread.
|
|
168 |
|
|
169 |
super terminateNoSignal
|
|
170 |
|
|
171 |
"Created: / 15-12-2010 / 00:18:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
172 |
"Modified: / 15-12-2010 / 11:19:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
173 |
! !
|
|
174 |
|
|
175 |
!JavaProcess::Helper methodsFor:'initialization'!
|
|
176 |
|
|
177 |
javaProcess:something
|
|
178 |
javaProcess := something.
|
|
179 |
!
|
|
180 |
|
|
181 |
javaThreadObject:something
|
|
182 |
javaThreadObject := something.
|
|
183 |
! !
|
|
184 |
|
|
185 |
!JavaProcess::Helper methodsFor:'support'!
|
|
186 |
|
|
187 |
value
|
|
188 |
|procName|
|
|
189 |
|
905
|
190 |
Object abortSignal
|
|
191 |
handle:[:ex |
|
752
|
192 |
procName := javaProcess name.
|
905
|
193 |
(procName startsWith:'JAVA-AWT-EventQueue') ifTrue:[
|
1000
|
194 |
Logger log: ('thread ' , procName , ' aborted - restarting process.') severity: #info facility: 'JVM'.
|
905
|
195 |
ex restart.
|
|
196 |
] ifFalse:[
|
|
197 |
(javaProcess == (Smalltalk at:#'JavaVM:JavaScreenUpdaterThread')
|
|
198 |
or:[javaProcess == (Smalltalk at:#'JavaVM:JavaEventQueueThread')])
|
|
199 |
ifTrue:[
|
1000
|
200 |
Logger log: ('thread ' , procName , ' aborted - restarting process.') severity: #info facility: 'JVM'.
|
905
|
201 |
ex restart
|
1000
|
202 |
] ifFalse:[
|
|
203 |
Logger log:('thread ' , procName , ' aborted.') severity: #info facility: 'JVM'.
|
905
|
204 |
]
|
|
205 |
].
|
|
206 |
]
|
|
207 |
do:[
|
|
208 |
[
|
|
209 |
JavaVM javaExceptionSignal
|
|
210 |
handle:[:ex |
|
|
211 |
|exClass|
|
752
|
212 |
|
905
|
213 |
procName := javaProcess name.
|
|
214 |
exClass := ex parameter class.
|
|
215 |
exClass == (Java at:'java.lang.ThreadDeath') ifTrue:[
|
1000
|
216 |
Logger log: ('thread ' , procName , ' terminated') severity: #info facility: 'JVM'.
|
905
|
217 |
] ifFalse:[
|
1000
|
218 |
Logger log:
|
|
219 |
('JAVA: thread ''' , procName , ''' terminated with exception: '
|
|
220 |
, exClass name) severity: #info facility: 'JVM'.
|
905
|
221 |
].
|
|
222 |
ex return.
|
|
223 |
]
|
|
224 |
do:[
|
|
225 |
Object messageNotUnderstoodSignal
|
|
226 |
handle:[:ex |
|
|
227 |
|
|
|
228 |
"/ remap doesNotUnderstand with nil-receiver to
|
|
229 |
"/ a nullPointerException ...
|
|
230 |
con m|
|
752
|
231 |
|
905
|
232 |
con := ex suspendedContext.
|
|
233 |
con receiver isNil ifTrue:[
|
|
234 |
((m := con sender method) notNil and:[m isJavaMethod]) ifTrue:[
|
|
235 |
JavaVM throwNullPointerException.
|
|
236 |
AbortSignal raise.
|
|
237 |
|
|
238 |
"/ ex proceed.
|
|
239 |
]
|
|
240 |
].
|
|
241 |
ex reject.
|
|
242 |
]
|
|
243 |
do:[
|
|
244 |
"/ Transcript showCR:(Timestamp now printString , 'start thread: ', stProcess name).
|
|
245 |
javaThreadObject perform:#'run()V'.
|
|
246 |
(Smalltalk at:#'JavaVM:ThreadTrace') == true ifTrue:[
|
1000
|
247 |
Logger log: ('thread ' , javaProcess name , ' terminated') severity: #info facility: 'JVM'.
|
905
|
248 |
].
|
|
249 |
javaThreadObject perform:#'exit()V'.
|
|
250 |
(Smalltalk at:#'JavaVM:ThreadTrace') == true ifTrue:[
|
1000
|
251 |
Logger log: ('after exit of thread ' , javaProcess name) severity: #info facility: 'JVM'.
|
905
|
252 |
]
|
|
253 |
]
|
|
254 |
]
|
|
255 |
] ensure:[
|
|
256 |
|monitors|
|
752
|
257 |
|
905
|
258 |
monitors := (Smalltalk at:#'JavaVM:EnteredMonitorsPerProcess')
|
|
259 |
at:javaProcess
|
|
260 |
ifAbsent:nil.
|
|
261 |
monitors notNil ifTrue:[
|
|
262 |
monitors do:[:obj |
|
|
263 |
|mon|
|
752
|
264 |
|
905
|
265 |
mon := JavaVM monitorFor:obj.
|
|
266 |
mon notNil ifTrue:[
|
|
267 |
mon owningProcess == javaProcess ifTrue:[
|
|
268 |
('JAVA: release monitor owned by dying thread: ' , javaProcess name)
|
|
269 |
infoPrintCR.
|
|
270 |
self breakPoint: #jv.
|
|
271 |
mon exit
|
|
272 |
].
|
|
273 |
].
|
|
274 |
].
|
|
275 |
(Smalltalk at:#'JavaVM:EnteredMonitorsPerProcess') removeKey:javaProcess.
|
|
276 |
javaProcess == (Smalltalk at:#'JavaVM:JavaScreenUpdaterThread') ifTrue:[
|
|
277 |
Smalltalk at:#'JavaVM:JavaScreenUpdaterThread' put:nil.
|
|
278 |
].
|
|
279 |
javaProcess == (Smalltalk at:#'JavaVM:JavaEventQueueThread') ifTrue:[
|
|
280 |
Smalltalk at:#'JavaVM:JavaEventQueueThread' put:nil.
|
|
281 |
].
|
|
282 |
|
752
|
283 |
"/ screenUpdaterClass := Java at:'sun.awt.ScreenUpdater'.
|
|
284 |
"/ screenUpdaterClass notNil ifTrue:[
|
|
285 |
"/ screenUpdaterClass instVarNamed:'updater' put:nil.
|
|
286 |
"/ ].
|
905
|
287 |
].
|
|
288 |
Java threads removeKey:javaThreadObject ifAbsent:[].
|
|
289 |
]
|
|
290 |
]
|
752
|
291 |
|
|
292 |
"Created: / 15-12-2010 / 11:06:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
293 |
! !
|
|
294 |
|
|
295 |
!JavaProcess class methodsFor:'documentation'!
|
|
296 |
|
|
297 |
version
|
1022
|
298 |
^ '$Id$'
|
752
|
299 |
!
|
|
300 |
|
|
301 |
version_SVN
|
1022
|
302 |
^ '$Id$'
|
1000
|
303 |
! !
|