author | vranyj1 |
Wed, 23 Nov 2011 15:26:06 +0000 | |
branch | jk_new_structure |
changeset 1152 | 040cba55a7d2 |
parent 1147 | 9431cebfd873 |
child 1155 | d6f6d5fc0343 |
permissions | -rw-r--r-- |
752 | 1 |
" |
877 | 2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
1152 | 3 |
|
4 |
New code and modification done at SWING Research Group [1]: |
|
5 |
||
877 | 6 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
7 |
SWING Research Group, Czech Technical University in Prague |
|
8 |
||
9 |
Parts of the code written by Claus Gittinger are under following |
|
10 |
license: |
|
752 | 11 |
|
12 |
This software is furnished under a license and may be used |
|
13 |
only in accordance with the terms of that license and with the |
|
14 |
inclusion of the above copyright notice. This software may not |
|
15 |
be provided or otherwise made available to, or used by, any |
|
16 |
other person. No title to or ownership of the software is |
|
17 |
hereby transferred. |
|
877 | 18 |
|
19 |
[1] Code written at SWING Research Group contain a signature |
|
1152 | 20 |
of one of the above copright owners. For exact set of such code |
21 |
see the differences between this version and version stx:lib |
|
22 |
as of 1.9.2010 |
|
752 | 23 |
" |
24 |
"{ Package: 'stx:libjava' }" |
|
25 |
||
26 |
Process subclass:#JavaProcess |
|
27 |
instanceVariableNames:'suspendedContext' |
|
28 |
classVariableNames:'' |
|
29 |
poolDictionaries:'' |
|
30 |
category:'Languages-Java-Classes' |
|
31 |
! |
|
32 |
||
33 |
Object subclass:#Helper |
|
34 |
instanceVariableNames:'javaThreadObject javaProcess' |
|
35 |
classVariableNames:'' |
|
36 |
poolDictionaries:'' |
|
37 |
privateIn:JavaProcess |
|
38 |
! |
|
39 |
||
40 |
!JavaProcess class methodsFor:'documentation'! |
|
41 |
||
42 |
copyright |
|
43 |
" |
|
877 | 44 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
1152 | 45 |
|
46 |
New code and modification done at SWING Research Group [1]: |
|
47 |
||
877 | 48 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
49 |
SWING Research Group, Czech Technical University in Prague |
|
50 |
||
51 |
Parts of the code written by Claus Gittinger are under following |
|
52 |
license: |
|
752 | 53 |
|
54 |
This software is furnished under a license and may be used |
|
55 |
only in accordance with the terms of that license and with the |
|
56 |
inclusion of the above copyright notice. This software may not |
|
57 |
be provided or otherwise made available to, or used by, any |
|
58 |
other person. No title to or ownership of the software is |
|
59 |
hereby transferred. |
|
877 | 60 |
|
61 |
[1] Code written at SWING Research Group contain a signature |
|
1152 | 62 |
of one of the above copright owners. For exact set of such code |
63 |
see the differences between this version and version stx:lib |
|
64 |
as of 1.9.2010 |
|
877 | 65 |
|
752 | 66 |
" |
67 |
! ! |
|
68 |
||
69 |
!JavaProcess class methodsFor:'instance creation'! |
|
70 |
||
71 |
newHelper |
|
72 |
||
73 |
^Helper new |
|
74 |
||
75 |
"Created: / 15-12-2010 / 11:11:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
76 |
! ! |
|
77 |
||
78 |
!JavaProcess methodsFor:'accessing'! |
|
79 |
||
80 |
suspendedContext |
|
81 |
|con| |
|
82 |
||
83 |
"/ suspendedContext notNil ifTrue:[^ suspendedContext]. |
|
84 |
"/ state ~~ #debug ifTrue:[ |
|
85 |
"/ "/ hide non-JAVA contexts ... |
|
86 |
"/ con := super suspendedContext. |
|
87 |
"/ [con notNil] whileTrue:[ |
|
88 |
"/ (con isMemberOf:JavaContext) ifTrue:[^ con]. |
|
89 |
"/ con := con sender. |
|
90 |
"/ ]. |
|
91 |
"/ ]. |
|
92 |
^ super suspendedContext |
|
93 |
||
94 |
"Created: / 7.5.1996 / 09:02:03 / cg" |
|
95 |
"Modified: / 4.2.1998 / 20:44:31 / cg" |
|
96 |
! |
|
97 |
||
98 |
suspendedContext:aContext |
|
99 |
suspendedContext := aContext |
|
100 |
||
101 |
"Created: 7.5.1996 / 09:02:12 / cg" |
|
102 |
! ! |
|
103 |
||
104 |
!JavaProcess methodsFor:'interrupts'! |
|
105 |
||
106 |
clearInterruptActions |
|
107 |
interruptActions := nil |
|
108 |
||
109 |
"Created: 14.8.1997 / 17:27:22 / cg" |
|
110 |
! |
|
111 |
||
112 |
isInterrupted |
|
113 |
^ interruptActions notNil |
|
114 |
||
115 |
"Created: 14.8.1997 / 17:26:40 / cg" |
|
116 |
! |
|
117 |
||
118 |
markInterrupted |
|
119 |
super interruptWith:[] |
|
120 |
||
121 |
"Modified: / 10.4.1998 / 15:20:58 / cg" |
|
122 |
"Created: / 10.4.1998 / 15:21:15 / cg" |
|
123 |
! ! |
|
124 |
||
125 |
!JavaProcess methodsFor:'suspend & resume'! |
|
126 |
||
127 |
terminateNoSignal |
|
128 |
| jThread | |
|
129 |
jThread := Java threads keyAtValue: self. |
|
1147
9431cebfd873
java monitors totally integrated.. maybe too ambitious.. we'll see
hlopkmar
parents:
1130
diff
changeset
|
130 |
self breakPoint: #mh. |
752 | 131 |
JavaVM wakeup: jThread. |
132 |
super terminateNoSignal |
|
133 |
||
134 |
"Created: / 15-12-2010 / 00:18:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
135 |
"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
|
136 |
"Modified: / 22-11-2011 / 13:25:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 137 |
! ! |
138 |
||
139 |
!JavaProcess::Helper methodsFor:'initialization'! |
|
140 |
||
141 |
javaProcess:something |
|
142 |
javaProcess := something. |
|
143 |
! |
|
144 |
||
145 |
javaThreadObject:something |
|
146 |
javaThreadObject := something. |
|
147 |
! ! |
|
148 |
||
149 |
!JavaProcess::Helper methodsFor:'support'! |
|
150 |
||
151 |
value |
|
1118 | 152 |
| procName | |
905 | 153 |
Object abortSignal |
1118 | 154 |
handle: [ |
155 |
:ex | |
|
752 | 156 |
procName := javaProcess name. |
1118 | 157 |
(procName startsWith: 'JAVA-AWT-EventQueue') ifTrue: [ |
158 |
Logger |
|
159 |
log: ('thread ' , procName , ' aborted - restarting process.') |
|
160 |
severity: #info |
|
161 |
facility: 'JVM'. |
|
905 | 162 |
ex restart. |
1118 | 163 |
] ifFalse: [ |
164 |
(javaProcess == (Smalltalk at: #'JavaVM:JavaScreenUpdaterThread') |
|
165 |
or: [ javaProcess == (Smalltalk at: #'JavaVM:JavaEventQueueThread') ]) |
|
166 |
ifTrue: [ |
|
167 |
Logger |
|
168 |
log: ('thread ' , procName , ' aborted - restarting process.') |
|
169 |
severity: #info |
|
170 |
facility: 'JVM'. |
|
905 | 171 |
ex restart |
1118 | 172 |
] |
173 |
ifFalse: [ |
|
174 |
Logger |
|
175 |
log: ('thread ' , procName , ' aborted.') |
|
176 |
severity: #info |
|
177 |
facility: 'JVM'. |
|
905 | 178 |
] |
179 |
]. |
|
180 |
] |
|
1118 | 181 |
do: [ |
905 | 182 |
[ |
183 |
JavaVM javaExceptionSignal |
|
1118 | 184 |
handle: [ |
185 |
:ex | |
|
186 |
| exClass | |
|
905 | 187 |
procName := javaProcess name. |
188 |
exClass := ex parameter class. |
|
1118 | 189 |
exClass == (Java at: 'java.lang.ThreadDeath') ifTrue: [ |
190 |
Logger |
|
191 |
log: ('thread ' , procName , ' terminated') |
|
192 |
severity: #info |
|
193 |
facility: 'JVM'. |
|
194 |
] ifFalse: [ |
|
195 |
Logger |
|
196 |
log: ('JAVA: thread ''' , procName , ''' terminated with exception: ' |
|
197 |
, exClass name) |
|
198 |
severity: #info |
|
199 |
facility: 'JVM'. |
|
905 | 200 |
]. |
201 |
ex return. |
|
202 |
] |
|
1118 | 203 |
do: [ |
905 | 204 |
Object messageNotUnderstoodSignal |
1118 | 205 |
handle: [ |
206 |
:ex | |
|
207 |
| |
|
905 | 208 |
"/ remap doesNotUnderstand with nil-receiver to |
209 |
"/ a nullPointerException ... |
|
1118 | 210 |
con m | |
905 | 211 |
con := ex suspendedContext. |
1118 | 212 |
con receiver isNil ifTrue: [ |
213 |
((m := con sender method) notNil and: [ m isJavaMethod ]) ifTrue: [ |
|
905 | 214 |
JavaVM throwNullPointerException. |
215 |
AbortSignal raise. |
|
216 |
||
217 |
"/ ex proceed. |
|
218 |
] |
|
219 |
]. |
|
220 |
ex reject. |
|
221 |
] |
|
1118 | 222 |
do: [ |
905 | 223 |
"/ 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
|
224 |
[ |
1118 | 225 |
javaThreadObject perform: #'run()V'. |
226 |
(Smalltalk at: #'JavaVM:ThreadTrace') == true ifTrue: [ |
|
227 |
Logger |
|
228 |
log: ('thread ' , javaProcess name , ' terminated') |
|
229 |
severity: #info |
|
230 |
facility: 'JVM'. |
|
1110
7413fa7769ec
- call Thread.exit() even if thread is aborted by user (or Smalltalk code)
vranyj1
parents:
1109
diff
changeset
|
231 |
]. |
1118 | 232 |
] ensure: [ |
233 |
javaThreadObject perform: #'exit()V'. |
|
234 |
(Smalltalk at: #'JavaVM:ThreadTrace') == true ifTrue: [ |
|
235 |
Logger |
|
236 |
log: ('after exit of thread ' , javaProcess name) |
|
237 |
severity: #info |
|
238 |
facility: 'JVM'. |
|
1110
7413fa7769ec
- call Thread.exit() even if thread is aborted by user (or Smalltalk code)
vranyj1
parents:
1109
diff
changeset
|
239 |
] |
905 | 240 |
] |
241 |
] |
|
242 |
] |
|
1118 | 243 |
] ensure: [ |
1130 | 244 |
|
1122 | 245 |
JavaVM leaveMonitorsOfProcess: javaProcess. |
1118 | 246 |
javaProcess == (Smalltalk at: #'JavaVM:JavaScreenUpdaterThread') ifTrue: [ |
247 |
Smalltalk at: #'JavaVM:JavaScreenUpdaterThread' put: nil. |
|
1090 | 248 |
]. |
1118 | 249 |
javaProcess == (Smalltalk at: #'JavaVM:JavaEventQueueThread') ifTrue: [ |
250 |
Smalltalk at: #'JavaVM:JavaEventQueueThread' put: nil. |
|
1090 | 251 |
]. |
1118 | 252 |
|
752 | 253 |
"/ screenUpdaterClass := Java at:'sun.awt.ScreenUpdater'. |
254 |
"/ screenUpdaterClass notNil ifTrue:[ |
|
255 |
"/ screenUpdaterClass instVarNamed:'updater' put:nil. |
|
256 |
"/ ]. |
|
1118 | 257 |
|
258 |
Java threads removeKey: javaThreadObject ifAbsent: []. |
|
905 | 259 |
] |
260 |
] |
|
752 | 261 |
|
262 |
"Created: / 15-12-2010 / 11:06:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1130 | 263 |
"Modified: / 17-11-2011 / 21:30:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 264 |
! ! |
265 |
||
266 |
!JavaProcess class methodsFor:'documentation'! |
|
267 |
||
268 |
version |
|
1022 | 269 |
^ '$Id$' |
752 | 270 |
! |
271 |
||
272 |
version_SVN |
|
1022 | 273 |
^ '$Id$' |
1000 | 274 |
! ! |