author | hlopkmar |
Tue, 22 Nov 2011 12:25:11 +0000 | |
branch | jk_new_structure |
changeset 1147 | 9431cebfd873 |
parent 1130 | 9e6c3f1aadd4 |
child 1152 | 040cba55a7d2 |
permissions | -rw-r--r-- |
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 |
| jThread | |
|
165 |
jThread := Java threads keyAtValue: self. |
|
1147
9431cebfd873
java monitors totally integrated.. maybe too ambitious.. we'll see
hlopkmar
parents:
1130
diff
changeset
|
166 |
self breakPoint: #mh. |
752 | 167 |
JavaVM wakeup: jThread. |
168 |
super terminateNoSignal |
|
169 |
||
170 |
"Created: / 15-12-2010 / 00:18:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
171 |
"Modified: / 15-12-2010 / 11:19:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1147
9431cebfd873
java monitors totally integrated.. maybe too ambitious.. we'll see
hlopkmar
parents:
1130
diff
changeset
|
172 |
"Modified: / 22-11-2011 / 13:25:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 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 |
|
1118 | 188 |
| procName | |
905 | 189 |
Object abortSignal |
1118 | 190 |
handle: [ |
191 |
:ex | |
|
752 | 192 |
procName := javaProcess name. |
1118 | 193 |
(procName startsWith: 'JAVA-AWT-EventQueue') ifTrue: [ |
194 |
Logger |
|
195 |
log: ('thread ' , procName , ' aborted - restarting process.') |
|
196 |
severity: #info |
|
197 |
facility: 'JVM'. |
|
905 | 198 |
ex restart. |
1118 | 199 |
] ifFalse: [ |
200 |
(javaProcess == (Smalltalk at: #'JavaVM:JavaScreenUpdaterThread') |
|
201 |
or: [ javaProcess == (Smalltalk at: #'JavaVM:JavaEventQueueThread') ]) |
|
202 |
ifTrue: [ |
|
203 |
Logger |
|
204 |
log: ('thread ' , procName , ' aborted - restarting process.') |
|
205 |
severity: #info |
|
206 |
facility: 'JVM'. |
|
905 | 207 |
ex restart |
1118 | 208 |
] |
209 |
ifFalse: [ |
|
210 |
Logger |
|
211 |
log: ('thread ' , procName , ' aborted.') |
|
212 |
severity: #info |
|
213 |
facility: 'JVM'. |
|
905 | 214 |
] |
215 |
]. |
|
216 |
] |
|
1118 | 217 |
do: [ |
905 | 218 |
[ |
219 |
JavaVM javaExceptionSignal |
|
1118 | 220 |
handle: [ |
221 |
:ex | |
|
222 |
| exClass | |
|
905 | 223 |
procName := javaProcess name. |
224 |
exClass := ex parameter class. |
|
1118 | 225 |
exClass == (Java at: 'java.lang.ThreadDeath') ifTrue: [ |
226 |
Logger |
|
227 |
log: ('thread ' , procName , ' terminated') |
|
228 |
severity: #info |
|
229 |
facility: 'JVM'. |
|
230 |
] ifFalse: [ |
|
231 |
Logger |
|
232 |
log: ('JAVA: thread ''' , procName , ''' terminated with exception: ' |
|
233 |
, exClass name) |
|
234 |
severity: #info |
|
235 |
facility: 'JVM'. |
|
905 | 236 |
]. |
237 |
ex return. |
|
238 |
] |
|
1118 | 239 |
do: [ |
905 | 240 |
Object messageNotUnderstoodSignal |
1118 | 241 |
handle: [ |
242 |
:ex | |
|
243 |
| |
|
905 | 244 |
"/ remap doesNotUnderstand with nil-receiver to |
245 |
"/ a nullPointerException ... |
|
1118 | 246 |
con m | |
905 | 247 |
con := ex suspendedContext. |
1118 | 248 |
con receiver isNil ifTrue: [ |
249 |
((m := con sender method) notNil and: [ m isJavaMethod ]) ifTrue: [ |
|
905 | 250 |
JavaVM throwNullPointerException. |
251 |
AbortSignal raise. |
|
252 |
||
253 |
"/ ex proceed. |
|
254 |
] |
|
255 |
]. |
|
256 |
ex reject. |
|
257 |
] |
|
1118 | 258 |
do: [ |
905 | 259 |
"/ Transcript showCR:(Timestamp now printString , 'start thread: ', stProcess name). |
1110
7413fa7769ec
- call Thread.exit() even if thread is aborted by user (or Smalltalk code)
vranyj1
parents:
1109
diff
changeset
|
260 |
[ |
1118 | 261 |
javaThreadObject perform: #'run()V'. |
262 |
(Smalltalk at: #'JavaVM:ThreadTrace') == true ifTrue: [ |
|
263 |
Logger |
|
264 |
log: ('thread ' , javaProcess name , ' terminated') |
|
265 |
severity: #info |
|
266 |
facility: 'JVM'. |
|
1110
7413fa7769ec
- call Thread.exit() even if thread is aborted by user (or Smalltalk code)
vranyj1
parents:
1109
diff
changeset
|
267 |
]. |
1118 | 268 |
] ensure: [ |
269 |
javaThreadObject perform: #'exit()V'. |
|
270 |
(Smalltalk at: #'JavaVM:ThreadTrace') == true ifTrue: [ |
|
271 |
Logger |
|
272 |
log: ('after exit of thread ' , javaProcess name) |
|
273 |
severity: #info |
|
274 |
facility: 'JVM'. |
|
1110
7413fa7769ec
- call Thread.exit() even if thread is aborted by user (or Smalltalk code)
vranyj1
parents:
1109
diff
changeset
|
275 |
] |
905 | 276 |
] |
277 |
] |
|
278 |
] |
|
1118 | 279 |
] ensure: [ |
1130 | 280 |
|
1122 | 281 |
JavaVM leaveMonitorsOfProcess: javaProcess. |
1118 | 282 |
javaProcess == (Smalltalk at: #'JavaVM:JavaScreenUpdaterThread') ifTrue: [ |
283 |
Smalltalk at: #'JavaVM:JavaScreenUpdaterThread' put: nil. |
|
1090 | 284 |
]. |
1118 | 285 |
javaProcess == (Smalltalk at: #'JavaVM:JavaEventQueueThread') ifTrue: [ |
286 |
Smalltalk at: #'JavaVM:JavaEventQueueThread' put: nil. |
|
1090 | 287 |
]. |
1118 | 288 |
|
752 | 289 |
"/ screenUpdaterClass := Java at:'sun.awt.ScreenUpdater'. |
290 |
"/ screenUpdaterClass notNil ifTrue:[ |
|
291 |
"/ screenUpdaterClass instVarNamed:'updater' put:nil. |
|
292 |
"/ ]. |
|
1118 | 293 |
|
294 |
Java threads removeKey: javaThreadObject ifAbsent: []. |
|
905 | 295 |
] |
296 |
] |
|
752 | 297 |
|
298 |
"Created: / 15-12-2010 / 11:06:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1130 | 299 |
"Modified: / 17-11-2011 / 21:30:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 300 |
! ! |
301 |
||
302 |
!JavaProcess class methodsFor:'documentation'! |
|
303 |
||
304 |
version |
|
1022 | 305 |
^ '$Id$' |
752 | 306 |
! |
307 |
||
308 |
version_SVN |
|
1022 | 309 |
^ '$Id$' |
1000 | 310 |
! ! |