author | hlopkmar |
Wed, 19 Oct 2011 16:18:27 +0000 | |
branch | jk_new_structure |
changeset 1026 | 5badd1d31864 |
parent 1025 | 2c9c84bdd863 |
child 1028 | d30cabc12354 |
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 |
Object subclass:#JavaClassReader |
|
45 |
instanceVariableNames:'inStream msb constants majorVsn minorVsn constNeeds2Slots |
|
775 | 46 |
constSlot classBeingLoaded' |
752 | 47 |
classVariableNames:'Verbose AnnotationsVerbose Silent AbsolutelySilent |
48 |
LazyClassLoading InvalidClassFormatSignal ClassLoaderQuerySignal |
|
877 | 49 |
JavaArchiveCache' |
752 | 50 |
poolDictionaries:'' |
51 |
category:'Languages-Java-Support' |
|
52 |
! |
|
53 |
||
54 |
!JavaClassReader class methodsFor:'documentation'! |
|
55 |
||
56 |
copyright |
|
57 |
" |
|
877 | 58 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
59 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
|
60 |
SWING Research Group, Czech Technical University in Prague |
|
61 |
||
62 |
Parts of the code written by Claus Gittinger are under following |
|
63 |
license: |
|
752 | 64 |
|
65 |
This software is furnished under a license and may be used |
|
66 |
only in accordance with the terms of that license and with the |
|
67 |
inclusion of the above copyright notice. This software may not |
|
68 |
be provided or otherwise made available to, or used by, any |
|
69 |
other person. No title to or ownership of the software is |
|
70 |
hereby transferred. |
|
877 | 71 |
|
72 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed: |
|
73 |
||
74 |
Permission is hereby granted, free of charge, to any person |
|
75 |
obtaining a copy of this software and associated documentation |
|
76 |
files (the 'Software'), to deal in the Software without |
|
77 |
restriction, including without limitation the rights to use, |
|
78 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
79 |
copies of the Software, and to permit persons to whom the |
|
80 |
Software is furnished to do so, subject to the following |
|
81 |
conditions: |
|
82 |
||
83 |
The above copyright notice and this permission notice shall be |
|
84 |
included in all copies or substantial portions of the Software. |
|
85 |
||
86 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
87 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
88 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
89 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
90 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
91 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
92 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
93 |
OTHER DEALINGS IN THE SOFTWARE. |
|
94 |
||
95 |
[1] Code written at SWING Research Group contain a signature |
|
96 |
of one of the above copright owners. |
|
97 |
||
752 | 98 |
" |
99 |
! ! |
|
100 |
||
101 |
!JavaClassReader class methodsFor:'initialization'! |
|
102 |
||
103 |
initialize |
|
104 |
InvalidClassFormatSignal := Signal new mayProceed: true. |
|
105 |
InvalidClassFormatSignal notifierString: 'class load failure'. |
|
106 |
InvalidClassFormatSignal nameClass: self message: #invalidClassFormatSignal. |
|
107 |
Verbose := false. |
|
108 |
Silent := true. |
|
109 |
AbsolutelySilent := false. |
|
110 |
||
111 |
"/LazyClassLoading := false. |
|
112 |
||
113 |
LazyClassLoading := true. |
|
114 |
ClassLoaderQuerySignal := QuerySignal new. |
|
115 |
JavaArchiveCache := CacheDictionary new: 32. |
|
116 |
AnnotationsVerbose := false. |
|
771 | 117 |
|
752 | 118 |
" |
119 |
JavaClassReader initialize" |
|
120 |
||
121 |
"Modified: / 27-01-1998 / 17:54:23 / cg" |
|
122 |
"Modified: / 17-12-2010 / 17:37:45 / Marcel Hlopko <hlopik@gmail.com>" |
|
772
0f92c23b80ee
testing new project structure + fixing tiny litle bug which caused java not to work at all :)
hlopkmar
parents:
771
diff
changeset
|
123 |
"Modified: / 10-05-2011 / 23:59:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
877 | 124 |
"Modified: / 26-07-2011 / 17:21:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 125 |
! ! |
126 |
||
127 |
!JavaClassReader class methodsFor:'Signal constants'! |
|
128 |
||
129 |
classLoaderQuerySignal |
|
130 |
^ ClassLoaderQuerySignal |
|
131 |
||
132 |
"Created: 14.8.1997 / 19:56:03 / cg" |
|
133 |
! |
|
134 |
||
135 |
invalidClassFormatSignal |
|
136 |
^ InvalidClassFormatSignal |
|
137 |
||
138 |
"Created: 3.8.1997 / 18:17:21 / cg" |
|
139 |
! ! |
|
140 |
||
141 |
!JavaClassReader class methodsFor:'constants'! |
|
142 |
||
143 |
fileMajorVersions |
|
831 | 144 |
^#( |
145 |
46 "Java 1.2" |
|
920 | 146 |
47 "???" |
147 |
48 "???" |
|
831 | 148 |
49 "Java 5" |
149 |
50 "Java 6" |
|
150 |
). |
|
151 |
||
152 |
" |
|
153 |
JSR 202: |
|
154 |
The Java virtual machine implementation of Sun's JDK release 1.0.2 supports |
|
155 |
class file format versions 45.0 through 45.3 inclusive. Sun's JDK releases |
|
156 |
1.1.X can support class file formats of versions in the range 45.0 through |
|
157 |
45.65535 inclusive. For k > 1 implementations of version 1.k of the Java 2 |
|
158 |
platform can support class file formats of versions in the range 45.0 through |
|
159 |
44+k.0 inclusive. |
|
160 |
" |
|
752 | 161 |
|
162 |
"Created: / 19-10-2010 / 21:40:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
830
235c482b462f
- JavaClassReader: do not want about .class file version 50.0
vranyj1
parents:
828
diff
changeset
|
163 |
"Modified: / 01-06-2011 / 21:44:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
831 | 164 |
"Modified: / 02-06-2011 / 22:50:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
920 | 165 |
"Modified: / 18-08-2011 / 19:32:37 / jv" |
752 | 166 |
! |
167 |
||
168 |
fileMinorVersions |
|
169 |
^ #( |
|
170 |
3 "Java 1.2" |
|
171 |
0 "Java 6" |
|
172 |
) |
|
173 |
||
174 |
"Created: / 19-10-2010 / 21:41:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
175 |
! |
|
176 |
||
177 |
magic_LSB |
|
178 |
^ 16rBEBAFECA |
|
179 |
||
180 |
"Modified: / 7.5.1998 / 13:14:27 / cg" |
|
181 |
"Created: / 7.5.1998 / 13:15:05 / cg" |
|
182 |
! |
|
183 |
||
184 |
magic_MSB |
|
185 |
^ 16rCAFEBABE |
|
186 |
||
187 |
"Modified: / 7.5.1998 / 13:14:27 / cg" |
|
188 |
! ! |
|
189 |
||
190 |
!JavaClassReader class methodsFor:'debugging'! |
|
191 |
||
192 |
annotationsVerbose:aBoolean |
|
193 |
AnnotationsVerbose := aBoolean |
|
194 |
||
195 |
" |
|
196 |
Java flushClasses. |
|
197 |
JavaClassReader verbose:true |
|
198 |
JavaClassReader verbose:false" |
|
199 |
||
200 |
"Created: / 25-02-2011 / 12:25:23 / Marcel Hlopko <hlopik@gmail.com>" |
|
201 |
! |
|
202 |
||
203 |
verbose:aBoolean |
|
204 |
Verbose := aBoolean |
|
205 |
||
206 |
" |
|
207 |
Java flushClasses. |
|
208 |
JavaClassReader verbose:true |
|
209 |
JavaClassReader verbose:false |
|
210 |
" |
|
211 |
! ! |
|
212 |
||
213 |
!JavaClassReader class methodsFor:'file reading'! |
|
214 |
||
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
215 |
readClass: aClassName |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
216 |
"reads a class, and returns it. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
217 |
<clinit> is called, class is not installed" |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
218 |
|
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
219 |
^ self readClass: aClassName ignoring: Set new. |
752 | 220 |
|
960 | 221 |
"Created: / 15-04-1996 / 14:58:53 / cg" |
222 |
"Modified: / 20-10-1998 / 17:24:54 / cg" |
|
992 | 223 |
"Modified: / 08-09-2011 / 08:10:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 224 |
! |
225 |
||
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
226 |
readClass: className ignoring: classesBeingLoadedOrNil |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
227 |
"reads a class, and returns it. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
228 |
<clinit> is called, class is not installed |
752 | 229 |
|
1021
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
230 |
className expected format: |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
231 |
foo.bar.Baz - normal class |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
232 |
foo/bar/Baz - alternative format |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
233 |
[[Lfoo/bar/Baz; - array |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
234 |
[[I - primitive array" |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
235 |
|
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
236 |
| rslt clsName cls classesBeingLoaded | |
1021
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
237 |
|
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
238 |
(JavaDescriptor isJavaPrimitiveArrayName: className) ifTrue: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
239 |
^ (JavaDescriptor fromString: className) javaClass. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
240 |
]. |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
241 |
(cls := Java javaRegistry at: clsName) ifNotNil: [ ^ cls. ]. |
1021
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
242 |
clsName := self getCleanClassNameFrom: className. |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
243 |
(classesBeingLoadedOrNil notNil |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
244 |
and: [ classesBeingLoadedOrNil includes: clsName ]) |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
245 |
ifTrue: [ self halt: 'recursive load - should not happen'. ]. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
246 |
classesBeingLoadedOrNil isNil ifTrue: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
247 |
classesBeingLoaded := Set with: clsName |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
248 |
] ifFalse: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
249 |
classesBeingLoaded := classesBeingLoadedOrNil |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
250 |
add: clsName; |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
251 |
yourself. |
1021
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
252 |
]. |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
253 |
Java effectiveClassPath do: [ |
1021
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
254 |
:path | |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
255 |
| nm p zar entry zipFile read | |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
256 |
|
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
257 |
p := path. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
258 |
p asFilename isDirectory ifTrue: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
259 |
(p endsWith: Filename separator) ifFalse: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
260 |
p := p , (Filename separator asString) |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
261 |
]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
262 |
(Array |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
263 |
with: clsName |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
264 |
with: clsName asLowercase |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
265 |
with: clsName asUppercase) |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
266 |
do: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
267 |
:tryName | |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
268 |
nm := p , tryName , '.class'. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
269 |
nm asFilename exists ifTrue: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
270 |
(Java isExcludedFromClassPath: nm) ifFalse: [ |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
271 |
self breakPoint:#mh. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
272 |
"means we are successfully going to read something :)" |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
273 |
rslt := self readFile: nm ignoring: classesBeingLoaded. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
274 |
rslt notNil ifTrue: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
275 |
^ rslt. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
276 |
]. |
1021
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
277 |
] |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
278 |
]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
279 |
] |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
280 |
] ifFalse: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
281 |
((zipFile := p asFilename withSuffix: 'jar') exists |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
282 |
or: [ (zipFile := p asFilename withSuffix: 'zip') exists ]) |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
283 |
ifTrue: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
284 |
zar := JavaArchiveCache at: zipFile |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
285 |
ifAbsentPut: [ ZipArchive oldFileNamed: zipFile ]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
286 |
read := [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
287 |
nm := clsName , '.class'. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
288 |
entry := zar extract: nm. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
289 |
entry notNil ifTrue: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
290 |
(Java isExcludedFromClassPath: nm) ifFalse: [ |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
291 |
rslt := self readStream: (entry readStream) ignoring: classesBeingLoaded. |
1021
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
292 |
rslt notNil ifTrue: [ ^ rslt ]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
293 |
] |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
294 |
] |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
295 |
]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
296 |
JavaClassReader invalidClassFormatSignal |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
297 |
handle: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
298 |
"Kludge, sometimes zar gets corrupted" |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
299 |
zar := JavaArchiveCache at: zipFile put: (ZipArchive oldFileNamed: zipFile). |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
300 |
read value |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
301 |
] |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
302 |
do: [ read value ]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
303 |
] |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
304 |
] |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
305 |
]. |
752 | 306 |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
307 |
|
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
308 |
"Created: / 15-04-1996 / 14:58:53 / cg" |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
309 |
"Modified: / 20-10-1998 / 17:24:54 / cg" |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
310 |
"Modified: / 08-09-2011 / 08:10:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 311 |
! |
312 |
||
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
313 |
readFile: aFilename ignoring: classesBeingLoaded |
752 | 314 |
"reads a class from aFilename and returns it. |
315 |
The JavaClass is NOT installed as global and unresolved |
|
316 |
refs are NOT patched." |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
317 |
|
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
318 |
| inStream javaClass | |
752 | 319 |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
320 |
[ inStream := aFilename asFilename readStream. ] on: StreamError |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
321 |
do: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
322 |
:ex | |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
323 |
Logger |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
324 |
log: ('no file: ' , aFilename asString) |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
325 |
severity: #error |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
326 |
facility: 'JVM'. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
327 |
self halt. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
328 |
^ nil |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
329 |
]. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
330 |
javaClass := self readStream: inStream ignoring: classesBeingLoaded. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
331 |
(javaClass notNil and: [ javaClass isJavaClass ]) ifTrue: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
332 |
javaClass setBinaryFilePath: (inStream pathName). |
752 | 333 |
]. |
334 |
inStream close. |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
335 |
AbsolutelySilent ifFalse: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
336 |
Logger |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
337 |
log: 'loaded class ' , javaClass displayString |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
338 |
severity: #info |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
339 |
facility: 'JVM'. |
752 | 340 |
]. |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
341 |
^ javaClass. |
752 | 342 |
|
898 | 343 |
"Created: / 15-04-1996 / 14:58:53 / cg" |
344 |
"Modified: / 09-05-1998 / 01:44:24 / cg" |
|
1000 | 345 |
"Modified: / 14-09-2011 / 22:20:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 346 |
! |
347 |
||
771 | 348 |
readStream: aStream ignoring: classesBeingLoaded |
752 | 349 |
"reads a class from aStream and returns it. |
350 |
The JavaClass is not installed as global" |
|
771 | 351 |
|
352 |
| javaClass | |
|
353 |
||
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
354 |
javaClass := JavaClassReader new readStream: aStream |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
355 |
ignoring: classesBeingLoaded. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
356 |
Logger |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
357 |
log: 'loaded class ' , javaClass displayString |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
358 |
severity: #info |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
359 |
facility: 'JVM'. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
360 |
^ javaClass. |
752 | 361 |
|
771 | 362 |
"Modified: / 30-03-1998 / 18:14:40 / cg" |
363 |
"Modified: / 09-05-2011 / 23:15:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1000 | 364 |
"Modified: / 14-09-2011 / 22:21:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 365 |
! ! |
366 |
||
1021
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
367 |
!JavaClassReader class methodsFor:'helpers'! |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
368 |
|
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
369 |
getCleanClassNameFrom: className |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
370 |
| cleanClassName | |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
371 |
|
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
372 |
cleanClassName := className utf8Encoded. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
373 |
(cleanClassName matches: '*\[*') ifTrue: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
374 |
cleanClassName := cleanClassName |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
375 |
copyFrom: (cleanClassName lastIndexOf: $[) + 1 |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
376 |
to: cleanClassName size. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
377 |
]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
378 |
(cleanClassName startsWith:$L) ifTrue: [cleanClassName := cleanClassName copyFrom:2 to: cleanClassName size - 1]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
379 |
(cleanClassName endsWith: '[]') ifTrue: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
380 |
('oops - loading of ' , className , ' not supported') infoPrintCR. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
381 |
self halt: 'should not happen'. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
382 |
^ nil |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
383 |
]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
384 |
(cleanClassName includes: $.) ifTrue: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
385 |
cleanClassName := cleanClassName asString copyReplaceAll: $. with: $/ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
386 |
]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
387 |
^ cleanClassName. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
388 |
! |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
389 |
|
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
390 |
makeArrayOf: loadedJavaClass withDimensions: numOfDimensions |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
391 |
| arrayClass | |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
392 |
|
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
393 |
arrayClass := loadedJavaClass. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
394 |
numOfDimensions timesRepeat: [ arrayClass := arrayClass javaArrayClass. ]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
395 |
^ arrayClass. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
396 |
! ! |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
397 |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
398 |
!JavaClassReader class methodsFor:'obsolete'! |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
399 |
|
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
400 |
resolveClass: aJavaClass |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
401 |
"Resolve a particular classes' constants. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
402 |
Perform all class initialization functions |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
403 |
(of those which are not yet initialized)." |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
404 |
|
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
405 |
| loader classToLoad | |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
406 |
|
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
407 |
self breakPoint: #mh. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
408 |
"new resolving does not need this - shouldn't be called at all" |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
409 |
LazyClassLoading ifFalse: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
410 |
loader := (aJavaClass classLoader). |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
411 |
[ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
412 |
classToLoad := nil. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
413 |
aJavaClass constantPool do: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
414 |
:item | |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
415 |
| itemClass | |
771 | 416 |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
417 |
itemClass := item class. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
418 |
itemClass == JavaUnresolvedClassConstant ifTrue: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
419 |
classToLoad := item className. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
420 |
|
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
421 |
"/ ] ifFalse:[ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
422 |
"/ itemClass == JavaUnresolvedMethodrefConstant ifTrue:[ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
423 |
"/self halt. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
424 |
"/ ] ifFalse:[ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
425 |
"/ itemClass == JavaUnresolvedInterfaceMethodrefConstant ifTrue:[ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
426 |
"/self halt. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
427 |
"/ ] |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
428 |
"/ ] |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
429 |
]. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
430 |
]. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
431 |
classToLoad notNil ifTrue: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
432 |
loader isNil ifTrue: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
433 |
Java javaRegistry classForName: classToLoad. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
434 |
] ifFalse: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
435 |
"/ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
436 |
"/ the aquired loader is a javaClassLoader |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
437 |
"/ which expects an URL as arg. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
438 |
"/ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
439 |
"/ classURL := Java as_URL:('file:' , nextUnresolved asString , '.class'). |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
440 |
"/ loader loadClass:classURL |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
441 |
loader perform: #'loadClass(Ljava/lang/String;)Ljava/lang/Class;' |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
442 |
with: (Java as_String: (classToLoad asString)). |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
443 |
] |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
444 |
]. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
445 |
classToLoad notNil. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
446 |
] whileTrue. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
447 |
aJavaClass isInitialized ifFalse: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
448 |
Silent ifFalse: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
449 |
'performing class initialization of ' print. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
450 |
aJavaClass fullName printCR. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
451 |
]. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
452 |
aJavaClass classInit |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
453 |
]. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
454 |
] |
771 | 455 |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
456 |
"Created: / 20.10.1998 / 17:53:22 / cg" |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
457 |
"Modified: / 20.10.1998 / 17:59:09 / cg" |
771 | 458 |
! ! |
459 |
||
460 |
!JavaClassReader methodsFor:'accessing'! |
|
461 |
||
462 |
constants |
|
463 |
^ constants. |
|
464 |
||
465 |
"Created: / 10-05-2011 / 13:48:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
466 |
! |
|
467 |
||
468 |
constants: aJavaConstantPool |
|
469 |
constants := aJavaConstantPool. |
|
470 |
||
471 |
"Created: / 10-05-2011 / 13:48:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
472 |
! |
|
473 |
||
474 |
stream |
|
475 |
^ inStream. |
|
476 |
||
477 |
"Created: / 09-05-2011 / 23:22:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
478 |
! |
|
479 |
||
480 |
stream:aReadStream |
|
481 |
inStream := aReadStream. |
|
482 |
||
483 |
"Created: / 09-05-2011 / 23:23:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
484 |
! ! |
|
485 |
||
752 | 486 |
!JavaClassReader methodsFor:'file reading'! |
487 |
||
771 | 488 |
readClassFileIgnoring: classesbeingLoaded |
752 | 489 |
"reads a class from inStream and returns it. |
490 |
The JavaClass is not installed as global and its constants |
|
491 |
(especially strings) may not be fully resolved." |
|
492 |
||
798
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
493 |
| magic access_flags this_class_index super_class super_class_index this_class_ref existingSuperClass fields interfaces staticFields nStatic superClassName thisClassName existing_class thisMetaClass | |
752 | 494 |
|
495 |
"/ |
|
496 |
"/ read magic, determine byte order |
|
497 |
"/ |
|
498 |
msb := true. |
|
771 | 499 |
magic := inStream nextUnsignedLongMSB: true. |
500 |
magic = (self class magic_MSB) |
|
501 |
ifFalse: |
|
502 |
[ magic = (self class magic_LSB) |
|
503 |
ifFalse: |
|
504 |
[ InvalidClassFormatSignal raiseErrorString: 'not a java class file'. |
|
505 |
^ nil ]. |
|
506 |
msb := false. |
|
507 |
Verbose ifTrue: [ Transcript showCR: 'file is lsb' ]. ] |
|
508 |
ifTrue: [ Verbose ifTrue: [ Transcript showCR: 'file is msb' ]. ]. |
|
752 | 509 |
|
510 |
"/ |
|
511 |
"/ get version |
|
512 |
"/ |
|
513 |
||
771 | 514 |
minorVsn := inStream nextUnsignedShortMSB: msb. |
515 |
majorVsn := inStream nextUnsignedShortMSB: msb. |
|
516 |
((self class fileMajorVersions includes: majorVsn) not |
|
517 |
or: [ (self class fileMinorVersions includes: minorVsn) not ]) |
|
518 |
ifTrue: |
|
519 |
[ Transcript |
|
520 |
show: 'warning this file has version '; |
|
521 |
show: majorVsn; |
|
522 |
show: '.'; |
|
523 |
showCR: minorVsn. ]. |
|
524 |
Verbose |
|
525 |
ifTrue: |
|
526 |
[ Transcript |
|
527 |
show: 'version = '; |
|
528 |
show: (majorVsn printString); |
|
529 |
show: '.'; |
|
530 |
showCR: (minorVsn printString). ]. |
|
752 | 531 |
|
532 |
"/ |
|
533 |
"/ get constant pool |
|
534 |
"/ |
|
535 |
||
536 |
self readConstantPool. |
|
537 |
||
538 |
"/ |
|
539 |
"/ access flags |
|
540 |
"/ |
|
541 |
||
771 | 542 |
access_flags := inStream nextUnsignedShortMSB: msb. |
543 |
this_class_index := inStream nextUnsignedShortMSB: msb. |
|
544 |
super_class_index := inStream nextUnsignedShortMSB: msb. |
|
545 |
super_class_index == 0 |
|
546 |
ifTrue: [ super_class := nil ] |
|
547 |
ifFalse: |
|
548 |
[ super_class := constants at: super_class_index. |
|
549 |
superClassName := super_class fullName. |
|
550 |
||
551 |
"/ special for ST-classes |
|
552 |
||
553 |
(superClassName startsWith: 'smalltalk.') |
|
554 |
ifTrue: |
|
555 |
[ "/ a Smalltalk class |
|
556 |
superClassName := superClassName copyFrom: 11. |
|
557 |
existingSuperClass := Smalltalk at: superClassName asSymbol. |
|
558 |
existingSuperClass notNil |
|
559 |
ifTrue: [ super_class := existingSuperClass ] |
|
560 |
ifFalse: |
|
561 |
[ "/ self halt - must load superclass ... |
|
562 |
] ] |
|
563 |
ifFalse: |
|
564 |
[ "/ a JAVA class |
|
798
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
565 |
super_class := Java classNamed: superClassName. |
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
566 |
super_class ifNil: |
799 | 567 |
[ super_class := self loadSuperclassIdentifiedBy: (constants at: super_class_index) |
798
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
568 |
ignoring: classesbeingLoaded ]. |
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
569 |
super_class ifNil: [ self halt: 'Cannot find super class?!!' ]. ]. ]. |
752 | 570 |
|
571 |
"/ |
|
572 |
"/ get interfaces |
|
573 |
"/ |
|
574 |
||
575 |
interfaces := self readInterfaces. |
|
576 |
||
577 |
"/ |
|
578 |
"/ get fields |
|
579 |
"/ |
|
580 |
||
581 |
fields := self readFieldInfofields. |
|
582 |
||
583 |
"/ |
|
584 |
"/ create the fields as instVars |
|
585 |
"/ static fields are created as class-InstVars |
|
586 |
"/ |
|
798
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
587 |
|
771 | 588 |
staticFields := fields select: [:f | f isStatic ]. |
752 | 589 |
nStatic := staticFields size. |
771 | 590 |
this_class_ref := constants at: this_class_index. |
752 | 591 |
thisClassName := this_class_ref fullName. |
592 |
||
593 |
"/ care for smalltalk classes ... |
|
594 |
||
771 | 595 |
(thisClassName startsWith: 'smalltalk.') |
596 |
ifTrue: |
|
597 |
[ thisClassName := thisClassName copyFrom: 11. |
|
598 |
existing_class := Smalltalk at: thisClassName asSymbol. |
|
599 |
existing_class notNil |
|
600 |
ifTrue: |
|
601 |
[ self halt: ('overloading existing class: ' , thisClassName). |
|
602 |
thisClassName := (thisClassName , '_new') asSymbol. ]. |
|
603 |
thisMetaClass := Metaclass new. |
|
604 |
thisMetaClass setSuperclass: super_class class. |
|
605 |
thisMetaClass instSize: (super_class class instSize + nStatic). |
|
775 | 606 |
classBeingLoaded := thisMetaClass new. |
607 |
classBeingLoaded setSuperclass: super_class. |
|
608 |
classBeingLoaded setName: thisClassName asSymbol. ] |
|
771 | 609 |
ifFalse: |
610 |
[ "/ a java class |
|
775 | 611 |
classBeingLoaded := JavaClass fullName: thisClassName numStatic: nStatic. |
811 | 612 |
|
613 |
fields := fields select: [:f | f isStatic not ]. |
|
614 |
||
615 |
JavaClass setInstanceVariableStringFromFields: staticFields |
|
616 |
in: classBeingLoaded class. |
|
617 |
||
618 |
classBeingLoaded setStaticFields: staticFields. |
|
619 |
classBeingLoaded initializeStaticFields. |
|
775 | 620 |
classBeingLoaded setAccessFlags: access_flags. |
621 |
classBeingLoaded setSuperclass: super_class. |
|
622 |
classBeingLoaded setConstantPool: constants. |
|
623 |
classBeingLoaded setFields: fields. |
|
624 |
classBeingLoaded setInterfaces: interfaces. |
|
809 | 625 |
]. |
752 | 626 |
|
627 |
"/ |
|
628 |
"/ get methods |
|
629 |
"/ |
|
630 |
||
775 | 631 |
self readMethodsFor: classBeingLoaded. |
632 |
self readAttributesFor: classBeingLoaded. |
|
809 | 633 |
"/ classBeingLoaded constantPool |
634 |
"/ do: [:each | self updateOwnerInCPItem: each ]. |
|
796
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
635 |
classBeingLoaded fields do: [:each | self updateOwnerInField: each ]. |
797
8d4e7c17eadd
fixed JavaClassReader so it always sets staticFields
hlopkmar
parents:
796
diff
changeset
|
636 |
classBeingLoaded staticFields do: [:each | self updateOwnerInField: each ]. |
992 | 637 |
|
638 |
||
775 | 639 |
^ classBeingLoaded. |
752 | 640 |
|
641 |
" |
|
642 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
643 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
644 |
JavaClassReader loadFile:'foo.cls' |
|
645 |
||
646 |
JavaClassReader verbose:true. |
|
647 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/java/lang/ArithmeticException.class' |
|
648 |
JavaClassReader loadFile:'/phys/ibm3/java/lib/java/lang/ArithmeticException.class'" |
|
649 |
||
650 |
"Created: / 15-04-1996 / 15:02:47 / cg" |
|
651 |
"Modified: / 12-11-1998 / 21:14:45 / cg" |
|
652 |
"Modified: / 15-10-2010 / 17:37:38 / Jan Kurs <kurs.jan@post.cz>" |
|
653 |
"Modified: / 28-01-2011 / 15:09:48 / Marcel Hlopko <hlopik@gmail.com>" |
|
800
11f2222f816d
forgotten return and fixed broken class reading (static field were not set up correctly)..
hlopkmar
parents:
799
diff
changeset
|
654 |
"Modified: / 18-05-2011 / 15:30:29 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
992 | 655 |
"Modified: / 08-09-2011 / 08:25:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 656 |
! |
657 |
||
658 |
readStream:aStream ignoring:classesBeingLoaded |
|
659 |
"reads a class from aStream and returns it. |
|
660 |
The JavaClass is not installed as global" |
|
661 |
||
662 |
inStream := aStream. |
|
663 |
inStream binary. |
|
664 |
||
665 |
^ self readClassFileIgnoring:classesBeingLoaded |
|
666 |
||
667 |
" |
|
668 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
669 |
" |
|
670 |
||
671 |
"Created: 15.4.1996 / 15:00:55 / cg" |
|
672 |
"Modified: 15.4.1996 / 15:06:18 / cg" |
|
673 |
! ! |
|
674 |
||
675 |
!JavaClassReader methodsFor:'file reading - attributes'! |
|
676 |
||
677 |
readAnnotationDefaultAttributeFor:something |
|
678 |
"/ ('JAVA [info]: unhandled attribute: AnnotationDefault') infoPrintCR. |
|
679 |
||
680 |
|len startPos endPos annotationDefault| |
|
681 |
||
682 |
self assert:something isJavaMethod |
|
683 |
description:'AnnotationDefault may only occure for methods!!'. |
|
684 |
len := inStream nextUnsignedLongMSB:msb. |
|
685 |
startPos := inStream position. |
|
686 |
annotationDefault := (something ensureHasAnnotations) |
|
687 |
default:(JavaAnnotationDefault new |
|
688 |
value:(self readAnnotationValueFor:something)); |
|
689 |
default. |
|
690 |
endPos := inStream position. |
|
691 |
inStream position:startPos. |
|
692 |
annotationDefault bytes:(inStream next:len). |
|
693 |
self assert:inStream position = endPos |
|
694 |
description:'self readAnnotationValueFor: something is reading what it shouldn'. |
|
695 |
||
696 |
"Modified: / 28-02-2011 / 17:08:28 / Marcel Hlopko <hlopik@gmail.com>" |
|
697 |
"Modified: / 03-03-2011 / 23:06:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
698 |
! |
|
699 |
||
700 |
readAnnotationFor:something |
|
701 |
| typeIndex type result attrsCount | |
|
702 |
||
703 |
typeIndex := inStream nextUnsignedShortMSB:msb. |
|
879 | 704 |
type := constants at:typeIndex. |
752 | 705 |
attrsCount := inStream nextUnsignedShortMSB:msb. |
706 |
result := JavaAnnotation for:something. |
|
707 |
result name:type. |
|
708 |
attrsCount timesRepeat: |
|
709 |
[ | nameIndex name valueIndex attr | |
|
710 |
||
711 |
nameIndex := inStream nextUnsignedShortMSB:msb. |
|
879 | 712 |
name := constants at:nameIndex. |
752 | 713 |
attr := self readAnnotationValueFor:something. |
714 |
attr name:name. |
|
715 |
result values at:attr name put:attr. |
|
716 |
AnnotationsVerbose |
|
717 |
ifTrue:[ ('JAVA [INFO]: Reading annotation attribute: ' , name) infoPrintCR. ]. ]. |
|
718 |
^ result. |
|
719 |
||
720 |
"Created: / 17-12-2010 / 16:21:28 / Marcel Hlopko <hlopik@gmail.com>" |
|
721 |
"Modified: / 25-02-2011 / 12:25:36 / Marcel Hlopko <hlopik@gmail.com>" |
|
879 | 722 |
"Modified: / 27-07-2011 / 09:37:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 723 |
! |
724 |
||
725 |
readAnnotationValueFor:something |
|
726 |
| tag result | |
|
727 |
||
728 |
tag := (inStream nextByte) asCharacter. |
|
729 |
tag = $e |
|
730 |
ifTrue: |
|
731 |
[ result := JavaAnnotationEnumValue for:something. |
|
732 |
result nameIndex:(inStream nextUnsignedShortMSB:msb). |
|
733 |
result valueIndex:(inStream nextUnsignedShortMSB:msb). |
|
734 |
AnnotationsVerbose |
|
735 |
ifTrue: |
|
736 |
[ ('JAVA [INFO]: Reading annotation enum value: ' , result name printString, ' -> ' |
|
737 |
, result value printString) infoPrintCR ]. |
|
738 |
^ result ]. |
|
739 |
tag = $c |
|
740 |
ifTrue: |
|
741 |
[ result := JavaAnnotationClassValue for:something. |
|
742 |
result classIndex:(inStream nextUnsignedShortMSB:msb). |
|
743 |
AnnotationsVerbose |
|
744 |
ifTrue: |
|
745 |
[ ('JAVA [INFO]: Reading annotation class value: ' , result name printString, ' -> ' |
|
746 |
, result value printString) infoPrintCR ]. |
|
747 |
^ result ]. |
|
748 |
tag = $@ |
|
749 |
ifTrue: |
|
750 |
[ result := JavaAnnotationNestedAnnotationValue for:something. |
|
751 |
result classIndex:(inStream nextUnsignedShortMSB:msb). |
|
752 |
AnnotationsVerbose |
|
753 |
ifTrue: |
|
754 |
[ ('JAVA [INFO]: Reading annotation nested annotation value: ' , result name printString |
|
755 |
, ' -> ' , result value printString) |
|
756 |
infoPrintCR ]. |
|
757 |
^ result ]. |
|
758 |
tag = $[ |
|
759 |
ifTrue: |
|
760 |
[ result := JavaAnnotationArrayValue for:something. |
|
761 |
result count:(inStream nextUnsignedShortMSB:msb). |
|
762 |
AnnotationsVerbose |
|
763 |
ifTrue:[ ('JAVA [INFO]: Reading annotation array value') infoPrintCR ]. |
|
764 |
1 to:result count |
|
765 |
do:[:index | result values at:index put:(self readAnnotationValueFor:something) ]. |
|
766 |
AnnotationsVerbose |
|
767 |
ifTrue: |
|
768 |
[ ('JAVA [INFO]: Finished reading annotation array value: ' |
|
769 |
, result value printString) infoPrintCR ]. |
|
770 |
^ result ]. |
|
771 |
result := JavaAnnotationPrimitiveValue for:something. |
|
772 |
result valueIndex:(inStream nextUnsignedShortMSB:msb). |
|
773 |
AnnotationsVerbose |
|
774 |
ifTrue: |
|
775 |
[ ('JAVA [INFO]: Finished reading annotation primitive value: ' |
|
776 |
, result name printString , ' -> ' , result value printString) infoPrintCR ]. |
|
777 |
^ result. |
|
778 |
||
779 |
"Created: / 17-12-2010 / 16:44:14 / Marcel Hlopko <hlopik@gmail.com>" |
|
780 |
"Modified: / 28-02-2011 / 16:12:09 / Marcel Hlopko <hlopik@gmail.com>" |
|
781 |
! |
|
782 |
||
783 |
readAttribute:attributeName for:something |
|
784 |
"/ implemented JAVA attributes |
|
785 |
||
786 |
(attributeName = 'ConstantValue') |
|
787 |
ifTrue: |
|
788 |
[ self readConstantValueAttributeFor:something. |
|
789 |
^ self. ]. |
|
790 |
(attributeName = 'Code') |
|
791 |
ifTrue: |
|
792 |
[ self readCodeAttributeFor:something. |
|
793 |
^ self. ]. |
|
794 |
(attributeName = 'Exceptions') |
|
795 |
ifTrue: |
|
796 |
[ self readExceptionsAttributeFor:something. |
|
797 |
^ self. ]. |
|
798 |
(attributeName = 'InnerClasses') |
|
799 |
ifTrue: |
|
800 |
[ self readInnerClassesAttributeFor:something. |
|
801 |
^ self. ]. |
|
802 |
(attributeName = 'EnclosingMethod') |
|
803 |
ifTrue: |
|
804 |
[ self readEnclosingMethodAttributeFor:something. |
|
805 |
^ self. ]. |
|
806 |
(attributeName = 'LineNumberTable') |
|
807 |
ifTrue: |
|
808 |
[ self readLineNumberTableAttributeFor:something. |
|
809 |
^ self. ]. |
|
810 |
(attributeName = 'LocalVariableTable') |
|
811 |
ifTrue: |
|
812 |
[ self readLocalVariableTableAttributeFor:something. |
|
813 |
^ self. ]. |
|
814 |
(attributeName = 'LocalVariableTypeTable') |
|
815 |
ifTrue: |
|
816 |
[ self readLocalVariableTypeTableAttributeFor:something. |
|
817 |
^ self. ]. |
|
818 |
(attributeName = 'SourceFile') |
|
819 |
ifTrue: |
|
820 |
[ self readSourceFileAttributeFor:something. |
|
821 |
^ self. ]. |
|
822 |
(attributeName = 'SourceDebugExtension') |
|
823 |
ifTrue: |
|
824 |
[ self readSourceDebugExtensionAttributeFor:something. |
|
825 |
^ self. ]. |
|
826 |
(attributeName = 'Synthetic') |
|
827 |
ifTrue: |
|
828 |
[ self readSyntheticAttributeFor:something. |
|
829 |
^ self. ]. |
|
830 |
(attributeName = 'Signature') |
|
831 |
ifTrue: |
|
832 |
[ self readSignatureAttributeFor:something. |
|
833 |
^ self. ]. |
|
834 |
(attributeName = 'Deprecated') |
|
835 |
ifTrue: |
|
836 |
[ self readDeprecatedAttributeFor:something. |
|
837 |
^ self. ]. |
|
838 |
(attributeName = 'RuntimeVisibleAnnotations') |
|
839 |
ifTrue: |
|
840 |
[ self readRuntimeAnnotationsAttributeFor:something visible:true. |
|
841 |
^ self. ]. |
|
842 |
(attributeName = 'RuntimeInvisibleAnnotations') |
|
843 |
ifTrue: |
|
844 |
[ self readRuntimeAnnotationsAttributeFor:something visible:false. |
|
845 |
^ self. ]. |
|
846 |
(attributeName = 'RuntimeVisibleParameterAnnotations') |
|
847 |
ifTrue: |
|
848 |
[ self readRuntimeParameterAnnotationsAttributeFor:something visible:true. |
|
849 |
^ self. ]. |
|
850 |
(attributeName = 'RuntimeInvisibleParameterAnnotations') |
|
851 |
ifTrue: |
|
852 |
[ self readRuntimeParameterAnnotationsAttributeFor:something visible:false. |
|
853 |
^ self. ]. |
|
854 |
(attributeName = 'AnnotationDefault') |
|
855 |
ifTrue: |
|
856 |
[ self readAnnotationDefaultAttributeFor:something. |
|
857 |
^ self. ]. |
|
858 |
||
859 |
"/ ignored JAVA attributes |
|
860 |
||
861 |
(attributeName = 'FastJavac1.0') |
|
862 |
ifTrue: |
|
863 |
[ "/ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
|
864 |
self skipAttribute:attributeName. |
|
865 |
^ self. ]. |
|
866 |
(attributeName = 'AbsoluteSourcePath') |
|
867 |
ifTrue: |
|
868 |
[ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
|
869 |
self skipAttribute:attributeName. |
|
870 |
^ self. ]. |
|
871 |
(attributeName startsWith:((Character value:13) asString , 'WARNING:')) |
|
872 |
ifTrue: |
|
873 |
[ "/ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
|
874 |
self skipAttribute:attributeName. |
|
875 |
^ self. ]. |
|
876 |
(attributeName = 'StackMapTable') |
|
877 |
ifTrue: |
|
878 |
[ "/ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
|
879 |
self readStackMapTableAttributeFor:something. |
|
880 |
^ self. ]. |
|
881 |
||
882 |
"/ implemented ST attributes |
|
883 |
||
884 |
(attributeName = 'STLiterals') |
|
885 |
ifTrue: |
|
886 |
[ self readSTLiteralsAttributeFor:something. |
|
887 |
^ self. ]. |
|
888 |
(attributeName = 'ClassRevision') |
|
889 |
ifTrue: |
|
890 |
[ self readSTClassRevisionAttributeFor:something. |
|
891 |
^ self. ]. |
|
892 |
(attributeName = 'ClassPackage') |
|
893 |
ifTrue: |
|
894 |
[ self readSTClassPackageAttributeFor:something. |
|
895 |
^ self. ]. |
|
896 |
(attributeName = 'ClassCategory') |
|
897 |
ifTrue: |
|
898 |
[ self readSTClassCategoryAttributeFor:something. |
|
899 |
^ self. ]. |
|
900 |
(attributeName = 'ClassVarNames') |
|
901 |
ifTrue: |
|
902 |
[ self readSTClassVarNamesAttributeFor:something. |
|
903 |
^ self. ]. |
|
904 |
(attributeName = 'ClassInstVarNames') |
|
905 |
ifTrue: |
|
906 |
[ self readSTClassInstVarNamesAttributeFor:something. |
|
907 |
^ self. ]. |
|
908 |
(attributeName = 'InstVarNames') |
|
909 |
ifTrue: |
|
910 |
[ self readSTInstVarNamesAttributeFor:something. |
|
911 |
^ self. ]. |
|
912 |
(attributeName = 'STCode') |
|
913 |
ifTrue: |
|
914 |
[ self readSTCodeAttributeFor:something. |
|
915 |
^ self. ]. |
|
916 |
(attributeName = 'MethodCategory') |
|
917 |
ifTrue: |
|
918 |
[ self readSTMethodCategoryAttributeFor:something. |
|
919 |
^ self. ]. |
|
920 |
||
921 |
"/ unknown attributes |
|
922 |
||
923 |
('JAVA [warning]: unrecognized attribute: ' , attributeName) infoPrintCR. |
|
924 |
self skipAttribute:attributeName. |
|
925 |
||
926 |
"Modified: / 03-12-1998 / 13:13:42 / cg" |
|
927 |
"Modified: / 25-02-2011 / 18:09:21 / Marcel Hlopko <hlopik@gmail.com>" |
|
928 |
! |
|
929 |
||
930 |
readAttributeFor:something |
|
931 |
|attribute_name_index attribute_name attribute_length attribute_info| |
|
932 |
||
933 |
Verbose ifTrue:[Transcript show:'attrib at pos: '; showCR:inStream position]. |
|
934 |
||
935 |
attribute_name_index := inStream nextUnsignedShortMSB:msb. |
|
936 |
attribute_name_index == 0 ifTrue:[ |
|
937 |
self halt. |
|
938 |
"/self skipAttribute:'unnamed'. |
|
939 |
^ self. |
|
940 |
]. |
|
941 |
||
942 |
"/ |
|
943 |
"/ UNDOC feature ? |
|
944 |
"/ |
|
945 |
attribute_name_index > constants size ifTrue:[ |
|
946 |
attribute_name_index == 16rb700 ifTrue:[ |
|
947 |
self halt. |
|
948 |
] |
|
949 |
]. |
|
950 |
||
951 |
attribute_name := constants at:attribute_name_index. |
|
952 |
||
953 |
Verbose ifTrue:[Transcript show:'attrib name: '; showCR:attribute_name]. |
|
954 |
||
955 |
self readAttribute:attribute_name for:something. |
|
956 |
||
957 |
" |
|
958 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
959 |
" |
|
960 |
||
961 |
"Created: / 15-04-1996 / 15:40:17 / cg" |
|
962 |
"Modified: / 09-04-1998 / 18:13:34 / cg" |
|
963 |
"Modified: / 19-10-2010 / 21:43:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
964 |
! |
|
965 |
||
966 |
readAttributesFor:something |
|
967 |
|attributes_count| |
|
968 |
||
969 |
attributes_count := inStream nextUnsignedShortMSB:msb. |
|
970 |
||
971 |
1 to:attributes_count do:[:i | |
|
972 |
self readAttributeFor:something. |
|
973 |
]. |
|
974 |
||
975 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
976 |
"Created: 15.4.1996 / 15:40:17 / cg" |
|
977 |
! |
|
978 |
||
979 |
readDeprecatedAttributeFor:aJavaMethodWithHandler |
|
980 |
||
981 |
self skipAttribute:'Deprecated'. |
|
982 |
^self |
|
983 |
||
984 |
"Created: / 18-10-2010 / 22:26:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
985 |
! |
|
986 |
||
987 |
readEnclosingMethodAttributeFor:something |
|
988 |
"/ ('JAVA [info]: unhandled attribute: EnclosingMethod') infoPrintCR. |
|
989 |
self skipAttribute:'EnclosingMethod'. |
|
990 |
! |
|
991 |
||
992 |
readInnerClassesAttributeFor:something |
|
993 |
"/ ('JAVA [info]: unhandled attribute: InnerClasses') infoPrintCR. |
|
994 |
self skipAttribute:'InnerClasses'. |
|
995 |
! |
|
996 |
||
997 |
readLocalVariableTypeTableAttributeFor:something |
|
998 |
"/ ('JAVA [info]: unhandled attribute: LocalVariableTypeTable') infoPrintCR. |
|
999 |
self skipAttribute:'LocalVariableTypeTable'. |
|
1000 |
! |
|
1001 |
||
1002 |
readRuntimeAnnotationsAttributeFor: something visible: visible |
|
1003 |
| length annotationsCount annotations rawAnnotations startPos endPos | |
|
1004 |
||
1005 |
self assert: inStream isPositionable |
|
1006 |
message: '.class file stream must be positionable'. |
|
1007 |
length := inStream nextUnsignedLongMSB: msb. |
|
1008 |
startPos := inStream position. |
|
1009 |
annotationsCount := inStream nextUnsignedShortMSB: msb. |
|
1010 |
annotationsCount = 0 ifTrue: [ ^ nil ]. |
|
1011 |
annotations := visible ifTrue: [something ensureHasAnnotations ensureRuntimeVisible] ifFalse: [something ensureHasAnnotations ensureRuntimeInvisible]. |
|
1012 |
annotationsCount timesRepeat: |
|
1013 |
[ | currentAnnotation | |
|
1014 |
||
1015 |
currentAnnotation := self readAnnotationFor: something. |
|
1016 |
annotations at: currentAnnotation name put: currentAnnotation. ]. |
|
1017 |
"Cut raw annotations as required by getRawAnnotations()" |
|
1018 |
endPos := inStream position. |
|
1019 |
inStream position: startPos. |
|
1020 |
rawAnnotations := inStream next: length. |
|
1021 |
inStream position ~= endPos |
|
1022 |
ifTrue: [ self halt: 'annotations are probably reading what they shouldnt' ]. |
|
1023 |
annotations rawAnnotations: rawAnnotations. |
|
1024 |
||
1025 |
"Modified: / 07-01-2011 / 22:00:07 / Jan Kurs <kurs.jan@post.cz>" |
|
1026 |
"Modified: / 25-02-2011 / 18:45:58 / Marcel Hlopko <hlopik@gmail.com>" |
|
1027 |
"Modified: / 03-03-2011 / 23:01:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1028 |
"Modified: / 16-03-2011 / 16:57:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1029 |
! |
|
1030 |
||
1031 |
readRuntimeParameterAnnotationsAttributeFor: javaMethod visible: visible |
|
1032 |
| length paramsCount annotationsCount rawAnnotations startPos endPos | |
|
1033 |
||
1034 |
self assert: inStream isPositionable |
|
1035 |
message: '.class file stream must be positionable'. |
|
1036 |
length := inStream nextUnsignedLongMSB: msb. |
|
1037 |
startPos := inStream position. |
|
1038 |
paramsCount := inStream nextByte. |
|
1039 |
paramsCount = 0 ifTrue: [ ^ nil ]. |
|
1040 |
1 to: paramsCount |
|
1041 |
do: |
|
1042 |
[:paramIndex | |
|
1043 |
annotationsCount := inStream nextUnsignedShortMSB: msb. |
|
1044 |
annotationsCount > 0 |
|
1045 |
ifTrue: |
|
1046 |
[ | annotations | |
|
1047 |
annotations := visible |
|
1048 |
ifTrue: |
|
1049 |
[ javaMethod ensureHasAnnotations ensureVisibleParameterAnnotationsAt: paramIndex ] |
|
1050 |
ifFalse: |
|
1051 |
[javaMethod ensureHasAnnotations ensureInvisibleParameterAnnotationsAt: paramIndex ]. |
|
1052 |
annotationsCount timesRepeat: |
|
1053 |
[ | annotation | |
|
1054 |
||
1055 |
annotation := self readAnnotationFor: javaMethod. |
|
1056 |
annotations at: (annotation name) put: annotation. ] ]]. |
|
1057 |
endPos := inStream position. |
|
1058 |
rawAnnotations := inStream position: startPos. |
|
1059 |
rawAnnotations := inStream next: length. |
|
1060 |
inStream position ~= endPos |
|
1061 |
ifTrue: [ self halt: 'annotations are probably reading what they shouldnt' ]. |
|
1062 |
javaMethod annotations rawAnnotations: rawAnnotations. |
|
1063 |
||
1064 |
"Modified: / 28-02-2011 / 17:05:47 / Marcel Hlopko <hlopik@gmail.com>" |
|
1065 |
"Modified: / 16-03-2011 / 17:26:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1066 |
! |
|
1067 |
||
1068 |
readSignatureAttributeFor:something |
|
912
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1069 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1070 |
|attribute_length signature_index signature| |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1071 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1072 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1073 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1074 |
signature_index := inStream nextUnsignedShortMSB:msb. |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1075 |
signature := constants at:signature_index. |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1076 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1077 |
something setSignature: signature. |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1078 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1079 |
"Modified: / 13-08-2011 / 00:28:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 1080 |
! |
1081 |
||
1082 |
readSourceDebugExtensionAttributeFor:something |
|
1083 |
"/ ('JAVA [info]: unhandled attribute: SourceDebugExtension') infoPrintCR. |
|
1084 |
self skipAttribute:'SourceDebugExtension'. |
|
1085 |
! |
|
1086 |
||
1087 |
readSourceFileAttributeFor:aClass |
|
1088 |
|attribute_length sourceFile_index sourceFile| |
|
1089 |
||
1090 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1091 |
||
1092 |
sourceFile_index := inStream nextUnsignedShortMSB:msb. |
|
1093 |
sourceFile := constants at:sourceFile_index. |
|
1094 |
||
1095 |
aClass isJavaClass ifTrue:[ |
|
1096 |
aClass setSourceFile:sourceFile. |
|
1097 |
] ifFalse:[ |
|
1098 |
aClass setClassFilename:sourceFile |
|
1099 |
]. |
|
1100 |
||
1101 |
Verbose ifTrue:[Transcript show:'sourceFile: '; showCR:sourceFile]. |
|
1102 |
^ true |
|
1103 |
||
1104 |
" |
|
1105 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1106 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1107 |
JavaClassReader loadFile:'foo.cls' |
|
1108 |
" |
|
1109 |
||
1110 |
"Created: / 15.4.1996 / 15:40:17 / cg" |
|
1111 |
"Modified: / 12.5.1998 / 22:01:07 / cg" |
|
1112 |
! |
|
1113 |
||
1114 |
readStackMapTableAttributeFor:something |
|
1115 |
"/ ('JAVA [info]: unhandled attribute: StackMapTable') infoPrintCR. |
|
1116 |
self skipAttribute:'StackMapTable'. |
|
1117 |
||
1118 |
"Created: / 09-02-2011 / 01:19:20 / Marcel Hlopko <hlopik@gmail.com>" |
|
1119 |
! |
|
1120 |
||
1121 |
readSyntheticAttributeFor:something |
|
1122 |
"/ ('JAVA [info]: unhandled attribute: Synthetic') infoPrintCR. |
|
1123 |
self skipAttribute:'Synthetic'. |
|
1124 |
! |
|
1125 |
||
1126 |
skipAttribute:attributeName |
|
1127 |
"dont know about this attribute - skip it here" |
|
1128 |
||
1129 |
|attribute_length attribute_info| |
|
1130 |
||
1131 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1132 |
attribute_info := ByteArray new:(attribute_length). |
|
1133 |
inStream nextBytes:attribute_length into:attribute_info startingAt:1. |
|
1134 |
||
1135 |
Verbose ifTrue:[Transcript show:'skipped '; show:attributeName; showCR:'-attribute']. |
|
1136 |
||
1137 |
"Created: / 9.4.1998 / 18:12:46 / cg" |
|
1138 |
"Modified: / 9.4.1998 / 18:13:20 / cg" |
|
1139 |
! ! |
|
1140 |
||
1141 |
!JavaClassReader methodsFor:'file reading - attributes-ST'! |
|
1142 |
||
1143 |
readSTClassCategoryAttributeFor:aClass |
|
1144 |
|attribute_length categoryString_index categoryString| |
|
1145 |
||
1146 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1147 |
||
1148 |
categoryString_index := inStream nextUnsignedShortMSB:msb. |
|
1149 |
categoryString := constants at:categoryString_index. |
|
1150 |
||
1151 |
aClass category:categoryString. |
|
1152 |
||
1153 |
Verbose ifTrue:[Transcript show:'categoryString: '; showCR:categoryString]. |
|
1154 |
^ true |
|
1155 |
||
1156 |
" |
|
1157 |
JavaClassReader loadFile:'foo.cls' |
|
1158 |
" |
|
1159 |
||
1160 |
"Created: / 9.5.1998 / 02:33:13 / cg" |
|
1161 |
"Modified: / 9.5.1998 / 02:36:55 / cg" |
|
1162 |
! |
|
1163 |
||
1164 |
readSTClassInstVarNamesAttributeFor:aClass |
|
1165 |
|attribute_length nameString_index nameString| |
|
1166 |
||
1167 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1168 |
||
1169 |
nameString_index := inStream nextUnsignedShortMSB:msb. |
|
1170 |
nameString := constants at:nameString_index. |
|
1171 |
||
1172 |
aClass class instanceVariableString:nameString. |
|
1173 |
||
1174 |
Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString]. |
|
1175 |
^ true |
|
1176 |
||
1177 |
" |
|
1178 |
JavaClassReader loadFile:'foo.cls' |
|
1179 |
" |
|
1180 |
||
1181 |
"Modified: / 12.5.1998 / 22:18:03 / cg" |
|
1182 |
"Created: / 12.5.1998 / 22:18:24 / cg" |
|
1183 |
! |
|
1184 |
||
1185 |
readSTClassPackageAttributeFor:aClass |
|
1186 |
|attribute_length packageString_index packageString| |
|
1187 |
||
1188 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1189 |
||
1190 |
packageString_index := inStream nextUnsignedShortMSB:msb. |
|
1191 |
packageString := constants at:packageString_index. |
|
1192 |
||
1193 |
aClass package:packageString asSymbol. |
|
1194 |
||
1195 |
Verbose ifTrue:[Transcript show:'packageString: '; showCR:packageString]. |
|
1196 |
^ true |
|
1197 |
||
1198 |
" |
|
1199 |
JavaClassReader loadFile:'foo.cls' |
|
1200 |
" |
|
1201 |
||
1202 |
"Modified: / 9.5.1998 / 02:32:38 / cg" |
|
1203 |
"Created: / 9.5.1998 / 02:33:44 / cg" |
|
1204 |
! |
|
1205 |
||
1206 |
readSTClassRevisionAttributeFor:aClass |
|
1207 |
|attribute_length revisionString_index revisionString| |
|
1208 |
||
1209 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1210 |
||
1211 |
revisionString_index := inStream nextUnsignedShortMSB:msb. |
|
1212 |
revisionString := constants at:revisionString_index. |
|
1213 |
||
1214 |
aClass setBinaryRevision:revisionString. |
|
1215 |
||
1216 |
Verbose ifTrue:[Transcript show:'revisionString: '; showCR:revisionString]. |
|
1217 |
^ true |
|
1218 |
||
1219 |
" |
|
1220 |
JavaClassReader loadFile:'foo.cls' |
|
1221 |
" |
|
1222 |
||
1223 |
"Created: / 9.5.1998 / 02:33:13 / cg" |
|
1224 |
"Modified: / 9.5.1998 / 02:35:01 / cg" |
|
1225 |
! |
|
1226 |
||
1227 |
readSTClassVarNamesAttributeFor:aClass |
|
1228 |
|attribute_length nameString_index nameString| |
|
1229 |
||
1230 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1231 |
||
1232 |
nameString_index := inStream nextUnsignedShortMSB:msb. |
|
1233 |
nameString := constants at:nameString_index. |
|
1234 |
||
1235 |
aClass classVariableString:nameString. |
|
1236 |
||
1237 |
Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString]. |
|
1238 |
^ true |
|
1239 |
||
1240 |
" |
|
1241 |
JavaClassReader loadFile:'foo.cls' |
|
1242 |
" |
|
1243 |
||
1244 |
"Created: / 9.5.1998 / 02:33:13 / cg" |
|
1245 |
"Modified: / 12.5.1998 / 22:18:03 / cg" |
|
1246 |
! |
|
1247 |
||
1248 |
readSTInstVarNamesAttributeFor:aClass |
|
1249 |
|attribute_length nameString_index nameString| |
|
1250 |
||
1251 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1252 |
||
1253 |
nameString_index := inStream nextUnsignedShortMSB:msb. |
|
1254 |
nameString := constants at:nameString_index. |
|
1255 |
||
1256 |
aClass setInstanceVariableString:nameString. |
|
1257 |
||
1258 |
Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString]. |
|
1259 |
^ true |
|
1260 |
||
1261 |
" |
|
1262 |
JavaClassReader loadFile:'foo.cls' |
|
1263 |
" |
|
1264 |
||
1265 |
"Created: / 12.5.1998 / 22:18:14 / cg" |
|
1266 |
"Modified: / 12.5.1998 / 22:21:10 / cg" |
|
1267 |
! ! |
|
1268 |
||
1269 |
!JavaClassReader methodsFor:'file reading - constants'! |
|
1270 |
||
1271 |
readConstant |
|
1272 |
|tag constReader const| |
|
1273 |
||
1274 |
||
1275 |
constNeeds2Slots := false. |
|
1276 |
||
1277 |
"/ |
|
1278 |
"/ get tag |
|
1279 |
"/ |
|
1280 |
tag := inStream nextByte. |
|
1281 |
Verbose ifTrue:[Transcript show:'tag = '; showCR:tag]. |
|
1282 |
||
1283 |
tag >= 250 ifTrue:[ |
|
1284 |
constReader := #( |
|
1285 |
"/ ST types |
|
1286 |
readConstant_ST_Large "/ 249 |
|
1287 |
readConstant_ST_Special "/ 250 |
|
1288 |
readConstant_ST_Character "/ 251 |
|
1289 |
readConstant_ST_ByteArray "/ 252 |
|
1290 |
readConstant_ST_Array "/ 253 |
|
1291 |
readConstant_ST_Symbol "/ 254 |
|
1292 |
readConstant_ST_Reserved "/ 255 |
|
1293 |
) at:tag-249+1. |
|
1294 |
] ifFalse:[ |
|
1295 |
constReader := #( |
|
1296 |
"/ JAVA types |
|
1297 |
readConstant_Utf8 "/ 1 - now called Utf8 |
|
1298 |
readConstant_Unicode "/ 2 |
|
1299 |
readConstant_Integer "/ 3 |
|
1300 |
readConstant_Float "/ 4 |
|
1301 |
readConstant_Long "/ 5 |
|
1302 |
readConstant_Double "/ 6 |
|
1303 |
readConstant_Class "/ 7 |
|
1304 |
readConstant_String "/ 8 |
|
1305 |
readConstant_Fieldref "/ 9 |
|
1306 |
readConstant_Methodref "/ 10 |
|
1307 |
readConstant_InterfaceMethodref "/ 11 |
|
1308 |
readConstant_NameAndType "/ 12 |
|
1309 |
) at:tag ifAbsent:[#readConstant_Undef]. |
|
1310 |
]. |
|
1311 |
^ self perform:constReader. |
|
1312 |
||
1313 |
" |
|
1314 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1315 |
" |
|
1316 |
||
1317 |
"Created: / 15.4.1996 / 15:46:32 / cg" |
|
1318 |
"Modified: / 9.5.1998 / 01:26:05 / cg" |
|
1319 |
! |
|
1320 |
||
1321 |
readConstantPool |
|
877 | 1322 |
| constantPoolSize const | |
752 | 1323 |
|
1324 |
"/ |
|
1325 |
"/ get constant pool |
|
1326 |
"/ |
|
877 | 1327 |
constantPoolSize := inStream nextUnsignedShortMSB: msb. |
1328 |
self info: 'constantPoolSize = ' , constantPoolSize printString. |
|
1329 |
constants := JavaConstantPool new: constantPoolSize - 1. |
|
752 | 1330 |
constSlot := 1. |
877 | 1331 |
[ constSlot < constantPoolSize ] whileTrue: [ |
1332 |
self info: 'const slot: ' , constSlot printString. |
|
1333 |
const := self readConstant. |
|
1334 |
constants at: constSlot put: const. |
|
1335 |
||
1336 |
"/ long & double consts take 2 slots |
|
1337 |
"/ (only first is used) |
|
1338 |
||
1339 |
constNeeds2Slots |
|
1340 |
ifTrue: [ constSlot := constSlot + 2. ] |
|
1341 |
ifFalse: [ constSlot := constSlot + 1. ]]. |
|
752 | 1342 |
constSlot := -1. |
877 | 1343 |
|
1344 |
1 to: constantPoolSize - 1 |
|
1345 |
do: |
|
1346 |
[:i | |
|
1347 |
| const value | |
|
1348 |
||
1349 |
const := constants at: i. |
|
1350 |
const ifNotNil: |
|
1351 |
[ "/ kludge for 2-slot constants (which only take 1 slot in ST/X) |
|
1352 |
(const isKindOf: JavaUnresolvedConstant) |
|
1353 |
ifTrue: |
|
1354 |
[ value := const preResolve. |
|
1355 |
value ~~ const ifTrue: [ constants at: i put: value. ] ] ] ]. |
|
752 | 1356 |
|
1357 |
" |
|
1358 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
877 | 1359 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'" |
1360 |
||
1361 |
"Modified: / 07-05-1998 / 11:44:06 / cg" |
|
1362 |
"Created: / 13-05-2011 / 16:52:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1363 |
! |
1364 |
||
1365 |
readConstant_Asciz |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1366 |
| len string | |
782 | 1367 |
|
1368 |
||
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1369 |
len := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1370 |
string := String new: len. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1371 |
inStream |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1372 |
nextBytes: len |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1373 |
into: string |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1374 |
startingAt: 1. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1375 |
Verbose |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1376 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1377 |
[ Transcript |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1378 |
show: 'asciz; string= '; |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1379 |
showCR: string ]. |
752 | 1380 |
^ string |
1381 |
||
1382 |
" |
|
1383 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1384 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'" |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1385 |
|
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1386 |
"Created: / 15-04-1996 / 15:15:35 / cg" |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1387 |
"Modified: / 15-04-1996 / 16:33:45 / cg" |
782 | 1388 |
"Modified: / 13-05-2011 / 17:31:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1389 |
! |
1390 |
||
1391 |
readConstant_Class |
|
877 | 1392 |
| nameIndex | |
1393 |
||
1394 |
nameIndex := inStream nextUnsignedShortMSB: msb. |
|
1395 |
((constants at: nameIndex) isNil) |
|
1396 |
ifTrue: |
|
1397 |
[ self info: ('reading class; index=' , nameIndex printString , ' name=' |
|
1398 |
, (constants at: nameIndex) printString) ] |
|
1399 |
ifFalse: [ self info: ('reading class; index= ' , nameIndex printString) ]. |
|
1400 |
^ JavaClassRef2 in: constants withNameAt: nameIndex. |
|
1401 |
||
1402 |
"Modified: / 18-05-2011 / 18:21:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1403 |
! |
1404 |
||
1405 |
readConstant_Double |
|
1406 |
|high low aFloat bytes| |
|
1407 |
||
1408 |
"/ new code - to be tested |
|
1409 |
"/ bytes := ByteArray new:8. |
|
1410 |
"/ |
|
1411 |
"/ inStream nextBytes:8 into:bytes startingAt:1. |
|
1412 |
"/ msb ~~ UninterpretedBytes isBigEndian ifTrue:[ |
|
1413 |
"/ bytes reverse |
|
1414 |
"/ ]. |
|
1415 |
"/ aFloat := bytes doubleAt:1. |
|
1416 |
||
1417 |
"/ old code |
|
1418 |
||
1419 |
high := inStream nextUnsignedLongMSB:msb. |
|
1420 |
low := inStream nextUnsignedLongMSB:msb. |
|
1421 |
||
1422 |
aFloat := Float new. |
|
1423 |
UninterpretedBytes isBigEndian ifTrue:[ |
|
1424 |
aFloat basicAt:1 put:((high bitShift:-24) bitAnd:16rFF). |
|
1425 |
aFloat basicAt:2 put:((high bitShift:-16) bitAnd:16rFF). |
|
1426 |
aFloat basicAt:3 put:((high bitShift:-8) bitAnd:16rFF). |
|
1427 |
aFloat basicAt:4 put:(high bitAnd:16rFF). |
|
1428 |
aFloat basicAt:5 put:((low bitShift:-24) bitAnd:16rFF). |
|
1429 |
aFloat basicAt:6 put:((low bitShift:-16) bitAnd:16rFF). |
|
1430 |
aFloat basicAt:7 put:((low bitShift:-8) bitAnd:16rFF). |
|
1431 |
aFloat basicAt:8 put:(low bitAnd:16rFF). |
|
1432 |
] ifFalse:[ |
|
1433 |
aFloat basicAt:1 put:(low bitAnd:16rFF). |
|
1434 |
aFloat basicAt:2 put:((low bitShift:-8) bitAnd:16rFF). |
|
1435 |
aFloat basicAt:3 put:((low bitShift:-16) bitAnd:16rFF). |
|
1436 |
aFloat basicAt:4 put:((low bitShift:-24) bitAnd:16rFF). |
|
1437 |
aFloat basicAt:5 put:(high bitAnd:16rFF). |
|
1438 |
aFloat basicAt:6 put:((high bitShift:-8) bitAnd:16rFF). |
|
1439 |
aFloat basicAt:7 put:((high bitShift:-16) bitAnd:16rFF). |
|
1440 |
aFloat basicAt:8 put:((high bitShift:-24) bitAnd:16rFF). |
|
1441 |
]. |
|
1442 |
||
1443 |
constNeeds2Slots := true. |
|
1444 |
||
1445 |
Verbose ifTrue:[Transcript show:'double; value= '; showCR:aFloat]. |
|
1446 |
^ aFloat |
|
1447 |
||
1448 |
" |
|
1449 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1450 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1451 |
" |
|
1452 |
||
1453 |
"Created: / 15.4.1996 / 16:34:42 / cg" |
|
1454 |
"Modified: / 8.5.1998 / 22:06:07 / cg" |
|
1455 |
! |
|
1456 |
||
877 | 1457 |
readConstant_Fieldref |
1458 |
"incrementally changing resolving logic, fields will come later" |
|
1459 |
||
1460 |
| classIndex nameAndTypeIndex | |
|
1461 |
||
1462 |
classIndex := inStream nextUnsignedShortMSB: msb. |
|
1463 |
nameAndTypeIndex := inStream nextUnsignedShortMSB: msb. |
|
1464 |
self |
|
1465 |
info: 'reading fieldref; classindex=' , classIndex printString |
|
1466 |
, ' nameAndTypeIndex=' , nameAndTypeIndex printString. |
|
1467 |
^ JavaFieldRef2 |
|
1468 |
in: constants |
|
1469 |
withNameAndTypeAt: nameAndTypeIndex |
|
1470 |
andClassAt: classIndex. |
|
1471 |
||
1472 |
"Modified: / 15-05-2011 / 14:20:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1473 |
! |
1474 |
||
1475 |
readConstant_Float |
|
1476 |
|b1 b2 b3 b4 aFloat bytes| |
|
1477 |
||
1478 |
"/ new code - to be tested ... |
|
1479 |
"/ |
|
1480 |
"/ bytes := ByteArray new:4. |
|
1481 |
"/ inStream nextBytes:4 into:bytes startingAt:1. |
|
1482 |
"/ msb ~~ UninterpretedBytes isBigEndian ifTrue:[ |
|
1483 |
"/ bytes reverse |
|
1484 |
"/ ]. |
|
1485 |
"/ aFloat := bytes floatAt:1. |
|
1486 |
"/ Verbose ifTrue:[Transcript show:'float; value= '; showCR:aFloat]. |
|
1487 |
"/ ^ aFloat. |
|
1488 |
||
1489 |
"/ old code |
|
1490 |
||
1491 |
aFloat := ShortFloat basicNew. |
|
1492 |
||
1493 |
b1 := inStream nextByte. |
|
1494 |
b2 := inStream nextByte. |
|
1495 |
b3 := inStream nextByte. |
|
1496 |
b4 := inStream nextByte. |
|
1497 |
||
1498 |
UninterpretedBytes isBigEndian ifTrue:[ |
|
1499 |
aFloat basicAt:1 put:b1. |
|
1500 |
aFloat basicAt:2 put:b2. |
|
1501 |
aFloat basicAt:3 put:b3. |
|
1502 |
aFloat basicAt:4 put:b4. |
|
1503 |
] ifFalse:[ |
|
1504 |
aFloat basicAt:4 put:b1. |
|
1505 |
aFloat basicAt:3 put:b2. |
|
1506 |
aFloat basicAt:2 put:b3. |
|
1507 |
aFloat basicAt:1 put:b4. |
|
1508 |
]. |
|
1509 |
Verbose ifTrue:[Transcript show:'float; value= '; showCR:aFloat]. |
|
1510 |
^ aFloat |
|
1511 |
||
1512 |
" |
|
1513 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1514 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1515 |
" |
|
1516 |
||
1517 |
"Created: / 15.4.1996 / 16:34:42 / cg" |
|
1518 |
"Modified: / 10.11.1998 / 22:04:59 / cg" |
|
1519 |
! |
|
1520 |
||
1521 |
readConstant_Integer |
|
1522 |
|value| |
|
1523 |
||
1524 |
value := inStream nextLongMSB:msb. |
|
1525 |
||
1526 |
Verbose ifTrue:[Transcript show:'integer; value= '; showCR:value]. |
|
1527 |
||
1528 |
^ value |
|
1529 |
||
1530 |
" |
|
1531 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1532 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1533 |
" |
|
1534 |
||
1535 |
"Modified: 15.4.1996 / 15:42:16 / cg" |
|
1536 |
"Created: 15.4.1996 / 16:34:42 / cg" |
|
1537 |
! |
|
1538 |
||
1539 |
readConstant_InterfaceMethodref |
|
877 | 1540 |
| classIndex nameAndTypeIndex | |
1541 |
||
1542 |
classIndex := inStream nextUnsignedShortMSB: msb. |
|
1543 |
nameAndTypeIndex := inStream nextUnsignedShortMSB: msb. |
|
1544 |
self |
|
1545 |
info: 'reading interface methodref; classindex=' , classIndex printString |
|
1546 |
, ' nameAndTypeIndex=' , nameAndTypeIndex printString. |
|
1547 |
^ JavaInterfaceMethodRef2 |
|
1548 |
in: constants |
|
1549 |
withNameAndTypeAt: nameAndTypeIndex |
|
1550 |
andClassAt: classIndex. |
|
1551 |
||
1552 |
"Modified: / 12-05-2011 / 18:57:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1553 |
! |
1554 |
||
1555 |
readConstant_Long |
|
1556 |
|high low value| |
|
1557 |
||
1558 |
high := inStream nextUnsignedLongMSB:msb. |
|
1559 |
low := inStream nextUnsignedLongMSB:msb. |
|
1560 |
||
1561 |
value := (high bitShift:32) bitOr:low. |
|
1562 |
(high bitTest:16r80000000) ifTrue:[ |
|
1563 |
value := value - 16r10000000000000000. |
|
1564 |
]. |
|
1565 |
constNeeds2Slots := true. |
|
1566 |
||
1567 |
Verbose ifTrue:[Transcript show:'long; value= '; showCR:value]. |
|
1568 |
^ value |
|
1569 |
||
1570 |
" |
|
1571 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1572 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1573 |
" |
|
1574 |
||
1575 |
"Modified: 15.4.1996 / 15:42:16 / cg" |
|
1576 |
"Created: 15.4.1996 / 16:34:42 / cg" |
|
1577 |
! |
|
1578 |
||
1579 |
readConstant_Methodref |
|
877 | 1580 |
| classIndex nameAndTypeIndex | |
1581 |
||
1582 |
classIndex := inStream nextUnsignedShortMSB: msb. |
|
1583 |
nameAndTypeIndex := inStream nextUnsignedShortMSB: msb. |
|
1584 |
self |
|
1585 |
info: 'reading methodref; classindex=' , classIndex printString , ' nameAndTypeIndex=' |
|
1586 |
, nameAndTypeIndex printString. |
|
1587 |
^ JavaMethodRef2 |
|
1588 |
in: constants |
|
1589 |
withNameAndTypeAt: nameAndTypeIndex |
|
1590 |
andClassAt: classIndex. |
|
1591 |
||
1592 |
"Modified: / 15-05-2011 / 14:20:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1593 |
! |
1594 |
||
1595 |
readConstant_NameAndType |
|
877 | 1596 |
| nameIndex descriptorIndex | |
1597 |
||
1598 |
nameIndex := inStream nextUnsignedShortMSB: msb. |
|
1599 |
descriptorIndex := inStream nextUnsignedShortMSB: msb. |
|
1600 |
self |
|
1601 |
info: 'reading nameAndType; nameindex=' , nameIndex printString |
|
1602 |
, ' descriptorIndex= ' , descriptorIndex printString. |
|
1603 |
^JavaNameAndType2 |
|
1604 |
in: constants |
|
1605 |
withNameAt: nameIndex |
|
1606 |
andDescriptorAt: descriptorIndex. |
|
1607 |
||
1608 |
"Modified: / 10-05-2011 / 17:09:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1609 |
! |
1610 |
||
1611 |
readConstant_String |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
1612 |
| string_index | |
782 | 1613 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1614 |
string_index := inStream nextUnsignedShortMSB: msb. |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
1615 |
^ JavaStringRef2 in: constants withValueAt: string_index. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
1616 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1617 |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
1618 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1619 |
"Created: / 15-04-1996 / 15:20:33 / cg" |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1620 |
"Modified: / 07-05-1998 / 11:42:45 / cg" |
782 | 1621 |
"Modified: / 13-05-2011 / 17:31:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
906
fea23aa2b228
Few more fixes and workarounds for Saxon 6.5.5: the Othello example works fine...
vranyj1
parents:
898
diff
changeset
|
1622 |
"Modified: / 10-08-2011 / 23:25:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 1623 |
! |
1624 |
||
1625 |
readConstant_Unicode |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1626 |
| len string ascii | |
782 | 1627 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1628 |
len := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1629 |
string := TwoByteString new: len. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1630 |
1 to: len |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1631 |
do: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1632 |
[:idx | |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1633 |
ascii := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1634 |
string at: idx put: (Character value: ascii). ]. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1635 |
Verbose |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1636 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1637 |
[ Transcript |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1638 |
show: 'asciz; unicodeString= '; |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1639 |
showCR: string ]. |
752 | 1640 |
^ string |
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1641 |
|
782 | 1642 |
"Modified: / 13-05-2011 / 17:31:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1643 |
! |
1644 |
||
1645 |
readConstant_Utf8 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1646 |
| len bytes string | |
782 | 1647 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1648 |
len := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1649 |
bytes := ByteArray new: len. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1650 |
inStream |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1651 |
nextBytes: len |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1652 |
into: bytes |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1653 |
startingAt: 1. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1654 |
string := CharacterArray fromJavaUTF8Bytes: bytes. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1655 |
Verbose |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1656 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1657 |
[ Transcript |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1658 |
show: 'asciz; string= '; |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1659 |
showCR: string ]. |
752 | 1660 |
^ string |
1661 |
||
1662 |
"Modified: / 19-10-2010 / 12:38:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
782 | 1663 |
"Modified: / 13-05-2011 / 17:31:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1664 |
! ! |
1665 |
||
1666 |
!JavaClassReader methodsFor:'file reading - constants-ST'! |
|
1667 |
||
1668 |
readConstant_ST_Array |
|
1669 |
|aSize arr| |
|
1670 |
||
1671 |
aSize := inStream nextUnsignedShortMSB:msb. |
|
1672 |
arr := Array new:aSize. |
|
1673 |
||
1674 |
1 to:aSize do:[:i | |
|
1675 |
|element_index element| |
|
1676 |
||
1677 |
element_index := inStream nextUnsignedShortMSB:msb. |
|
1678 |
arr at:i put:element_index. |
|
1679 |
]. |
|
1680 |
Verbose ifTrue:[Transcript show:'array; size= '; showCR:aSize]. |
|
1681 |
||
1682 |
^ JavaUnresolvedSTArrayConstant |
|
1683 |
pool:constants |
|
1684 |
poolIndex:constSlot |
|
1685 |
array:arr |
|
1686 |
||
1687 |
"Created: / 7.5.1998 / 11:47:01 / cg" |
|
1688 |
"Modified: / 9.5.1998 / 00:25:34 / cg" |
|
1689 |
! |
|
1690 |
||
1691 |
readConstant_ST_ByteArray |
|
1692 |
|aSize arr| |
|
1693 |
||
1694 |
aSize := inStream nextUnsignedShortMSB:msb. |
|
1695 |
arr := ByteArray new:aSize. |
|
1696 |
||
1697 |
1 to:aSize do:[:i | |
|
1698 |
|element_index| |
|
1699 |
||
1700 |
arr at:i put:(inStream nextByte). |
|
1701 |
]. |
|
1702 |
Verbose ifTrue:[Transcript show:'byteArray; size= '; showCR:aSize]. |
|
1703 |
||
1704 |
^ arr |
|
1705 |
||
1706 |
"Created: / 7.5.1998 / 11:47:12 / cg" |
|
1707 |
! |
|
1708 |
||
1709 |
readConstant_ST_Character |
|
1710 |
|ascii| |
|
1711 |
||
1712 |
ascii := inStream nextUnsignedShortMSB:msb. |
|
1713 |
||
1714 |
Verbose ifTrue:[Transcript show:'char; ascii= '; showCR:ascii]. |
|
1715 |
^ Character value:ascii |
|
1716 |
||
1717 |
"Created: / 7.5.1998 / 11:48:12 / cg" |
|
1718 |
! |
|
1719 |
||
1720 |
readConstant_ST_Special |
|
1721 |
|type| |
|
1722 |
||
1723 |
type := inStream nextUnsignedShortMSB:msb. |
|
1724 |
^ #( |
|
1725 |
nil |
|
1726 |
true |
|
1727 |
false |
|
1728 |
) at:(type + 1) |
|
1729 |
||
1730 |
"Created: / 8.5.1998 / 23:06:56 / cg" |
|
1731 |
"Modified: / 9.5.1998 / 00:40:14 / cg" |
|
1732 |
! |
|
1733 |
||
1734 |
readConstant_ST_String |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1735 |
| tag string_index chars | |
782 | 1736 |
|
1737 |
||
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1738 |
string_index := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1739 |
Verbose |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1740 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1741 |
[ Transcript |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1742 |
show: 'string; index= '; |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1743 |
showCR: string_index ]. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1744 |
|
752 | 1745 |
"/ resolve here if possible |
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1746 |
|
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1747 |
string_index < constSlot |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1748 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1749 |
[ chars := (constants at: string_index). |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1750 |
^ chars ]. |
752 | 1751 |
^ JavaUnresolvedSTStringConstant |
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1752 |
pool: constants |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1753 |
poolIndex: constSlot |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1754 |
stringIndex: string_index |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1755 |
|
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1756 |
"Created: / 07-05-1998 / 11:49:55 / cg" |
782 | 1757 |
"Modified: / 13-05-2011 / 17:32:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1758 |
! |
1759 |
||
1760 |
readConstant_ST_Symbol |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1761 |
| tag string_index chars | |
782 | 1762 |
|
1763 |
||
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1764 |
string_index := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1765 |
Verbose |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1766 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1767 |
[ Transcript |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1768 |
show: 'symbol; index= '; |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1769 |
showCR: string_index ]. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1770 |
|
752 | 1771 |
"/ resolve here if possible |
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1772 |
|
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1773 |
string_index < constSlot |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1774 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1775 |
[ chars := (constants at: string_index). |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1776 |
chars isString ifFalse: [ self halt: 'should not happen' ]. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1777 |
^ chars asSymbol ]. |
752 | 1778 |
^ JavaUnresolvedSTSymbolConstant |
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1779 |
pool: constants |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1780 |
poolIndex: constSlot |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1781 |
stringIndex: string_index |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1782 |
|
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1783 |
"Modified: / 07-05-1998 / 11:48:28 / cg" |
782 | 1784 |
"Modified: / 13-05-2011 / 17:32:09 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1785 |
! ! |
1786 |
||
1787 |
!JavaClassReader methodsFor:'file reading - fields'! |
|
1788 |
||
1789 |
readConstantValueAttributeFor:aField |
|
1790 |
|attribute_length constantvalue_index constantValue| |
|
1791 |
||
1792 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1793 |
||
1794 |
constantvalue_index := inStream nextUnsignedShortMSB:msb. |
|
1795 |
constantValue := constants at:constantvalue_index. |
|
1796 |
||
1797 |
aField constantValue:constantValue. |
|
1798 |
||
1799 |
Verbose ifTrue:[Transcript show:'constantValue: '; showCR:constantValue]. |
|
1800 |
^ true |
|
1801 |
||
1802 |
" |
|
1803 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1804 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1805 |
" |
|
1806 |
||
1807 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
1808 |
"Created: 15.4.1996 / 15:40:17 / cg" |
|
1809 |
! |
|
1810 |
||
1811 |
readFieldInfofield |
|
913 | 1812 |
| access_flags name_index descriptor_index attributes_count field | |
797
8d4e7c17eadd
fixed JavaClassReader so it always sets staticFields
hlopkmar
parents:
796
diff
changeset
|
1813 |
|
752 | 1814 |
access_flags := inStream nextUnsignedShortMSB: msb. |
1815 |
name_index := inStream nextUnsignedShortMSB: msb. |
|
913 | 1816 |
descriptor_index := inStream nextUnsignedShortMSB: msb. |
752 | 1817 |
field := JavaField new. |
1818 |
field setAccessFlags: access_flags. |
|
1819 |
field setName: (constants at: name_index) asSymbol. |
|
913 | 1820 |
field setDescriptor: (constants at: descriptor_index) asSymbol. |
879 | 1821 |
field setConstantPool: constants. |
752 | 1822 |
attributes_count := inStream nextUnsignedShortMSB: msb. |
1823 |
Verbose |
|
1824 |
ifTrue: |
|
1825 |
[ Transcript |
|
1826 |
show: ' field name: '; |
|
1827 |
show: (constants at: name_index); |
|
1828 |
show: ' access: '; |
|
1829 |
show: access_flags; |
|
1830 |
show: ' attrib_cnt: '; |
|
1831 |
showCR: attributes_count ]. |
|
1832 |
1 to: attributes_count do: [:i | self readAttributeFor: field. ]. |
|
1833 |
^ field. |
|
1834 |
||
1835 |
" |
|
1836 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'" |
|
1837 |
||
1838 |
"Created: / 15-04-1996 / 15:38:43 / cg" |
|
1839 |
"Modified: / 15-10-1998 / 10:38:01 / cg" |
|
1840 |
"Modified: / 17-12-2010 / 18:44:30 / Marcel Hlopko <hlopik@gmail.com>" |
|
797
8d4e7c17eadd
fixed JavaClassReader so it always sets staticFields
hlopkmar
parents:
796
diff
changeset
|
1841 |
"Modified: / 18-05-2011 / 14:11:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
913 | 1842 |
"Modified: / 14-08-2011 / 19:40:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 1843 |
! |
1844 |
||
1845 |
readFieldInfofields |
|
1846 |
|nFields fields| |
|
1847 |
||
1848 |
"/ |
|
1849 |
"/ get fieldInfos |
|
1850 |
"/ |
|
1851 |
nFields := inStream nextUnsignedShortMSB:msb. |
|
1852 |
Verbose ifTrue:[Transcript show:'fieldsCount = '; showCR:nFields]. |
|
1853 |
||
1854 |
fields := Array new:nFields. |
|
1855 |
||
1856 |
1 to:nFields do:[:i | |
|
1857 |
Verbose ifTrue:[Transcript show:'field: '; showCR:i]. |
|
1858 |
fields at:i put:(self readFieldInfofield) |
|
1859 |
]. |
|
1860 |
^ fields |
|
1861 |
||
1862 |
" |
|
1863 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1864 |
" |
|
1865 |
||
1866 |
"Created: 15.4.1996 / 15:34:41 / cg" |
|
1867 |
"Modified: 15.4.1996 / 15:35:28 / cg" |
|
1868 |
! ! |
|
1869 |
||
1870 |
!JavaClassReader methodsFor:'file reading - interfaces'! |
|
1871 |
||
1872 |
readInterfaces |
|
1873 |
|interfacesCount interface_index interface interfaces| |
|
1874 |
||
1875 |
"/ |
|
1876 |
"/ get interfaces |
|
1877 |
"/ |
|
1878 |
interfacesCount := inStream nextUnsignedShortMSB:msb. |
|
1879 |
Verbose ifTrue:[Transcript show:'interfacesCount = '; showCR:interfacesCount]. |
|
1880 |
||
1881 |
interfaces := Array new:interfacesCount. |
|
1882 |
||
1883 |
1 to:interfacesCount do:[:i | |
|
1884 |
Verbose ifTrue:[Transcript show:'interface: '; showCR:i]. |
|
1885 |
interface_index := inStream nextUnsignedShortMSB:msb. |
|
1886 |
interface := constants at:interface_index. |
|
1887 |
||
1888 |
interfaces at:i put:interface. |
|
1889 |
]. |
|
1890 |
^ interfaces |
|
1891 |
||
1892 |
" |
|
1893 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1894 |
" |
|
1895 |
||
1896 |
"Created: 15.4.1996 / 15:31:59 / cg" |
|
1897 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
1898 |
! ! |
|
1899 |
||
1900 |
!JavaClassReader methodsFor:'file reading - methods'! |
|
1901 |
||
1902 |
readCodeAttributeFor:aJavaMethod |
|
1903 |
|attribute_length max_stack max_locals code_length code |
|
1904 |
exception_table_length exception_table unknown1 unknown2| |
|
1905 |
||
1906 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1907 |
||
1908 |
Verbose ifTrue:[Transcript show:'code_attribute_length: 0x'; showCR:(attribute_length printStringRadix:16)]. |
|
1909 |
||
1910 |
((minorVsn > 2) or:[majorVsn > 45]) ifTrue:[ |
|
1911 |
"/ should be: |
|
1912 |
max_stack := inStream nextUnsignedShortMSB:msb. |
|
1913 |
max_locals := inStream nextUnsignedShortMSB:msb. |
|
1914 |
code_length := inStream nextUnsignedLongMSB:msb. |
|
1915 |
||
1916 |
"/ unknown1 := inStream nextByte. |
|
1917 |
"/ max_stack := inStream nextByte. |
|
1918 |
"/ max_locals := inStream nextUnsignedShortMSB:msb. |
|
1919 |
"/ unknown2 := inStream nextUnsignedShortMSB:msb. |
|
1920 |
"/ code_length := inStream nextUnsignedShortMSB:msb. |
|
1921 |
"/ Verbose ifTrue:[Transcript show:'?1: '; showCR:unknown1]. |
|
1922 |
"/ Verbose ifTrue:[Transcript show:'?2: '; showCR:unknown2]. |
|
1923 |
] ifFalse:[ |
|
1924 |
max_stack := inStream nextByte. |
|
1925 |
max_locals := inStream nextByte. |
|
1926 |
code_length := inStream nextUnsignedShortMSB:msb. |
|
1927 |
]. |
|
1928 |
||
1929 |
Verbose ifTrue:[ |
|
1930 |
Transcript show:'code_length: '; showCR:(code_length printStringRadix:16). |
|
1931 |
Transcript show:'code at pos: '; showCR:inStream position |
|
1932 |
]. |
|
1933 |
||
1934 |
code_length ~~ 0 ifTrue:[ |
|
1935 |
code := ByteArray new:code_length. |
|
1936 |
inStream nextBytes:code_length into:code startingAt:1. |
|
1937 |
]. |
|
1938 |
Verbose ifTrue:[Transcript show:'method code: '; showCR:code.]. |
|
1939 |
||
1940 |
exception_table_length := inStream nextUnsignedShortMSB:msb. |
|
1941 |
Verbose ifTrue:[Transcript show:'exception_table_length: '; showCR:(exception_table_length printStringRadix:16)]. |
|
1942 |
exception_table_length ~~ 0 ifTrue:[ |
|
1943 |
Verbose ifTrue:[Transcript show:'exceptionTable length:'; showCR:exception_table_length.]. |
|
1944 |
||
1945 |
exception_table := Array new:exception_table_length. |
|
1946 |
1 to:exception_table_length do:[:i | |
|
1947 |
|start_pc end_pc handler_pc catch_type| |
|
1948 |
||
1949 |
start_pc := inStream nextUnsignedShortMSB:msb. |
|
1950 |
end_pc := inStream nextUnsignedShortMSB:msb. |
|
1951 |
handler_pc := inStream nextUnsignedShortMSB:msb. |
|
1952 |
catch_type := inStream nextUnsignedShortMSB:msb. |
|
1953 |
catch_type ~= 0 ifTrue:[ |
|
1954 |
catch_type := constants at:catch_type. |
|
1955 |
]. |
|
1956 |
exception_table at:i put:(JavaExceptionTableEntry |
|
1957 |
startPC:start_pc |
|
1958 |
endPC:end_pc |
|
1959 |
handlerPC:handler_pc |
|
1960 |
catchType:catch_type). |
|
1961 |
]. |
|
1962 |
aJavaMethod setExceptionHandlerTable:exception_table. |
|
1963 |
]. |
|
1964 |
||
1965 |
aJavaMethod |
|
1966 |
setCode:code |
|
1967 |
maxStack:max_stack |
|
1968 |
maxLocals:max_locals |
|
1969 |
u1:unknown1 |
|
1970 |
u2:unknown2. |
|
1971 |
||
1972 |
self readAttributesFor:aJavaMethod. |
|
1973 |
^ true |
|
1974 |
||
1975 |
" |
|
1976 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1977 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1978 |
" |
|
1979 |
||
1980 |
"Created: / 15-04-1996 / 15:40:17 / cg" |
|
1981 |
"Modified: / 16-05-1998 / 01:39:42 / cg" |
|
1982 |
"Modified: / 17-12-2010 / 00:24:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1983 |
! |
|
1984 |
||
1985 |
readExceptionsAttributeFor:aJavaMethod |
|
1986 |
|attribute_length exception_table_length exception_table| |
|
1987 |
||
1988 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1989 |
||
1990 |
exception_table_length := inStream nextUnsignedShortMSB:msb. |
|
1991 |
exception_table_length ~~ 0 ifTrue:[ |
|
1992 |
exception_table := Array new:exception_table_length. |
|
1993 |
1 to:exception_table_length do:[:i | |
|
1994 |
|idx ex| |
|
1995 |
||
1996 |
idx := inStream nextUnsignedShortMSB:msb. |
|
1997 |
ex := constants at:idx. |
|
1998 |
exception_table at:i put:ex. |
|
1999 |
]. |
|
2000 |
]. |
|
2001 |
||
2002 |
Verbose ifTrue:[Transcript showCR:'method has an exceptionTable']. |
|
2003 |
||
2004 |
aJavaMethod setExceptionTable:exception_table. |
|
2005 |
^ true |
|
2006 |
||
2007 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
2008 |
"Created: 15.4.1996 / 15:40:17 / cg" |
|
2009 |
! |
|
2010 |
||
2011 |
readLineNumberTableAttributeFor:aJavaMethod |
|
2012 |
|attribute_length line_number_table_length line_number_table| |
|
2013 |
||
2014 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2015 |
||
2016 |
line_number_table_length := inStream nextUnsignedShortMSB:msb. |
|
2017 |
line_number_table_length ~~ 0 ifTrue:[ |
|
2018 |
line_number_table := Array new:line_number_table_length. |
|
2019 |
1 to:line_number_table_length do:[:i | |
|
2020 |
|start_pc line_number| |
|
2021 |
||
2022 |
start_pc := inStream nextUnsignedShortMSB:msb. |
|
2023 |
line_number := inStream nextUnsignedShortMSB:msb. |
|
2024 |
line_number_table at:i put:(start_pc -> line_number). |
|
2025 |
]. |
|
2026 |
Verbose ifTrue:[Transcript showCR:'method has a lineNumberTable']. |
|
2027 |
||
2028 |
aJavaMethod setLineNumberTable:line_number_table. |
|
2029 |
]. |
|
2030 |
||
2031 |
^ true |
|
2032 |
||
2033 |
" |
|
2034 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2035 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/java/lang/Boolean.class' |
|
2036 |
" |
|
2037 |
||
2038 |
"Created: / 15.4.1996 / 15:40:17 / cg" |
|
2039 |
"Modified: / 7.4.1998 / 19:08:42 / cg" |
|
2040 |
! |
|
2041 |
||
2042 |
readLocalVariableTableAttributeFor:aJavaMethod |
|
2043 |
|attribute_length local_variable_table_length local_variable_table| |
|
2044 |
||
2045 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2046 |
||
2047 |
local_variable_table_length := inStream nextUnsignedShortMSB:msb. |
|
2048 |
local_variable_table_length ~~ 0 ifTrue:[ |
|
2049 |
local_variable_table := JavaLocalVariableTable new:local_variable_table_length. |
|
2050 |
1 to:local_variable_table_length do:[:i | |
|
2051 |
|start_pc length name_index sig_index slot name signature| |
|
2052 |
||
2053 |
start_pc := inStream nextUnsignedShortMSB:msb. |
|
2054 |
length := inStream nextUnsignedShortMSB:msb. |
|
2055 |
name_index := inStream nextUnsignedShortMSB:msb. |
|
2056 |
name := constants at:name_index. |
|
2057 |
sig_index := inStream nextUnsignedShortMSB:msb. |
|
2058 |
signature := constants at:sig_index. |
|
2059 |
slot := inStream nextUnsignedShortMSB:msb. |
|
2060 |
||
2061 |
local_variable_table at:i put:(JavaLocalVariableTableEntry new |
|
2062 |
startPC:start_pc |
|
2063 |
length:length |
|
2064 |
name:name |
|
2065 |
signature:signature |
|
2066 |
slot:slot) |
|
2067 |
]. |
|
2068 |
]. |
|
2069 |
||
2070 |
Verbose ifTrue:[Transcript showCR:'method has a localvariableTable']. |
|
2071 |
||
2072 |
aJavaMethod setLocalVariableTable:local_variable_table. |
|
2073 |
^ true |
|
2074 |
||
2075 |
" |
|
2076 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2077 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/java/lang/Boolean.class' |
|
2078 |
" |
|
2079 |
||
2080 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
2081 |
"Created: 15.4.1996 / 15:40:17 / cg" |
|
2082 |
! |
|
2083 |
||
2084 |
readMethodFor:aClass |
|
913 | 2085 |
|m access_flags name_index name descriptor_index descriptor |
752 | 2086 |
tooManyArgs| |
2087 |
||
2088 |
"/ |
|
2089 |
"/ get a method |
|
2090 |
"/ |
|
2091 |
access_flags := inStream nextUnsignedShortMSB:msb. |
|
2092 |
name_index := inStream nextUnsignedShortMSB:msb. |
|
913 | 2093 |
descriptor_index := inStream nextUnsignedShortMSB:msb. |
752 | 2094 |
|
2095 |
name := constants at:name_index. |
|
913 | 2096 |
descriptor := constants at:descriptor_index. |
752 | 2097 |
|
2098 |
Verbose ifTrue:[ |
|
2099 |
Transcript show:'method name:'; showCR:name. |
|
913 | 2100 |
Transcript show:'descriptor:'; showCR:descriptor. |
752 | 2101 |
]. |
2102 |
||
2103 |
aClass isJavaClass ifTrue:[ |
|
2104 |
(access_flags bitAnd:JavaMethod A_NATIVE) ~~ 0 ifTrue:[ |
|
2105 |
m := JavaNativeMethod new. |
|
2106 |
] ifFalse:[ |
|
2107 |
m := JavaMethodWithHandler new. |
|
2108 |
]. |
|
2109 |
m setAccessFlags:access_flags. |
|
2110 |
tooManyArgs := false. |
|
2111 |
ArgumentError handle:[:ex | |
|
1000 | 2112 |
Logger log: 'java method has too many arguments - will fail to execute' severity: #warn facility: 'JVM'. |
752 | 2113 |
tooManyArgs := true. |
2114 |
ex proceed. |
|
2115 |
] do:[ |
|
913 | 2116 |
m setName:name descriptor:descriptor. |
752 | 2117 |
]. |
2118 |
m setJavaClass:aClass. |
|
2119 |
||
2120 |
self readAttributesFor:m. |
|
2121 |
||
2122 |
tooManyArgs ifTrue:[ |
|
2123 |
m code:nil. |
|
2124 |
m byteCode:nil. |
|
2125 |
]. |
|
2126 |
(m exceptionHandlerTable isNil) ifTrue:[ |
|
2127 |
m isNative ifFalse:[ |
|
2128 |
m getExceptionTable isNil ifTrue:[ |
|
2129 |
m := JavaMethod fromMethod:m |
|
2130 |
] ifFalse:[ |
|
2131 |
m := JavaMethodWithException fromMethod:m |
|
2132 |
] |
|
2133 |
] |
|
2134 |
] ifFalse:[ |
|
2135 |
m setAccessFlags:(m accessFlags bitOr:JavaMethod A_HASHANDLER) |
|
2136 |
]. |
|
913 | 2137 |
aClass addMethod:m name:name signature:descriptor. |
752 | 2138 |
] ifFalse:[ |
2139 |
m := Method new. |
|
2140 |
self readAttributesFor:m. |
|
2141 |
(access_flags bitTest:JavaMethod A_STATIC) ifTrue:[ |
|
2142 |
aClass class primAddSelector:name asSymbol withMethod:m. |
|
2143 |
] ifFalse:[ |
|
2144 |
aClass primAddSelector:name asSymbol withMethod:m. |
|
2145 |
] |
|
2146 |
]. |
|
2147 |
||
2148 |
" |
|
2149 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2150 |
" |
|
2151 |
||
2152 |
"Created: / 15-04-1996 / 16:48:49 / cg" |
|
2153 |
"Modified: / 25-09-1999 / 23:16:25 / cg" |
|
1000 | 2154 |
"Modified: / 14-09-2011 / 22:08:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 2155 |
! |
2156 |
||
2157 |
readMethodsFor:aJavaClass |
|
2158 |
|methodsCount method| |
|
2159 |
||
2160 |
"/ |
|
2161 |
"/ get methods |
|
2162 |
"/ |
|
2163 |
methodsCount := inStream nextUnsignedShortMSB:msb. |
|
2164 |
Verbose ifTrue:[Transcript show:'methodsCount = '; showCR:methodsCount]. |
|
2165 |
||
2166 |
1 to:methodsCount do:[:i | |
|
2167 |
Verbose ifTrue:[Transcript show:'method: '; showCR:i]. |
|
2168 |
method := self readMethodFor:aJavaClass |
|
2169 |
]. |
|
2170 |
||
2171 |
" |
|
2172 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2173 |
" |
|
2174 |
||
2175 |
"Created: / 15.4.1996 / 16:46:30 / cg" |
|
2176 |
"Modified: / 8.5.1998 / 21:20:59 / cg" |
|
2177 |
! ! |
|
2178 |
||
2179 |
!JavaClassReader methodsFor:'file reading - methods-ST'! |
|
2180 |
||
2181 |
readSTCodeAttributeFor:aSmalltalkMethod |
|
2182 |
|attribute_length max_stack max_locals code_length code |
|
2183 |
exception_table_length unknown1 unknown2| |
|
2184 |
||
2185 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2186 |
||
2187 |
Verbose ifTrue:[Transcript show:'attribute_length: 0x'; showCR:(attribute_length printStringRadix:16)]. |
|
2188 |
||
2189 |
max_stack := inStream nextUnsignedShortMSB:msb. |
|
2190 |
max_locals := inStream nextUnsignedShortMSB:msb. |
|
2191 |
||
2192 |
code_length := inStream nextUnsignedLongMSB:msb. |
|
2193 |
Verbose ifTrue:[Transcript show:'code_length: '; showCR:(code_length printStringRadix:16)]. |
|
2194 |
Verbose ifTrue:[Transcript show:'code at pos: '; showCR:inStream position]. |
|
2195 |
||
2196 |
code_length ~~ 0 ifTrue:[ |
|
2197 |
code := ByteArray new:code_length. |
|
2198 |
inStream nextBytes:code_length into:code startingAt:1. |
|
2199 |
]. |
|
2200 |
Verbose ifTrue:[Transcript show:'method code: '; showCR:code.]. |
|
2201 |
||
2202 |
exception_table_length := inStream nextUnsignedShortMSB:msb. |
|
2203 |
Verbose ifTrue:[Transcript show:'exception_table_length: '; showCR:(exception_table_length printStringRadix:16)]. |
|
2204 |
exception_table_length ~~ 0 ifTrue:[ |
|
2205 |
self error:'unexpected exceptionTable length'. |
|
2206 |
"/ skip it. |
|
2207 |
1 to:exception_table_length do:[:i | |
|
2208 |
"start_pc :=" inStream nextUnsignedShortMSB:msb. |
|
2209 |
"end_pc :=" inStream nextUnsignedShortMSB:msb. |
|
2210 |
"handler_pc :=" inStream nextUnsignedShortMSB:msb. |
|
2211 |
"catch_type :=" inStream nextUnsignedShortMSB:msb. |
|
2212 |
]. |
|
2213 |
]. |
|
2214 |
||
2215 |
aSmalltalkMethod byteCode:code. |
|
2216 |
aSmalltalkMethod stackSize:max_stack . |
|
2217 |
aSmalltalkMethod numberOfVars:max_locals. |
|
2218 |
||
2219 |
self readAttributesFor:aSmalltalkMethod. |
|
2220 |
^ true |
|
2221 |
||
2222 |
"Modified: / 16.5.1998 / 01:39:30 / cg" |
|
2223 |
! |
|
2224 |
||
2225 |
readSTLiteralsAttributeFor:aSmalltalkMethod |
|
2226 |
|attribute_length literal_table_length literal_table litIndex literal| |
|
2227 |
||
2228 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2229 |
||
2230 |
literal_table_length := inStream nextUnsignedShortMSB:msb. |
|
2231 |
literal_table_length ~~ 0 ifTrue:[ |
|
2232 |
literal_table := Array new:literal_table_length. |
|
2233 |
1 to:literal_table_length do:[:i | |
|
2234 |
litIndex := inStream nextUnsignedShortMSB:msb. |
|
2235 |
literal := (constants at:litIndex). |
|
2236 |
literal_table at:i put:literal. |
|
2237 |
]. |
|
2238 |
]. |
|
2239 |
Verbose ifTrue:[Transcript show:'literals: '; showCR:literal_table storeString.]. |
|
2240 |
||
2241 |
"Created: / 7.5.1998 / 11:52:28 / cg" |
|
2242 |
"Modified: / 16.5.1998 / 01:52:27 / cg" |
|
2243 |
! |
|
2244 |
||
2245 |
readSTMethodCategoryAttributeFor:aSmalltalkMethod |
|
2246 |
|attribute_length name_index name| |
|
2247 |
||
2248 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2249 |
||
2250 |
name_index := inStream nextUnsignedShortMSB:msb. |
|
2251 |
name := (constants at:name_index). |
|
2252 |
||
2253 |
aSmalltalkMethod category:name. |
|
2254 |
||
2255 |
"Modified: / 8.5.1998 / 20:39:59 / cg" |
|
2256 |
"Created: / 16.5.1998 / 01:04:19 / cg" |
|
2257 |
! ! |
|
2258 |
||
775 | 2259 |
!JavaClassReader methodsFor:'helpers'! |
2260 |
||
798
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
2261 |
loadSuperclassIdentifiedBy: something ignoring: classesBeingLoaded |
877 | 2262 |
"overriding method, here we expect something to be new JavaClassRef2" |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
2263 |
|
877 | 2264 |
self assert: something isJavaRef |
2265 |
message: 'class identifier is not a java reference'. |
|
2266 |
self assert: something isJavaClassRef |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
2267 |
message: 'class identifier is not a java class reference'. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
2268 |
(classesBeingLoaded includes: something name) ifTrue: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
2269 |
self |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
2270 |
error: 'class we want to load is being loaded and that means something went wrong. tell mh' |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
2271 |
]. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
2272 |
"hint in case of bug - is parent of something set? surely jv will know more :)" "find out which classloader is used" |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
2273 |
^ Java javaRegistry classForName: something name definedBy: nil. |
877 | 2274 |
|
2275 |
"Created: / 18-05-2011 / 14:55:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
960 | 2276 |
"Modified: / 31-08-2011 / 21:25:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
798
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
2277 |
! |
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
2278 |
|
775 | 2279 |
updateOwnerInCPItem: each |
2280 |
((each isJavaRef and: [ each isNewJavaRef ]) |
|
2281 |
or: [ each isJavaNameAndType and: [ each isNewJavaNameAndType ] ]) |
|
2282 |
ifTrue: [ each owner: classBeingLoaded ]. |
|
2283 |
||
2284 |
"Created: / 12-05-2011 / 17:40:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
796
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2285 |
! |
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2286 |
|
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2287 |
updateOwnerInField: each |
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2288 |
|
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2289 |
each setClass: classBeingLoaded. |
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2290 |
|
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2291 |
"Created: / 18-05-2011 / 13:57:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
775 | 2292 |
! ! |
2293 |
||
799 | 2294 |
!JavaClassReader methodsFor:'logging'! |
2295 |
||
2296 |
info: message |
|
1000 | 2297 |
Verbose ifTrue: [ Logger log: message severity: #info facility: 'JVM' ]. |
799 | 2298 |
|
2299 |
"Created: / 18-05-2011 / 15:06:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1000 | 2300 |
"Modified (format): / 14-09-2011 / 21:39:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
799 | 2301 |
! ! |
2302 |
||
752 | 2303 |
!JavaClassReader class methodsFor:'documentation'! |
2304 |
||
2305 |
version |
|
1022 | 2306 |
^ '$Id$' |
752 | 2307 |
! |
2308 |
||
2309 |
version_CVS |
|
2310 |
^ '§Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClassReader.st,v 1.92 2009/10/09 14:21:53 cg Exp §' |
|
2311 |
! |
|
2312 |
||
2313 |
version_SVN |
|
1022 | 2314 |
^ '$Id$' |
752 | 2315 |
! ! |
2316 |
||
959 | 2317 |
JavaClassReader initialize! |