749
|
1 |
"
|
|
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:
|
|
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 |
|
|
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.
|
|
41 |
"
|
|
42 |
"{ Package: 'stx:libjava' }"
|
|
43 |
|
|
44 |
JavaByteCodeProcessorTests subclass:#JavaByteCodeDisassemblerTests
|
|
45 |
instanceVariableNames:''
|
|
46 |
classVariableNames:''
|
|
47 |
poolDictionaries:''
|
|
48 |
category:'Languages-Java-Tests'
|
|
49 |
!
|
|
50 |
|
|
51 |
!JavaByteCodeDisassemblerTests class methodsFor:'documentation'!
|
|
52 |
|
|
53 |
copyright
|
|
54 |
"
|
|
55 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
56 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
57 |
SWING Research Group, Czech Technical University in Prague
|
|
58 |
|
|
59 |
Parts of the code written by Claus Gittinger are under following
|
|
60 |
license:
|
|
61 |
|
|
62 |
This software is furnished under a license and may be used
|
|
63 |
only in accordance with the terms of that license and with the
|
|
64 |
inclusion of the above copyright notice. This software may not
|
|
65 |
be provided or otherwise made available to, or used by, any
|
|
66 |
other person. No title to or ownership of the software is
|
|
67 |
hereby transferred.
|
|
68 |
|
|
69 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
|
|
70 |
|
|
71 |
Permission is hereby granted, free of charge, to any person
|
|
72 |
obtaining a copy of this software and associated documentation
|
|
73 |
files (the 'Software'), to deal in the Software without
|
|
74 |
restriction, including without limitation the rights to use,
|
|
75 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
76 |
copies of the Software, and to permit persons to whom the
|
|
77 |
Software is furnished to do so, subject to the following
|
|
78 |
conditions:
|
|
79 |
|
|
80 |
The above copyright notice and this permission notice shall be
|
|
81 |
included in all copies or substantial portions of the Software.
|
|
82 |
|
|
83 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
84 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
85 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
86 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
87 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
88 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
89 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
90 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
91 |
|
|
92 |
[1] Code written at SWING Research Group contain a signature
|
|
93 |
of one of the above copright owners.
|
|
94 |
|
|
95 |
"
|
|
96 |
! !
|
|
97 |
|
|
98 |
!JavaByteCodeDisassemblerTests class methodsFor:'resources'!
|
|
99 |
|
|
100 |
resources
|
|
101 |
|
|
102 |
^ Array with: JavaInitializedResource with: JavaTestsResource.
|
|
103 |
|
|
104 |
"Created: / 15-03-2011 / 17:29:22 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
105 |
"Modified: / 16-03-2011 / 14:43:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
106 |
! !
|
|
107 |
|
|
108 |
!JavaByteCodeDisassemblerTests methodsFor:'tests'!
|
|
109 |
|
|
110 |
testAnd
|
|
111 |
| result |
|
|
112 |
self shouldnt:
|
|
113 |
[ result := self
|
|
114 |
invoke: #'and(II)I'
|
|
115 |
class: self loadSimpleMathJavaClass
|
|
116 |
args: #( 255 149 )]raise: Error.
|
|
117 |
|
|
118 |
"static method
|
|
119 |
|
|
120 |
0 iload_0
|
|
121 |
1 iload_1
|
|
122 |
2 iand
|
|
123 |
3 ireturn"
|
|
124 |
|
|
125 |
"Created: / 14-03-2011 / 17:02:09 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
126 |
"Modified: / 20-03-2011 / 21:49:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
127 |
!
|
|
128 |
|
|
129 |
testBitShiftLeft
|
|
130 |
| |
|
|
131 |
|
|
132 |
self shouldnt:
|
|
133 |
[ self
|
|
134 |
invoke: #'bitShiftLeft(II)I'
|
|
135 |
class: self loadSimpleMathJavaClass
|
|
136 |
args: #( 21 4 )]
|
|
137 |
raise: Error.
|
|
138 |
"static method
|
|
139 |
|
|
140 |
0 iload_0
|
|
141 |
1 iload_1
|
|
142 |
2 ishl
|
|
143 |
3 ireturn"
|
|
144 |
|
|
145 |
"Created: / 14-03-2011 / 16:56:49 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
146 |
"Modified: / 20-03-2011 / 21:50:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
147 |
!
|
|
148 |
|
|
149 |
testBitShiftRight
|
|
150 |
| |
|
|
151 |
|
|
152 |
self shouldnt:
|
|
153 |
[ self
|
|
154 |
invoke: #'bitShiftRight(II)I'
|
|
155 |
class: self loadSimpleMathJavaClass
|
|
156 |
args: #( 439 4 )]
|
|
157 |
raise: Error.
|
|
158 |
|
|
159 |
"static method
|
|
160 |
|
|
161 |
0 iload_0
|
|
162 |
1 iload_1
|
|
163 |
2 ishr
|
|
164 |
3 ireturn"
|
|
165 |
|
|
166 |
"Created: / 14-03-2011 / 16:57:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
167 |
"Modified: / 20-03-2011 / 21:50:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
168 |
!
|
|
169 |
|
|
170 |
testDec2
|
|
171 |
self shouldnt:
|
|
172 |
|
|
173 |
|
|
174 |
[ self
|
|
175 |
invoke: #'dec2(I)I'
|
|
176 |
class: self loadSimpleMathJavaClass
|
|
177 |
args: #( 3 ). ] raise: Error.
|
|
178 |
|
|
179 |
|
|
180 |
"static method
|
|
181 |
|
|
182 |
0 iinc 0 -1
|
|
183 |
3 iinc 0 -1
|
|
184 |
6 iload_0
|
|
185 |
7 ireturn"
|
|
186 |
|
|
187 |
"Created: / 14-03-2011 / 16:58:12 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
188 |
"Modified: / 20-03-2011 / 22:59:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
189 |
!
|
|
190 |
|
|
191 |
testDiv
|
|
192 |
| |
|
|
193 |
|
|
194 |
self shouldnt:
|
|
195 |
[ self
|
|
196 |
invoke: #'div(II)I'
|
|
197 |
class: self loadSimpleMathJavaClass
|
|
198 |
args: #( 101 10 ) ]
|
|
199 |
raise: Error.
|
|
200 |
|
|
201 |
"static method
|
|
202 |
|
|
203 |
0 iload_0
|
|
204 |
1 iload_1
|
|
205 |
2 irem
|
|
206 |
3 ireturn"
|
|
207 |
|
|
208 |
"Created: / 14-03-2011 / 16:54:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
209 |
"Modified: / 20-03-2011 / 21:51:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
210 |
!
|
|
211 |
|
|
212 |
testDivision
|
|
213 |
| |
|
|
214 |
|
|
215 |
self shouldnt:
|
|
216 |
[ self
|
|
217 |
invoke: #'division(II)I'
|
|
218 |
class: self loadSimpleMathJavaClass
|
|
219 |
args: #( 101 10 ) ]
|
|
220 |
raise: Error.
|
|
221 |
"static method
|
|
222 |
|
|
223 |
0 iload_0
|
|
224 |
1 iload_1
|
|
225 |
2 idiv
|
|
226 |
3 ireturn"
|
|
227 |
|
|
228 |
"Created: / 14-03-2011 / 16:57:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
229 |
"Modified: / 20-03-2011 / 21:51:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
230 |
!
|
|
231 |
|
|
232 |
testInc2
|
|
233 |
| |
|
|
234 |
|
|
235 |
self shouldnt:
|
|
236 |
[ self
|
|
237 |
invoke: #'inc2(I)I'
|
|
238 |
class: self loadSimpleMathJavaClass
|
|
239 |
args: #( 3 ) ]
|
|
240 |
raise: Error.
|
|
241 |
"static method
|
|
242 |
|
|
243 |
0 iinc 0 1
|
|
244 |
3 iinc 0 1
|
|
245 |
6 iload_0
|
|
246 |
7 ireturn"
|
|
247 |
|
|
248 |
"Created: / 14-03-2011 / 16:58:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
249 |
"Modified: / 20-03-2011 / 21:51:49 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
250 |
!
|
|
251 |
|
|
252 |
testInheritedMethodCall
|
|
253 |
self shouldnt: [
|
|
254 |
|
|
255 |
self
|
|
256 |
invoke: #'foo()Ljava/lang/String;'
|
|
257 |
class: self loadSimpleInheritingJavaClass
|
|
258 |
args: nil.
|
|
259 |
|
|
260 |
] raise: Error.
|
|
261 |
"0 ldc1 2 ['foo']
|
|
262 |
2 areturn"
|
|
263 |
|
|
264 |
"Created: / 14-03-2011 / 16:21:04 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
265 |
"Modified: / 20-03-2011 / 23:01:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
266 |
!
|
|
267 |
|
|
268 |
testJustLoadConstants
|
|
269 |
self shouldnt: [
|
|
270 |
|
|
271 |
self
|
|
272 |
invoke: #'justUseConstants()V'
|
|
273 |
class: self loadSimpleMathJavaClass
|
|
274 |
args: #().
|
|
275 |
|
|
276 |
] raise: Error.
|
|
277 |
"static method
|
|
278 |
|
|
279 |
0 lconst_0
|
|
280 |
1 lstore_0
|
|
281 |
2 lconst_1
|
|
282 |
3 lstore_2
|
|
283 |
4 fconst_0
|
|
284 |
5 fstore 4
|
|
285 |
7 fconst_1
|
|
286 |
8 fstore 5
|
|
287 |
10 fconst_2
|
|
288 |
11 fstore 6
|
|
289 |
13 dconst_0
|
|
290 |
14 dstore 7
|
|
291 |
16 dconst_1
|
|
292 |
17 dstore 9
|
|
293 |
19 return"
|
|
294 |
|
|
295 |
"Created: / 14-03-2011 / 17:05:22 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
296 |
"Modified: / 20-03-2011 / 23:02:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
297 |
!
|
|
298 |
|
|
299 |
testLookupSwitch
|
|
300 |
self shouldnt: [
|
|
301 |
|
|
302 |
self
|
|
303 |
invoke: #'switchInt(I)I'
|
|
304 |
class: self loadSwitchExamplesClass
|
|
305 |
receiver: self loadSwitchExamplesClass new
|
|
306 |
args: #( -1000 )
|
|
307 |
|
|
308 |
] raise: Error.
|
|
309 |
|
|
310 |
"Created: / 21-03-2011 / 13:51:49 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
311 |
"Modified: / 21-03-2011 / 15:12:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
312 |
!
|
|
313 |
|
|
314 |
testMultipy
|
|
315 |
self shouldnt:
|
|
316 |
[ self
|
|
317 |
invoke: #'multiply(II)I'
|
|
318 |
class: self loadSimpleMathJavaClass
|
|
319 |
args: (Array with: 20 with: 10)]
|
|
320 |
raise: Error.
|
|
321 |
|
|
322 |
"static method
|
|
323 |
|
|
324 |
0 iload_0
|
|
325 |
1 iload_1
|
|
326 |
2 imul
|
|
327 |
3 ireturn"
|
|
328 |
|
|
329 |
"Created: / 06-03-2011 / 14:17:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
330 |
"Modified: / 20-03-2011 / 21:53:07 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
331 |
!
|
|
332 |
|
|
333 |
testNegateInt
|
|
334 |
self shouldnt:
|
|
335 |
[ self
|
|
336 |
invoke: #'negateInt(I)I'
|
|
337 |
class: self loadSimpleMathJavaClass
|
|
338 |
args: #( 55 )]
|
|
339 |
raise: Error.
|
|
340 |
|
|
341 |
"0 iload_0
|
|
342 |
1 iconst_m1
|
|
343 |
2 ixor
|
|
344 |
3 ireturn"
|
|
345 |
|
|
346 |
"Created: / 14-03-2011 / 16:55:55 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
347 |
"Modified: / 20-03-2011 / 21:53:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
348 |
!
|
|
349 |
|
|
350 |
testOr
|
|
351 |
| |
|
|
352 |
|
|
353 |
self shouldnt:
|
|
354 |
[ self
|
|
355 |
invoke: #'or(II)I'
|
|
356 |
class: self loadSimpleMathJavaClass
|
|
357 |
args: #( 55 66 )]
|
|
358 |
raise: Error.
|
|
359 |
|
|
360 |
"0 iload_0
|
|
361 |
1 iload_1
|
|
362 |
2 ior
|
|
363 |
3 ireturn"
|
|
364 |
|
|
365 |
"Created: / 14-03-2011 / 17:02:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
366 |
"Modified: / 20-03-2011 / 21:53:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
367 |
!
|
|
368 |
|
|
369 |
testOverridenMethodCall
|
|
370 |
self shouldnt:
|
|
371 |
[ self
|
|
372 |
invoke: #'bar()Ljava/lang/String;'
|
|
373 |
class: self loadSimpleInheritingJavaClass
|
|
374 |
args: nil.]
|
|
375 |
raise: Error.
|
|
376 |
|
|
377 |
"0 ldc1 2 ['bar']
|
|
378 |
2 areturn"
|
|
379 |
|
|
380 |
"Modified: / 20-03-2011 / 21:53:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
381 |
!
|
|
382 |
|
|
383 |
testPower
|
|
384 |
self shouldnt:
|
|
385 |
[ self
|
|
386 |
invoke: #'power(II)I'
|
|
387 |
class: self loadSimpleMathJavaClass
|
|
388 |
args: (Array with: 2 with: 10)]
|
|
389 |
raise: Error.
|
|
390 |
|
|
391 |
"0 iload_0
|
|
392 |
1 iload_1
|
|
393 |
2 iconst_1
|
|
394 |
3 invokestatic 2 [JavaMethod(stx.libjava.tests.simpleClasses.SimpleMath::int powerAcc (int int int))]
|
|
395 |
6 ireturn"
|
|
396 |
|
|
397 |
"Created: / 06-03-2011 / 14:18:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
398 |
"Modified: / 20-03-2011 / 21:54:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
399 |
!
|
|
400 |
|
|
401 |
testReturnArrayOfLongs
|
|
402 |
|
|
403 |
|
|
404 |
self shouldnt:
|
|
405 |
[ self
|
|
406 |
invoke: #'giveMeArrayOfLongs()[J'
|
|
407 |
class: self loadSimpleMathJavaClass
|
|
408 |
args: #(). ]
|
|
409 |
raise: Error.
|
|
410 |
|
|
411 |
"0 bipush 100
|
|
412 |
2 newarray 11 [T_LONG]
|
|
413 |
4 areturn"
|
|
414 |
|
|
415 |
"Created: / 14-03-2011 / 17:08:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
416 |
"Modified: / 20-03-2011 / 21:54:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
417 |
!
|
|
418 |
|
|
419 |
testSimpleAdd
|
|
420 |
self shouldnt:
|
|
421 |
[ self
|
|
422 |
invoke: #'add2To2000Expect2002()I'
|
|
423 |
class: self loadSimpleMathJavaClass
|
|
424 |
args: nil ]
|
|
425 |
raise: Error.
|
|
426 |
|
|
427 |
"static method
|
|
428 |
|
|
429 |
0 iconst_2
|
|
430 |
1 istore_0
|
|
431 |
2 sipush 2000
|
|
432 |
5 istore_1
|
|
433 |
6 iload_0
|
|
434 |
7 iload_1
|
|
435 |
8 iadd
|
|
436 |
9 istore_2
|
|
437 |
10 iload_2
|
|
438 |
11 ireturn"
|
|
439 |
|
|
440 |
"Created: / 06-03-2011 / 14:18:09 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
441 |
"Modified: / 20-03-2011 / 21:55:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
442 |
!
|
|
443 |
|
|
444 |
testSimpleAdd2
|
|
445 |
self shouldnt:
|
|
446 |
[ self
|
|
447 |
invoke: #'addMinus5ToArg(I)I'
|
|
448 |
class: self loadSimpleMathJavaClass
|
|
449 |
args: (Array with: 10) ]
|
|
450 |
raise: Error.
|
|
451 |
|
|
452 |
"static method
|
|
453 |
|
|
454 |
0 iload_0
|
|
455 |
1 bipush -5
|
|
456 |
3 iadd
|
|
457 |
4 ireturn"
|
|
458 |
|
|
459 |
"Created: / 06-03-2011 / 14:18:14 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
460 |
"Modified: / 20-03-2011 / 21:55:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
461 |
!
|
|
462 |
|
|
463 |
testStackCreation
|
|
464 |
self shouldnt:
|
|
465 |
[ self
|
|
466 |
invoke: #'isYourStackCreatedCorrectly()I'
|
|
467 |
class: self loadSimpleMathJavaClass
|
|
468 |
args: #()]
|
|
469 |
raise: Error.
|
|
470 |
|
|
471 |
"0 iconst_0
|
|
472 |
1 istore_0
|
|
473 |
2 iconst_1
|
|
474 |
3 istore_1
|
|
475 |
4 iconst_2
|
|
476 |
5 istore_0
|
|
477 |
6 iconst_3
|
|
478 |
7 istore_1
|
|
479 |
8 iconst_4
|
|
480 |
9 istore_0
|
|
481 |
10 iconst_5
|
|
482 |
11 istore_0
|
|
483 |
12 bipush 6
|
|
484 |
14 istore_1
|
|
485 |
15 bipush 7
|
|
486 |
17 istore_0
|
|
487 |
18 bipush 8
|
|
488 |
20 istore_1
|
|
489 |
21 bipush 9
|
|
490 |
23 istore_1
|
|
491 |
24 iload_0
|
|
492 |
25 ireturn"
|
|
493 |
|
|
494 |
"Created: / 14-03-2011 / 17:03:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
495 |
"Modified: / 20-03-2011 / 21:55:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
496 |
!
|
|
497 |
|
|
498 |
testSumArray
|
|
499 |
self shouldnt: [
|
|
500 |
|
|
501 |
self
|
|
502 |
invoke: #'sumArray([I)I'
|
|
503 |
class: self loadSimpleMathJavaClass
|
|
504 |
args: #( #(1 2 3 4 5) )
|
|
505 |
|
|
506 |
] raise: Error.
|
|
507 |
"
|
|
508 |
Decompiled source:
|
|
509 |
Static method
|
|
510 |
0 iconst_0
|
|
511 |
1 istore_1
|
|
512 |
2 iconst_0
|
|
513 |
3 istore_2
|
|
514 |
4 iload_2
|
|
515 |
5 aload_0
|
|
516 |
6 arraylength
|
|
517 |
7 if_icmpge 15 [22]
|
|
518 |
10 iload_1
|
|
519 |
11 aload_0
|
|
520 |
12 iload_2
|
|
521 |
13 iaload
|
|
522 |
14 iadd
|
|
523 |
15 istore_1
|
|
524 |
16 iinc 2 1
|
|
525 |
19 goto -15 [4]
|
|
526 |
22 iload_1
|
|
527 |
23 ireturn"
|
|
528 |
|
|
529 |
"Created: / 14-03-2011 / 17:06:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
530 |
"Modified: / 20-03-2011 / 23:05:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
531 |
!
|
|
532 |
|
|
533 |
testSumArrayOfDoubles
|
|
534 |
self shouldnt:
|
|
535 |
[self
|
|
536 |
invoke: #'sumArrayOfDoubles([D)D'
|
|
537 |
class: self loadSimpleMathJavaClass
|
|
538 |
args: #( #(1.1 2.2 3.3 4.4 5.5) ) ]
|
|
539 |
raise: Error.
|
|
540 |
"0 dconst_0
|
|
541 |
1 dstore_1
|
|
542 |
2 iconst_0
|
|
543 |
3 istore_3
|
|
544 |
4 iload_3
|
|
545 |
5 aload_0
|
|
546 |
6 arraylength
|
|
547 |
7 if_icmpge 15 [22]
|
|
548 |
10 dload_1
|
|
549 |
11 aload_0
|
|
550 |
12 iload_3
|
|
551 |
13 daload
|
|
552 |
14 dadd
|
|
553 |
15 dstore_1
|
|
554 |
16 iinc 3 1
|
|
555 |
19 goto -15 [4]
|
|
556 |
22 dload_1
|
|
557 |
23 dreturn"
|
|
558 |
|
|
559 |
"Created: / 14-03-2011 / 17:07:27 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
560 |
"Modified: / 20-03-2011 / 21:55:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
561 |
!
|
|
562 |
|
|
563 |
testTableSwitch
|
|
564 |
self shouldnt: [
|
|
565 |
|
|
566 |
self
|
|
567 |
invoke: #'switchChar(C)I'
|
|
568 |
class: self loadSwitchExamplesClass
|
|
569 |
receiver: self loadSwitchExamplesClass new
|
|
570 |
args: #( $b ).
|
|
571 |
|
|
572 |
] raise: Error.
|
|
573 |
|
|
574 |
"Created: / 21-03-2011 / 13:51:25 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
575 |
"Modified: / 21-03-2011 / 15:02:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
576 |
!
|
|
577 |
|
|
578 |
testUnsignedBitShiftLeft
|
|
579 |
self shouldnt:
|
|
580 |
[ self
|
|
581 |
invoke: #'unsignedBitShiftRight(II)I'
|
|
582 |
class: self loadSimpleMathJavaClass
|
|
583 |
args: #( 1234 5 ) ]
|
|
584 |
raise: Error.
|
|
585 |
|
|
586 |
"0 iload_0
|
|
587 |
1 iload_1
|
|
588 |
2 iushr
|
|
589 |
3 ireturn"
|
|
590 |
|
|
591 |
"Created: / 14-03-2011 / 17:01:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
592 |
"Modified: / 20-03-2011 / 21:56:12 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
593 |
!
|
|
594 |
|
|
595 |
testXor
|
|
596 |
self shouldnt:
|
|
597 |
[ self
|
|
598 |
invoke: #'xor(II)I'
|
|
599 |
class: self loadSimpleMathJavaClass
|
|
600 |
args: #( 1234 5 )]
|
|
601 |
raise: Error.
|
|
602 |
|
|
603 |
"0 iload_0
|
|
604 |
1 iload_1
|
|
605 |
2 ixor
|
|
606 |
3 ireturn"
|
|
607 |
|
|
608 |
"Modified: / 06-03-2011 / 15:11:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
609 |
"Created: / 14-03-2011 / 17:02:40 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
610 |
"Modified: / 20-03-2011 / 21:56:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
611 |
! !
|
|
612 |
|
|
613 |
!JavaByteCodeDisassemblerTests methodsFor:'tests - manual'!
|
|
614 |
|
|
615 |
diassembleAll
|
|
616 |
| fails |
|
|
617 |
|
|
618 |
fails := OrderedCollection new.
|
|
619 |
JavaMethod allSubInstances do:
|
|
620 |
[:method |
|
|
621 |
method isNative
|
|
622 |
ifFalse:
|
|
623 |
[ [ JavaByteCodeDisassembler new diassemble: method to: String new writeStream ]
|
|
624 |
on: Error
|
|
625 |
do: [ fails add: method ] ] ].
|
|
626 |
fails size ~~ 0
|
|
627 |
ifTrue: [ self error: 'Some java methods failed to disassemble' ].
|
|
628 |
|
|
629 |
"
|
|
630 |
JavaByteCodeDisassemblerTests new diassembleAll"
|
|
631 |
|
|
632 |
"Created: / 21-03-2011 / 21:13:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
633 |
"Modified: / 22-03-2011 / 21:05:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
634 |
"Modified: / 23-03-2011 / 16:54:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
635 |
! !
|
|
636 |
|
|
637 |
!JavaByteCodeDisassemblerTests methodsFor:'tests-helpers'!
|
|
638 |
|
|
639 |
invoke:methodName class:aClass receiver:receiver args:args
|
|
640 |
|method result|
|
|
641 |
|
|
642 |
method := aClass lookupMethodFor:methodName.
|
|
643 |
result := JavaByteCodeDisassembler diassemble:method.
|
|
644 |
|
|
645 |
"Created: / 10-03-2011 / 23:30:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
646 |
"Modified: / 20-03-2011 / 17:42:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
647 |
"Modified: / 22-03-2011 / 21:05:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
648 |
! !
|
|
649 |
|
|
650 |
!JavaByteCodeDisassemblerTests methodsFor:'tests2'!
|
|
651 |
|
|
652 |
testGetBoolean
|
|
653 |
|
|
654 |
self
|
|
655 |
invoke: #'getBoolean()Z'
|
|
656 |
class: self loadSimpleClassWithManyReferences
|
|
657 |
receiver: self loadSimpleClassWithManyReferences new
|
|
658 |
args: nil.
|
|
659 |
|
|
660 |
"
|
|
661 |
Deassembling getBoolean
|
|
662 |
1: ALOAD_0 (42) ARGS: [] STACK: [.. -> FIELD 0: stx.libjava.tests.simpleClasses.SimpleClassWithManyReferences]
|
|
663 |
2: GETFIELD (180) ARGS: [JavaFieldRef (stx.libjava.tests.simpleClasses.SimpleClassWithManyReferences 'values'[Ljava/lang/Object; offs=1)] STACK: [objectRef -> objectRef]
|
|
664 |
5: BIPUSH (16) ARGS: [9] STACK: [.. -> value]
|
|
665 |
7: AALOAD (50) ARGS: [] STACK: [arrayRef, index -> value]
|
|
666 |
8: CHECKCAST (192) ARGS: [java.lang.Boolean] STACK: [objectRef -> objectRef]
|
|
667 |
11: INVVIRT (182) ARGS: [JavaMethodRef (java.lang.Boolean 'booleanValue'()Z)] STACK: [objectRef, [arg1, arg2, ...] -> ..]
|
|
668 |
14: IRETURN (172) ARGS: [] STACK: [value -> EMPTY]
|
|
669 |
"
|
|
670 |
|
|
671 |
"Created: / 14-03-2011 / 21:36:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
672 |
"Modified: / 22-03-2011 / 16:06:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
673 |
!
|
|
674 |
|
|
675 |
testGetByte
|
|
676 |
self shouldnt:[ self
|
|
677 |
invoke: #'getByte()B'
|
|
678 |
class: self loadSimpleClassWithManyReferences
|
|
679 |
receiver: self loadSimpleClassWithManyReferences new
|
|
680 |
args: nil] raise: Error.
|
|
681 |
|
|
682 |
"0 aload_0
|
|
683 |
1 getfield 3 [JavaFieldRef (stx.libjava.tests.simpleClasses.SimpleClassWithManyReferences 'values'[Ljava/lang/Object; offs=1)]
|
|
684 |
4 bipush 7
|
|
685 |
6 aaload
|
|
686 |
7 checkcast 17 [java.lang.Byte]
|
|
687 |
10 invokevirtual 31 [JavaMethodRef (java.lang.Byte 'byteValue'()B)]
|
|
688 |
13 ireturn"
|
|
689 |
|
|
690 |
"Created: / 14-03-2011 / 21:34:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
691 |
"Modified: / 21-03-2011 / 15:38:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
692 |
!
|
|
693 |
|
|
694 |
testGetChar
|
|
695 |
self shouldnt:[ self
|
|
696 |
invoke: #'getChar()C'
|
|
697 |
class: self loadSimpleClassWithManyReferences
|
|
698 |
receiver: self loadSimpleClassWithManyReferences new
|
|
699 |
args: nil] raise: Error.
|
|
700 |
|
|
701 |
"0 aload_0
|
|
702 |
1 getfield 3 [JavaFieldRef (stx.libjava.tests.simpleClasses.SimpleClassWithManyReferences 'values'[Ljava/lang/Object; offs=1)]
|
|
703 |
4 iconst_3
|
|
704 |
5 aaload
|
|
705 |
6 checkcast 25 [java.lang.Character]
|
|
706 |
9 invokevirtual 26 [JavaMethodRef (java.lang.Character 'charValue'()C)]
|
|
707 |
12 ireturn"
|
|
708 |
|
|
709 |
"Created: / 14-03-2011 / 21:31:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
710 |
"Modified: / 21-03-2011 / 15:39:09 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
711 |
!
|
|
712 |
|
|
713 |
testGetDateArray
|
|
714 |
self shouldnt:[ self
|
|
715 |
invoke: #'getDateArray()[Ljava/util/Date;'
|
|
716 |
class: self loadSimpleClassWithManyReferences
|
|
717 |
receiver: self loadSimpleClassWithManyReferences new
|
|
718 |
args: nil] raise: Error.
|
|
719 |
|
|
720 |
"0 aload_0
|
|
721 |
1 getfield 3 [JavaFieldRef (stx.libjava.tests.simpleClasses.SimpleClassWithManyReferences 'values'[Ljava/lang/Object; offs=1)]
|
|
722 |
4 bipush 8
|
|
723 |
6 aaload
|
|
724 |
7 checkcast 32 [UnresolvedClass([Ljava.util.Date;)]
|
|
725 |
10 checkcast 32 [UnresolvedClass([Ljava.util.Date;)]
|
|
726 |
13 areturn"
|
|
727 |
|
|
728 |
"Created: / 14-03-2011 / 21:35:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
729 |
"Modified: / 21-03-2011 / 15:39:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
730 |
!
|
|
731 |
|
|
732 |
testGetDouble
|
|
733 |
self shouldnt:[ self
|
|
734 |
invoke: #'getDouble()Ljava/lang/Double;'
|
|
735 |
class: self loadSimpleClassWithManyReferences
|
|
736 |
receiver: self loadSimpleClassWithManyReferences new
|
|
737 |
args: nil] raise: Error.
|
|
738 |
|
|
739 |
"0 aload_0
|
|
740 |
1 getfield 3 [JavaFieldRef (stx.libjava.tests.simpleClasses.SimpleClassWithManyReferences 'values'[Ljava/lang/Object; offs=1)]
|
|
741 |
4 iconst_2
|
|
742 |
5 aaload
|
|
743 |
6 checkcast 24 [java.lang.Double]
|
|
744 |
9 areturn"
|
|
745 |
|
|
746 |
"Created: / 14-03-2011 / 21:30:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
747 |
"Modified: / 21-03-2011 / 15:39:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
748 |
!
|
|
749 |
|
|
750 |
testGetInt
|
|
751 |
self shouldnt:[ self
|
|
752 |
invoke: #'getInt()I'
|
|
753 |
class: self loadSimpleClassWithManyReferences
|
|
754 |
receiver: self loadSimpleClassWithManyReferences new
|
|
755 |
args: nil] raise: Error.
|
|
756 |
|
|
757 |
"0 aload_0
|
|
758 |
1 getfield 3 [JavaFieldRef (stx.libjava.tests.simpleClasses.SimpleClassWithManyReferences 'values'[Ljava/lang/Object; offs=1)]
|
|
759 |
4 iconst_1
|
|
760 |
5 aaload
|
|
761 |
6 checkcast 13 [java.lang.Integer]
|
|
762 |
9 invokevirtual 23 [JavaMethodRef (java.lang.Integer 'intValue'()I)]
|
|
763 |
12 ireturn"
|
|
764 |
|
|
765 |
"Created: / 14-03-2011 / 21:30:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
766 |
"Modified: / 21-03-2011 / 15:39:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
767 |
!
|
|
768 |
|
|
769 |
testGetIntArray
|
|
770 |
self shouldnt:[ self
|
|
771 |
invoke: #'getIntArray()[I'
|
|
772 |
class: self loadSimpleClassWithManyReferences
|
|
773 |
receiver: self loadSimpleClassWithManyReferences new
|
|
774 |
args: nil.
|
|
775 |
] raise: Error.
|
|
776 |
|
|
777 |
"0 aload_0
|
|
778 |
1 getfield 3 [JavaFieldRef (stx.libjava.tests.simpleClasses.SimpleClassWithManyReferences 'values'[Ljava/lang/Object; offs=1)]
|
|
779 |
4 iconst_5
|
|
780 |
5 aaload
|
|
781 |
6 checkcast 29 [JavaBuiltInClassPointerRef(class:IntegerArray ; name&type: '[I')]
|
|
782 |
9 checkcast 29 [JavaBuiltInClassPointerRef(class:IntegerArray ; name&type: '[I')]
|
|
783 |
12 areturn"
|
|
784 |
|
|
785 |
"Created: / 14-03-2011 / 21:33:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
786 |
"Modified: / 21-03-2011 / 15:40:12 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
787 |
!
|
|
788 |
|
|
789 |
testGetLong
|
|
790 |
self shouldnt:[ self
|
|
791 |
invoke: #'getLong()J'
|
|
792 |
class: self loadSimpleClassWithManyReferences
|
|
793 |
receiver: self loadSimpleClassWithManyReferences new
|
|
794 |
args: nil] raise: Error.
|
|
795 |
|
|
796 |
"0 aload_0
|
|
797 |
1 getfield 3 [JavaFieldRef (stx.libjava.tests.simpleClasses.SimpleClassWithManyReferences 'values'[Ljava/lang/Object; offs=1)]
|
|
798 |
4 iconst_4
|
|
799 |
5 aaload
|
|
800 |
6 checkcast 27 [java.lang.Long]
|
|
801 |
9 invokevirtual 28 [JavaMethodRef (java.lang.Long 'longValue'()J)]
|
|
802 |
12 lreturn"
|
|
803 |
|
|
804 |
"Created: / 14-03-2011 / 21:32:14 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
805 |
"Modified: / 21-03-2011 / 15:40:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
806 |
!
|
|
807 |
|
|
808 |
testGetShort
|
|
809 |
self shouldnt:[ self
|
|
810 |
invoke: #'getShort()S'
|
|
811 |
class: self loadSimpleClassWithManyReferences
|
|
812 |
receiver: self loadSimpleClassWithManyReferences new
|
|
813 |
args: nil] raise: Error.
|
|
814 |
|
|
815 |
"0 aload_0
|
|
816 |
1 getfield 3 [JavaFieldRef (stx.libjava.tests.simpleClasses.SimpleClassWithManyReferences 'values'[Ljava/lang/Object; offs=1)]
|
|
817 |
4 bipush 6
|
|
818 |
6 aaload
|
|
819 |
7 checkcast 14 [java.lang.Short]
|
|
820 |
10 invokevirtual 30 [JavaMethodRef (java.lang.Short 'shortValue'()S)]
|
|
821 |
13 ireturn"
|
|
822 |
|
|
823 |
"Created: / 14-03-2011 / 21:33:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
824 |
"Modified: / 21-03-2011 / 15:40:45 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
825 |
!
|
|
826 |
|
|
827 |
testGetString
|
|
828 |
self shouldnt:[ self
|
|
829 |
invoke: #'getString()Ljava/lang/String;'
|
|
830 |
class: self loadSimpleClassWithManyReferences
|
|
831 |
receiver: self loadSimpleClassWithManyReferences new
|
|
832 |
args: nil] raise: Error.
|
|
833 |
|
|
834 |
"0 aload_0
|
|
835 |
1 getfield 3 [JavaFieldRef (stx.libjava.tests.simpleClasses.SimpleClassWithManyReferences 'values'[Ljava/lang/Object; offs=1)]
|
|
836 |
4 iconst_0
|
|
837 |
5 aaload
|
|
838 |
6 checkcast 22 [java.lang.String]
|
|
839 |
9 areturn"
|
|
840 |
|
|
841 |
"Created: / 14-03-2011 / 21:27:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
842 |
"Modified: / 21-03-2011 / 15:40:55 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
843 |
!
|
|
844 |
|
|
845 |
testMultiBytePrintString
|
|
846 |
|badClass|
|
|
847 |
badClass := Java classForName: 'java.nio.charset.CharsetDecoder'.
|
|
848 |
|
|
849 |
|
|
850 |
self
|
|
851 |
invoke: #'<init>(Ljava/nio/charset/Charset;FF)V'
|
|
852 |
class: badClass
|
|
853 |
args: #( 21 4 ).
|
|
854 |
|
|
855 |
"Created: / 23-03-2011 / 16:58:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
856 |
!
|
|
857 |
|
|
858 |
testSetBoolean
|
|
859 |
self shouldnt: [
|
|
860 |
|
|
861 |
self
|
|
862 |
invoke: #'setBoolean(I)V'
|
|
863 |
class: self loadSimpleClassWithManyReferences
|
|
864 |
receiver: self loadSimpleClassWithManyReferences new
|
|
865 |
args: nil.
|
|
866 |
|
|
867 |
] raise: Error.
|
|
868 |
|
|
869 |
"Created: / 22-03-2011 / 12:17:12 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
870 |
! !
|
|
871 |
|
|
872 |
!JavaByteCodeDisassemblerTests class methodsFor:'documentation'!
|
|
873 |
|
|
874 |
version_SVN
|
2152
|
875 |
^ '$Id: JavaByteCodeDisassemblerTests.st,v 1.1 2011-08-18 19:06:53 vrany Exp $'
|
|
876 |
! !
|