author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 31 Jan 2013 15:18:47 +0000 | |
branch | refactoring-vmdata |
changeset 2021 | 75e48299fc2d |
parent 1864 | 60a8dc26c8c6 |
child 2069 | 75d40b7b986f |
permissions | -rw-r--r-- |
877 | 1 |
" |
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 3 |
|
1155 | 4 |
New code and modifications done at SWING Research Group [1]: |
1152 | 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 |
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. |
|
15 |
||
1155 | 16 |
[1] Code written at SWING Research Group contains a signature |
17 |
of one of the above copright owners. For exact set of such code, |
|
18 |
see the differences between this version and version stx:libjava |
|
1152 | 19 |
as of 1.9.2010 |
877 | 20 |
" |
752 | 21 |
"{ Package: 'stx:libjava' }" |
22 |
||
23 |
Array variableSubclass:#JavaArray |
|
24 |
instanceVariableNames:'' |
|
25 |
classVariableNames:'' |
|
26 |
poolDictionaries:'' |
|
27 |
category:'Languages-Java-Classes' |
|
28 |
! |
|
29 |
||
30 |
JavaArray class instanceVariableNames:'componentClass' |
|
31 |
||
32 |
" |
|
33 |
No other class instance variables are inherited by this class. |
|
34 |
" |
|
35 |
! |
|
36 |
||
877 | 37 |
!JavaArray class methodsFor:'documentation'! |
38 |
||
39 |
copyright |
|
40 |
" |
|
41 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 42 |
|
1155 | 43 |
New code and modifications done at SWING Research Group [1]: |
1152 | 44 |
|
877 | 45 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
46 |
SWING Research Group, Czech Technical University in Prague |
|
47 |
||
48 |
This software is furnished under a license and may be used |
|
49 |
only in accordance with the terms of that license and with the |
|
50 |
inclusion of the above copyright notice. This software may not |
|
51 |
be provided or otherwise made available to, or used by, any |
|
52 |
other person. No title to or ownership of the software is |
|
53 |
hereby transferred. |
|
54 |
||
1155 | 55 |
[1] Code written at SWING Research Group contains a signature |
56 |
of one of the above copright owners. For exact set of such code, |
|
57 |
see the differences between this version and version stx:libjava |
|
1152 | 58 |
as of 1.9.2010 |
877 | 59 |
|
60 |
" |
|
61 |
! ! |
|
752 | 62 |
|
63 |
!JavaArray class methodsFor:'initialization'! |
|
64 |
||
1035 | 65 |
classInit |
66 |
||
67 |
componentClass isJavaClass ifTrue:[ |
|
68 |
^componentClass classInit |
|
69 |
]. |
|
70 |
componentClass isJavaArrayClass ifTrue:[ |
|
71 |
componentClass javaComponentClass isJavaPrimitiveType ifFalse:[ |
|
72 |
^componentClass classInit |
|
73 |
] |
|
74 |
] |
|
75 |
||
76 |
"Created: / 21-10-2011 / 11:03:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
77 |
! |
|
78 |
||
752 | 79 |
setComponentClass:aClass |
80 |
componentClass := aClass. |
|
81 |
||
82 |
"Created: / 17-12-2010 / 13:25:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
83 |
! ! |
|
84 |
||
85 |
!JavaArray class methodsFor:'accessing'! |
|
86 |
||
957 | 87 |
classLoader |
88 |
||
89 |
^self javaComponentClass classLoader |
|
90 |
||
91 |
"Created: / 31-08-2011 / 22:22:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
92 |
! |
|
93 |
||
752 | 94 |
javaClass |
95 |
^ self |
|
96 |
||
97 |
"Created: / 19-12-2010 / 17:09:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
98 |
! |
|
99 |
||
100 |
javaComponentClass |
|
101 |
^ componentClass |
|
102 |
||
103 |
"Created: / 20-12-2010 / 22:02:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
104 |
! |
|
105 |
||
106 |
javaName |
|
960 | 107 |
|
108 |
componentClass isJavaArrayClass ifTrue:[ |
|
109 |
^'[' , componentClass javaName. |
|
110 |
]. |
|
111 |
||
752 | 112 |
^'[L' , componentClass javaName, ';' |
113 |
||
114 |
"Created: / 25-02-2011 / 19:29:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
812
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
115 |
! |
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
116 |
|
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
117 |
javaPackage |
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
118 |
|
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
119 |
^componentClass javaPackage |
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
120 |
|
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
121 |
"Created: / 22-05-2011 / 18:07:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
122 |
! |
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
123 |
|
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
124 |
lookupMethodByNameAndType: aJavaNameAndType |
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
125 |
|
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
126 |
"Trick, since java arrays should respond to all messages |
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
127 |
understood by java.lang.object" |
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
128 |
^ (Java at:'java.lang.Object') lookupMethodByNameAndType: aJavaNameAndType |
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
129 |
|
62e917825364
- JavaDescriptor, JavaResolver, JavaArray: fixes for primitive and array types
vranyj1
parents:
752
diff
changeset
|
130 |
"Created: / 22-05-2011 / 18:03:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 131 |
! ! |
132 |
||
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1511
diff
changeset
|
133 |
!JavaArray class methodsFor:'accessing - java'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1511
diff
changeset
|
134 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1511
diff
changeset
|
135 |
javaMirrorClass |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1511
diff
changeset
|
136 |
^self == JavaArray ifTrue:[ |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1511
diff
changeset
|
137 |
super javaMirrorClass |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1511
diff
changeset
|
138 |
] ifFalse:[ |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1511
diff
changeset
|
139 |
JavaMirror mirrorClassForJavaArray |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1511
diff
changeset
|
140 |
] |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1511
diff
changeset
|
141 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1511
diff
changeset
|
142 |
"Created: / 31-07-2012 / 18:28:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1511
diff
changeset
|
143 |
! ! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
1511
diff
changeset
|
144 |
|
1481 | 145 |
!JavaArray class methodsFor:'autoboxing support'! |
146 |
||
147 |
javaUnwrap: anObject |
|
148 |
"Given a Java array, create a corresponding Smalltalk array. |
|
149 |
Called by interop proxies" |
|
150 |
||
151 |
| sarray | |
|
152 |
||
153 |
sarray := Array new: anObject size. |
|
154 |
1 to: sarray size do:[:i| |
|
155 |
sarray at: i put: (componentClass javaUnwrap: (anObject at: i)). |
|
156 |
]. |
|
157 |
^sarray. |
|
158 |
||
159 |
"Created: / 18-04-2012 / 08:23:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
160 |
! |
|
161 |
||
162 |
javaWrap: anObject |
|
163 |
"Given a Smalltalk array, create a corresponding Java array. |
|
164 |
Called by interop proxies" |
|
165 |
||
166 |
| jarray | |
|
167 |
||
168 |
self assert: anObject isSequenceable. |
|
169 |
jarray := self new: anObject size. |
|
170 |
1 to: jarray size do:[:i| |
|
171 |
jarray at: i put: (componentClass javaWrap: (anObject at: i)). |
|
172 |
]. |
|
173 |
^jarray. |
|
174 |
||
175 |
"Created: / 18-04-2012 / 08:21:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1805 | 176 |
! |
177 |
||
178 |
javaWrapRequired |
|
179 |
"Returns true, if a #javaWrap: has to be called |
|
180 |
prior an instance of Smalltalk object is passed |
|
181 |
as an argument to Java method, whoose formal tyoe |
|
182 |
is the receiver. " |
|
183 |
||
184 |
^ true |
|
185 |
||
186 |
"Created: / 04-11-2012 / 23:33:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1481 | 187 |
! ! |
188 |
||
752 | 189 |
!JavaArray class methodsFor:'class creation'! |
190 |
||
851 | 191 |
javaArrayClass |
192 |
||
193 |
^self javaArrayClassFor: self. |
|
194 |
||
195 |
"Created: / 11-06-2011 / 23:35:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
196 |
! |
|
197 |
||
1033 | 198 |
javaArrayClassFor: aJavaClass |
199 |
| meta cls | |
|
752 | 200 |
|
1511 | 201 |
^JavaVM arrayClassFor: aJavaClass ifAbsentPut:[ |
202 |
meta := Metaclass new. |
|
203 |
meta setSuperclass: JavaArray class. |
|
204 |
meta instSize: JavaArray class instSize. |
|
205 |
cls := meta new. |
|
206 |
cls setSuperclass: JavaArray. |
|
207 |
cls flags: JavaArray flags. |
|
208 |
cls instSize: JavaArray instSize. |
|
209 |
cls setComponentClass: aJavaClass. |
|
210 |
cls setName: (aJavaClass name , '[]') asSymbol. |
|
211 |
"Kludge, spec says" "All methods of class Object may be invoked on an array." |
|
212 |
cls setMethodDictionary: (JavaVM classForName: 'java.lang.Object') |
|
213 |
methodDictionary. |
|
214 |
cls |
|
215 |
] |
|
216 |
" |
|
217 |
JavaArray javaArrayClassFor: Object |
|
218 |
" |
|
752 | 219 |
|
220 |
"Created: / 17-12-2010 / 13:45:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1511 | 221 |
"Modified: / 05-07-2012 / 23:23:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 222 |
! ! |
223 |
||
224 |
!JavaArray class methodsFor:'queries'! |
|
225 |
||
226 |
hasInterface:aJavaInterface |
|
227 |
"return true, if I respond to all methods as |
|
228 |
aJavaInterface" |
|
229 |
||
230 |
^false |
|
231 |
||
232 |
"Modified: / 19-12-2010 / 16:45:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
233 |
! |
|
234 |
||
235 |
isAbstract |
|
236 |
"return true, if the receiver is abstract |
|
237 |
(i.e. may not have instances)" |
|
238 |
||
239 |
^ false |
|
240 |
||
241 |
"Modified: / 19-12-2010 / 16:45:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
242 |
! |
|
243 |
||
244 |
isFinal |
|
245 |
"return true, if the receiver is final |
|
246 |
(i.e. may not be subclassed)" |
|
247 |
||
248 |
^ false |
|
249 |
||
250 |
"Modified: / 19-12-2010 / 16:45:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
251 |
! |
|
252 |
||
253 |
isInitialized |
|
254 |
"return true, if the receiver is initialized" |
|
255 |
||
256 |
^ true |
|
257 |
||
258 |
"Modified: / 07-05-1998 / 12:23:54 / cg" |
|
259 |
"Modified: / 19-12-2010 / 16:45:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
260 |
! |
|
261 |
||
262 |
isInterface |
|
263 |
"return true, if the receiver is an interface" |
|
264 |
||
265 |
^ false |
|
266 |
||
267 |
"Modified: / 07-05-1998 / 12:23:39 / cg" |
|
268 |
"Modified: / 19-12-2010 / 16:45:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
269 |
! |
|
270 |
||
271 |
isJavaArrayClass |
|
272 |
||
273 |
^true |
|
274 |
||
275 |
"Created: / 19-12-2010 / 17:05:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
276 |
! |
|
277 |
||
278 |
isJavaReferenceType |
|
279 |
||
280 |
^true |
|
281 |
||
282 |
"Created: / 20-12-2010 / 21:58:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
283 |
! |
|
284 |
||
285 |
isJavaType |
|
286 |
||
287 |
^true |
|
288 |
||
289 |
"Created: / 20-12-2010 / 21:58:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
290 |
! |
|
291 |
||
292 |
isObsolete |
|
293 |
"return true, if the receiver is obsolete |
|
294 |
Java classes are never." |
|
295 |
||
296 |
^ false |
|
297 |
||
298 |
"Modified: / 07-08-1997 / 19:04:28 / cg" |
|
299 |
"Modified: / 19-12-2010 / 16:45:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
300 |
! |
|
301 |
||
302 |
isPublic |
|
303 |
"return true, if the receiver is public" |
|
304 |
||
305 |
^ true |
|
306 |
||
307 |
"Modified: / 19-12-2010 / 16:45:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
308 |
! |
|
309 |
||
310 |
isUnresolved |
|
311 |
||
312 |
^false |
|
313 |
||
314 |
"Created: / 21-12-2010 / 12:51:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
315 |
! ! |
|
316 |
||
317 |
!JavaArray class methodsFor:'documentation'! |
|
318 |
||
1864 | 319 |
version_HG |
320 |
||
321 |
^ '$Changeset: <not expanded> $' |
|
322 |
! |
|
323 |
||
752 | 324 |
version_SVN |
1864 | 325 |
^ '§Id§' |
752 | 326 |
! ! |