author | Claus Gittinger <cg@exept.de> |
Fri, 11 Nov 2016 12:04:39 +0100 | |
branch | cvs_MAIN |
changeset 3655 | 777b31a805e9 |
parent 3654 | 85dcb65aec35 |
child 3665 | a6497adefa64 |
permissions | -rw-r--r-- |
454 | 1 |
" |
3324
a58245c0e83a
Updated copyright notices.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3294
diff
changeset
|
2 |
COPYRIGHT (c) 1996-2015 by Claus Gittinger |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
3 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
4 |
New code and modifications done at SWING Research Group [1]: |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
5 |
|
3324
a58245c0e83a
Updated copyright notices.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3294
diff
changeset
|
6 |
COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko |
2151 | 7 |
SWING Research Group, Czech Technical University in Prague |
8 |
||
454 | 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. |
|
2151 | 15 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
16 |
[1] Code written at SWING Research Group contains a signature |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
17 |
of one of the above copright owners. For exact set of such code, |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
18 |
see the differences between this version and version stx:libjava |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
19 |
as of 1.9.2010 |
454 | 20 |
" |
695 | 21 |
"{ Package: 'stx:libjava' }" |
22 |
||
3384
98eb8443f4f4
Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3324
diff
changeset
|
23 |
"{ NameSpace: Smalltalk }" |
98eb8443f4f4
Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3324
diff
changeset
|
24 |
|
1 | 25 |
Object subclass:#JavaClassReader |
91 | 26 |
instanceVariableNames:'inStream msb constants majorVsn minorVsn constNeeds2Slots |
3003
c9f0019485ff
get rid of old mh breakpoint
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
2966
diff
changeset
|
27 |
constSlot classBeingLoaded classLoader attributes' |
2151 | 28 |
classVariableNames:'Verbose AnnotationsVerbose Silent AbsolutelySilent |
3003
c9f0019485ff
get rid of old mh breakpoint
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
2966
diff
changeset
|
29 |
LazyClassLoading InvalidClassFormatSignal ClassLoaderQuerySignal |
c9f0019485ff
get rid of old mh breakpoint
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
2966
diff
changeset
|
30 |
JavaArchiveCache JavaArchiveCacheLock LastJavaArchive |
3275
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
31 |
LastJavaArchiveLock MaxContextSize MaxContextSizeLimit |
3654 | 32 |
InternedStrings NoClassPathDefinedSignal' |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
33 |
poolDictionaries:'JavaConstants' |
2108 | 34 |
category:'Languages-Java-Support' |
1 | 35 |
! |
36 |
||
454 | 37 |
!JavaClassReader class methodsFor:'documentation'! |
38 |
||
39 |
copyright |
|
40 |
" |
|
3324
a58245c0e83a
Updated copyright notices.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3294
diff
changeset
|
41 |
COPYRIGHT (c) 1996-2015 by Claus Gittinger |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
42 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
43 |
New code and modifications done at SWING Research Group [1]: |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
44 |
|
3324
a58245c0e83a
Updated copyright notices.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3294
diff
changeset
|
45 |
COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko |
2151 | 46 |
SWING Research Group, Czech Technical University in Prague |
47 |
||
454 | 48 |
This software is furnished under a license and may be used |
49 |
only in accordance with the terms of that license and with the |
|
50 |
inclusion of the above copyright notice. This software may not |
|
51 |
be provided or otherwise made available to, or used by, any |
|
52 |
other person. No title to or ownership of the software is |
|
53 |
hereby transferred. |
|
2151 | 54 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
55 |
[1] Code written at SWING Research Group contains a signature |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
56 |
of one of the above copright owners. For exact set of such code, |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
57 |
see the differences between this version and version stx:libjava |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
58 |
as of 1.9.2010 |
2151 | 59 |
|
454 | 60 |
" |
61 |
! ! |
|
1 | 62 |
|
135 | 63 |
!JavaClassReader class methodsFor:'initialization'! |
1 | 64 |
|
3275
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
65 |
flushInternedStrings |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
66 |
self initializeInternedStrings |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
67 |
|
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
68 |
"Created: / 13-11-2014 / 12:13:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
69 |
! |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
70 |
|
1 | 71 |
initialize |
3655 | 72 |
self initializeSignals. |
3654 | 73 |
|
2151 | 74 |
Verbose := false. |
91 | 75 |
Silent := true. |
76 |
AbsolutelySilent := false. |
|
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
77 |
|
3654 | 78 |
"/ Verbose := true. |
79 |
"/ Silent := false. |
|
80 |
||
2151 | 81 |
LazyClassLoading := true. |
3655 | 82 |
"/ LazyClassLoading := false. |
83 |
||
3275
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
84 |
self initializeArchiveCache. |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
85 |
JavaArchiveCacheLock := RecursionLock new. |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
86 |
LastJavaArchiveLock := RecursionLock new. |
2151 | 87 |
AnnotationsVerbose := false. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
88 |
MaxContextSize := 0. |
3275
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
89 |
"Maximum stack depth supported by the VM. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
90 |
if you change it, make sure it is equal (or lower) |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
91 |
to CONSIZE in jinterpret.c (line 111 or so) |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
92 |
Otherwise, VM may crash!!!!!!" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
93 |
MaxContextSizeLimit := 100. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
94 |
|
3275
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
95 |
self initializeInternedStrings. |
29 | 96 |
|
97 |
" |
|
2151 | 98 |
JavaClassReader initialize" |
99 |
||
100 |
"Modified: / 27-01-1998 / 17:54:23 / cg" |
|
101 |
"Modified: / 17-12-2010 / 17:37:45 / Marcel Hlopko <hlopik@gmail.com>" |
|
102 |
"Modified: / 10-05-2011 / 23:59:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
103 |
"Modified: / 14-08-2012 / 02:01:37 / jv" |
3275
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
104 |
"Modified (comment): / 13-11-2014 / 12:12:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
105 |
! |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
106 |
|
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
107 |
initializeArchiveCache |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
108 |
OperatingSystem isMSWINDOWSlike ifFalse:[ |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
109 |
JavaArchiveCache := CacheDictionary new:32. |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
110 |
] ifTrue:[ |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
111 |
JavaArchiveCache := CacheDictionary new:8. |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
112 |
] |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
113 |
! |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
114 |
|
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
115 |
initializeInternedStrings |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
116 |
"Constant pool strings are interned to save memory |
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
117 |
and kept in InternedStrings variable" |
3275
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
118 |
InternedStrings := Set new |
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
119 |
|
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
120 |
"Modified (comment): / 13-11-2014 / 12:12:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3655 | 121 |
! |
122 |
||
123 |
initializeSignals |
|
124 |
InvalidClassFormatSignal := Signal new mayProceed:true. |
|
125 |
InvalidClassFormatSignal notifierString:'class load failure'. |
|
126 |
InvalidClassFormatSignal nameClass:self message:#invalidClassFormatSignal. |
|
127 |
||
128 |
NoClassPathDefinedSignal := Signal new mayProceed:true. |
|
129 |
NoClassPathDefinedSignal notifierString:'no class path defined'. |
|
130 |
NoClassPathDefinedSignal nameClass:self message:#noClassPathDefinedSignal. |
|
131 |
||
132 |
ClassLoaderQuerySignal := QuerySignal new. |
|
133 |
ClassLoaderQuerySignal defaultAnswer:[ JavaVM systemClassLoader ]. |
|
134 |
||
135 |
||
136 |
"Modified: / 27-01-1998 / 17:54:23 / cg" |
|
198 | 137 |
! ! |
138 |
||
139 |
!JavaClassReader class methodsFor:'Signal constants'! |
|
140 |
||
223 | 141 |
classLoaderQuerySignal |
142 |
^ ClassLoaderQuerySignal |
|
143 |
||
144 |
"Created: 14.8.1997 / 19:56:03 / cg" |
|
145 |
! |
|
146 |
||
198 | 147 |
invalidClassFormatSignal |
148 |
^ InvalidClassFormatSignal |
|
149 |
||
150 |
"Created: 3.8.1997 / 18:17:21 / cg" |
|
3654 | 151 |
! |
152 |
||
153 |
noClassPathDefinedSignal |
|
154 |
^ NoClassPathDefinedSignal |
|
1 | 155 |
! ! |
156 |
||
3590 | 157 |
|
344 | 158 |
!JavaClassReader class methodsFor:'constants'! |
159 |
||
2151 | 160 |
fileMajorVersions |
2966 | 161 |
^#( |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
162 |
45 "Java 1.0.2" |
2151 | 163 |
46 "Java 1.2" |
164 |
47 "???" |
|
165 |
48 "???" |
|
166 |
49 "Java 5" |
|
167 |
50 "Java 6" |
|
168 |
). |
|
169 |
||
170 |
" |
|
171 |
JSR 202: |
|
172 |
The Java virtual machine implementation of Sun's JDK release 1.0.2 supports |
|
173 |
class file format versions 45.0 through 45.3 inclusive. Sun's JDK releases |
|
174 |
1.1.X can support class file formats of versions in the range 45.0 through |
|
175 |
45.65535 inclusive. For k > 1 implementations of version 1.k of the Java 2 |
|
176 |
platform can support class file formats of versions in the range 45.0 through |
|
177 |
44+k.0 inclusive. |
|
178 |
" |
|
179 |
||
180 |
"Created: / 19-10-2010 / 21:40:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
181 |
"Modified: / 02-06-2011 / 22:50:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
182 |
"Modified: / 18-08-2011 / 19:32:37 / jv" |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
183 |
"Modified (comment): / 16-08-2012 / 15:34:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
344 | 184 |
! |
185 |
||
2151 | 186 |
fileMinorVersions |
187 |
^ #( |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
188 |
3 "Java 1.0.2 , Java 1.2" |
2151 | 189 |
0 "Java 6" |
190 |
) |
|
191 |
||
192 |
"Created: / 19-10-2010 / 21:41:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
344 | 193 |
! |
194 |
||
195 |
magic_LSB |
|
196 |
^ 16rBEBAFECA |
|
197 |
||
198 |
"Modified: / 7.5.1998 / 13:14:27 / cg" |
|
199 |
"Created: / 7.5.1998 / 13:15:05 / cg" |
|
200 |
! |
|
201 |
||
202 |
magic_MSB |
|
203 |
^ 16rCAFEBABE |
|
204 |
||
205 |
"Modified: / 7.5.1998 / 13:14:27 / cg" |
|
206 |
! ! |
|
207 |
||
135 | 208 |
!JavaClassReader class methodsFor:'debugging'! |
1 | 209 |
|
2966 | 210 |
annotationsVerbose:aBoolean |
2151 | 211 |
AnnotationsVerbose := aBoolean |
212 |
||
213 |
" |
|
214 |
Java flushClasses. |
|
215 |
JavaClassReader verbose:true |
|
216 |
JavaClassReader verbose:false" |
|
217 |
||
218 |
"Created: / 25-02-2011 / 12:25:23 / Marcel Hlopko <hlopik@gmail.com>" |
|
219 |
! |
|
220 |
||
1 | 221 |
verbose:aBoolean |
222 |
Verbose := aBoolean |
|
223 |
||
224 |
" |
|
67 | 225 |
Java flushClasses. |
1 | 226 |
JavaClassReader verbose:true |
227 |
JavaClassReader verbose:false |
|
228 |
" |
|
229 |
! ! |
|
230 |
||
135 | 231 |
!JavaClassReader class methodsFor:'file reading'! |
1 | 232 |
|
2966 | 233 |
readClass: aClassName |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
234 |
"reads a class, and returns it. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
235 |
<clinit> is NOT called, class is NOT installed" |
2966 | 236 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
237 |
^ self readClass: aClassName ignoring: Set new. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
238 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
239 |
"Created: / 15-04-1996 / 14:58:53 / cg" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
240 |
"Modified: / 20-10-1998 / 17:24:54 / cg" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
241 |
"Modified: / 08-09-2011 / 08:10:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
242 |
"Modified (comment): / 07-02-2013 / 14:21:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
21 | 243 |
! |
244 |
||
2966 | 245 |
readClass: aClassName classPath: classPath |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
246 |
"reads a class, and returns it. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
247 |
<clinit> is NOT called, class is NOT installed" |
2966 | 248 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
249 |
^ self readClass: aClassName ignoring: Set new classPath: classPath |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
250 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
251 |
"Created: / 15-04-1996 / 14:58:53 / cg" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
252 |
"Modified: / 20-10-1998 / 17:24:54 / cg" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
253 |
"Modified: / 08-09-2011 / 08:10:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
254 |
"Created: / 30-10-2011 / 12:27:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
255 |
"Modified (comment): / 07-02-2013 / 14:21:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2151 | 256 |
! |
257 |
||
2966 | 258 |
readClass: className ignoring: classesBeingLoadedOrNil |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
259 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
260 |
"This method is bit hacky, as it tries to supply 'correct' |
2966 | 261 |
classloader. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
262 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
263 |
If the class is loaded from Java release classPath (containing |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
264 |
base java classes shipped with JDK/JRE), then set the classloader |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
265 |
to null. Otherwise set class's loader to system class loader |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
266 |
(as returned by ClassLoader#getSystemClassLoader()) |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
267 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
268 |
This is required to run groovy and other SW that uses resources |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
269 |
or other classloader dependent stuff. When changing, make sure |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
270 |
Groovy is running afterwards!!!!!! |
7 | 271 |
" |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
272 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
273 |
| class | |
2966 | 274 |
class := self |
275 |
readClass: className ignoring: classesBeingLoadedOrNil |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
276 |
classPath: Java release classPath. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
277 |
class notNil ifTrue:[ ^ class ]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
278 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
279 |
class isNil ifTrue:[ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
280 |
JavaVM booted ifFalse:[ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
281 |
^nil |
350 | 282 |
]. |
3655 | 283 |
ClassLoaderQuerySignal answer: JavaVM systemClassLoader do:[ |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
284 |
class := self |
2966 | 285 |
readClass: className ignoring: classesBeingLoadedOrNil |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
286 |
classPath: Java classPath. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
287 |
]. |
327 | 288 |
]. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
289 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
290 |
^class |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
291 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
292 |
"Created: / 15-04-1996 / 14:58:53 / cg" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
293 |
"Modified: / 20-10-1998 / 17:24:54 / cg" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
294 |
"Modified: / 21-10-2011 / 13:39:14 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
295 |
"Modified: / 30-10-2011 / 16:50:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2151 | 296 |
! |
297 |
||
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
298 |
readClass: className ignoring: ignoring classPath: classPath |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
299 |
| cls | |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
300 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
301 |
cls := self new readClass: className ignoring: ignoring classPath: classPath. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
302 |
cls notNil ifTrue:[ |
2966 | 303 |
Logger |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
304 |
log: 'loaded class ' , cls displayString |
3384
98eb8443f4f4
Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3324
diff
changeset
|
305 |
severity: Logger severityTRACE |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
306 |
facility: 'JVM'. |
54 | 307 |
]. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
308 |
^cls. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
309 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
310 |
"Created: / 07-02-2013 / 14:34:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3384
98eb8443f4f4
Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3324
diff
changeset
|
311 |
"Modified: / 02-03-2015 / 14:08:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
43 | 312 |
! |
313 |
||
2966 | 314 |
readFile:aFilename ignoring:classesBeingLoaded |
7 | 315 |
"reads a class from aFilename and returns it. |
91 | 316 |
The JavaClass is NOT installed as global and unresolved |
317 |
refs are NOT patched." |
|
2966 | 318 |
|
2476
d24ce8174195
JavaClass can now keep it's classfile bytes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2431
diff
changeset
|
319 |
| inStream | |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
320 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
321 |
[ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
322 |
JavaVM commonOpenStreamUsing:[ inStream := aFilename asFilename readStream ] |
2966 | 323 |
] on:StreamError do:[:ex | |
324 |
Logger |
|
3384
98eb8443f4f4
Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3324
diff
changeset
|
325 |
log:('cannot read .class file: ' , ex description) severity:Logger severityERROR facility:'JVM'. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
326 |
self breakPoint: #jv. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
327 |
^ nil |
43 | 328 |
]. |
21 | 329 |
|
2476
d24ce8174195
JavaClass can now keep it's classfile bytes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2431
diff
changeset
|
330 |
^[ |
d24ce8174195
JavaClass can now keep it's classfile bytes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2431
diff
changeset
|
331 |
self readStream:inStream ignoring:classesBeingLoaded. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
332 |
] ensure:[ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
333 |
inStream close. |
91 | 334 |
]. |
1 | 335 |
|
2151 | 336 |
"Created: / 15-04-1996 / 14:58:53 / cg" |
337 |
"Modified: / 09-05-1998 / 01:44:24 / cg" |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
338 |
"Modified: / 14-08-2012 / 02:17:26 / jv" |
3384
98eb8443f4f4
Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3324
diff
changeset
|
339 |
"Modified: / 02-03-2015 / 14:08:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 340 |
! |
341 |
||
2966 | 342 |
readStream: aStream |
198 | 343 |
"reads a class from aStream and returns it. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
344 |
The JavaClass is not installed as global" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
345 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
346 |
^self readStream: aStream ignoring: Set new. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
347 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
348 |
"Created: / 24-10-2011 / 00:12:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
198 | 349 |
! |
350 |
||
2966 | 351 |
readStream: stream ignoring: classesBeingLoaded |
2578
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
352 |
"reads a class from aStream and returns it. |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
353 |
The JavaClass is not installed as global" |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
354 |
|
3655 | 355 |
^self readStream: stream loader: ClassLoaderQuerySignal query ignoring: classesBeingLoaded |
2578
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
356 |
|
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
357 |
"Modified: / 30-03-1998 / 18:14:40 / cg" |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
358 |
"Modified: / 09-05-2011 / 23:15:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
359 |
"Modified: / 02-05-2013 / 09:51:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
360 |
! |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
361 |
|
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
362 |
readStream: stream loader: classloader |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
363 |
"reads a class from aStream and returns it. |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
364 |
The JavaClass is not installed as global" |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
365 |
|
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
366 |
^self readStream: stream loader: classloader ignoring: Set new. |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
367 |
|
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
368 |
"Created: / 02-05-2013 / 09:51:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
369 |
! |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
370 |
|
2966 | 371 |
readStream: stream loader: classloader ignoring: classesBeingLoaded |
7 | 372 |
"reads a class from aStream and returns it. |
373 |
The JavaClass is not installed as global" |
|
2966 | 374 |
|
2151 | 375 |
| javaClass | |
376 |
||
2578
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
377 |
javaClass := JavaClassReader new readStream: stream loader: classloader ignoring: classesBeingLoaded. |
2966 | 378 |
Logger |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
379 |
log: 'loaded class ' , javaClass displayString |
3384
98eb8443f4f4
Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3324
diff
changeset
|
380 |
severity: Logger severityTRACE |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
381 |
facility: 'JVM'. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
382 |
^ javaClass. |
327 | 383 |
|
2578
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
384 |
"Created: / 02-05-2013 / 09:50:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3384
98eb8443f4f4
Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3324
diff
changeset
|
385 |
"Modified: / 02-03-2015 / 14:08:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
386 |
! ! |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
387 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
388 |
!JavaClassReader class methodsFor:'obsolete'! |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
389 |
|
2966 | 390 |
resolveClass: aJavaClass |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
391 |
"Resolve a particular classes' constants. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
392 |
Perform all class initialization functions |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
393 |
(of those which are not yet initialized)." |
2966 | 394 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
395 |
| loader classToLoad | |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
396 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
397 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
398 |
"new resolving does not need this - shouldn't be called at all" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
399 |
LazyClassLoading ifFalse: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
400 |
loader := (aJavaClass classLoader). |
399 | 401 |
[ |
402 |
classToLoad := nil. |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
403 |
aJavaClass constantPool do: [ |
2966 | 404 |
:item | |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
405 |
| itemClass | |
399 | 406 |
|
407 |
itemClass := item class. |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
408 |
itemClass == JavaUnresolvedClassConstant ifTrue: [ |
399 | 409 |
classToLoad := item className. |
2966 | 410 |
|
399 | 411 |
"/ ] ifFalse:[ |
412 |
"/ itemClass == JavaUnresolvedMethodrefConstant ifTrue:[ |
|
413 |
"/self halt. |
|
414 |
"/ ] ifFalse:[ |
|
415 |
"/ itemClass == JavaUnresolvedInterfaceMethodrefConstant ifTrue:[ |
|
416 |
"/self halt. |
|
417 |
"/ ] |
|
418 |
"/ ] |
|
419 |
]. |
|
420 |
]. |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
421 |
classToLoad notNil ifTrue: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
422 |
loader isNil ifTrue: [ JavaVM classForName: classToLoad. ] ifFalse: [ |
399 | 423 |
"/ |
3590 | 424 |
"/ the acquired loader is a javaClassLoader |
399 | 425 |
"/ which expects an URL as arg. |
426 |
"/ |
|
427 |
"/ classURL := Java as_URL:('file:' , nextUnresolved asString , '.class'). |
|
428 |
"/ loader loadClass:classURL |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
429 |
loader perform: #'loadClass(Ljava/lang/String;)Ljava/lang/Class;' |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
430 |
with: (Java as_String: (classToLoad asString)). |
399 | 431 |
] |
432 |
]. |
|
433 |
classToLoad notNil. |
|
434 |
] whileTrue. |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
435 |
aJavaClass isInitialized ifFalse: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
436 |
Silent ifFalse: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
437 |
'performing class initialization of ' print. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
438 |
aJavaClass fullName printCR. |
399 | 439 |
]. |
440 |
aJavaClass classInit |
|
441 |
]. |
|
442 |
] |
|
443 |
||
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
444 |
"Created: / 20-10-1998 / 17:53:22 / cg" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
445 |
"Modified: / 16-11-2011 / 14:39:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
2151 | 446 |
! ! |
447 |
||
2578
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
448 |
!JavaClassReader class methodsFor:'others'! |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
449 |
|
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
450 |
version_HG |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
451 |
|
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
452 |
^ '$Changeset: <not expanded> $' |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
453 |
! ! |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
454 |
|
2151 | 455 |
!JavaClassReader methodsFor:'accessing'! |
456 |
||
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
457 |
constantPoolAt: index |
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
458 |
^ constants at: index |
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
459 |
|
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
460 |
! |
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
461 |
|
2966 | 462 |
constants |
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
463 |
^ constants. |
2151 | 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 |
||
1 | 486 |
!JavaClassReader methodsFor:'file reading'! |
487 |
||
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
488 |
readClass: clsName from: path ignoring: classesBeingLoaded |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
489 |
"load class named clsName from directory or .jar archive path. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
490 |
<clinit> is NOT called, class is NOT installed as global" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
491 |
|
2931
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
492 |
| nm p zar zarAndRefcount entry zipFile read rslt | |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
493 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
494 |
p := path asString. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
495 |
p asFilename isDirectory ifTrue: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
496 |
| f | |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
497 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
498 |
(p endsWith: Filename separator) ifFalse: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
499 |
p := p , (Filename separator asString) |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
500 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
501 |
nm := p , clsName , '.class'. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
502 |
(f := nm asFilename) exists ifTrue: [ |
2966 | 503 |
(Java isExcludedFromClassPath: nm) ifFalse: [ |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
504 |
"means we are successfully going to read something :)" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
505 |
f readingFileDo:[:s|rslt := self readStream: s ignoring: classesBeingLoaded]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
506 |
rslt notNil ifTrue: [ ^ rslt. ]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
507 |
] |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
508 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
509 |
] ifFalse: [ |
2966 | 510 |
((zipFile := p asFilename withSuffix: 'jar') exists |
511 |
or: [ (zipFile := p asFilename withSuffix: 'zip') exists ]) |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
512 |
ifTrue: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
513 |
"/ Do not use at:ifAbsentPut: here, JavaArchiveCache is a CacheDictionary!!!!!! |
2931
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
514 |
JavaArchiveCacheLock critical:[ |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
515 |
zarAndRefcount := JavaArchiveCache at: zipFile ifAbsent: nil. |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
516 |
zarAndRefcount isNil ifTrue:[ |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
517 |
JavaVM commonOpenStreamUsing:[ zar := ZipArchive oldFileNamed: zipFile ]. |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
518 |
JavaArchiveCache at: zipFile put: (zarAndRefcount := Array with: zar with: 1) |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
519 |
] ifFalse:[ |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
520 |
zar := zarAndRefcount first. |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
521 |
zarAndRefcount at: 2 put: (zarAndRefcount at: 2) + 1. |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
522 |
]. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
523 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
524 |
read := [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
525 |
nm := clsName , '.class'. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
526 |
|
2604
b9cb81e47766
Lost changes meant to be commited in 7af1671fc73f.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2602
diff
changeset
|
527 |
(zar isValidFile: nm) ifTrue: [ |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
528 |
(Java isExcludedFromClassPath: nm) ifFalse: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
529 |
JavaVM commonOpenStreamUsing:[ zar := zar reopenForReading ]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
530 |
entry := zar extract: nm. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
531 |
rslt := self readStream: (entry readStream) ignoring: classesBeingLoaded. |
2966 | 532 |
rslt notNil ifTrue: [ |
2931
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
533 |
JavaArchiveCacheLock critical:[ |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
534 |
zarAndRefcount at: 2 put: (zarAndRefcount at: 2) - 1. |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
535 |
]. |
2966 | 536 |
^ rslt |
2931
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
537 |
]. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
538 |
] |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
539 |
]. |
2931
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
540 |
JavaArchiveCacheLock critical:[ |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
541 |
zarAndRefcount at: 2 put: (zarAndRefcount at: 2) - 1. |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
542 |
(zarAndRefcount at: 2) == 0 ifTrue:[ |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
543 |
zar closeFile. |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
544 |
]. |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
545 |
]. |
e215dba1f0fb
Fix in JavaClassReader for concurrent access to zipa archives.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2914
diff
changeset
|
546 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
547 |
]. |
2966 | 548 |
JavaClassReader invalidClassFormatSignal |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
549 |
handle: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
550 |
"Kludge, sometimes zar gets corrupted" |
2946
5f8f0ac505a5
Fix in JavaClassReader>>#readClass:from:ignoring: (fix wrong code for zar refcounting)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2942
diff
changeset
|
551 |
JavaArchiveCache at: zipFile put: (Array with: (zar := JavaVM commonOpenStreamUsing: [ZipArchive oldFileNamed: zipFile]) with: 1). |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
552 |
read value |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
553 |
] |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
554 |
do: [ read value ]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
555 |
] |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
556 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
557 |
^nil |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
558 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
559 |
"Created: / 03-12-2012 / 22:47:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2966 | 560 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
561 |
! |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
562 |
|
2966 | 563 |
readClass: className ignoring: classesBeingLoadedOrNil classPath: classPath |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
564 |
"searches classspath for a class, loads it and returns. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
565 |
<clinit> is not called, class is not installed as global" |
2966 | 566 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
567 |
| rslt clsName classesBeingLoaded | |
3654 | 568 |
|
569 |
classPath isNil ifTrue:[ |
|
570 |
NoClassPathDefinedSignal raiseRequest. |
|
571 |
^ nil |
|
572 |
]. |
|
573 |
||
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
574 |
clsName := className asSlashedJavaClassName. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
575 |
classesBeingLoaded := classesBeingLoadedOrNil. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
576 |
classesBeingLoaded isNil ifTrue: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
577 |
classesBeingLoaded := Set new. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
578 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
579 |
classesBeingLoaded add: clsName. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
580 |
|
2966 | 581 |
classPath do: [:path | |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
582 |
rslt := self readClass: clsName from: path ignoring: classesBeingLoaded. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
583 |
rslt notNil ifTrue:[ ^rslt ]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
584 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
585 |
^nil. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
586 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
587 |
"Created: / 15-04-1996 / 14:58:53 / cg" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
588 |
"Modified: / 20-10-1998 / 17:24:54 / cg" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
589 |
"Created: / 23-10-2011 / 21:48:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
590 |
"Modified: / 03-11-2011 / 18:14:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
591 |
"Modified: / 14-08-2012 / 02:17:59 / jv" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
592 |
"Modified: / 07-02-2013 / 14:19:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
593 |
! |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
594 |
|
2966 | 595 |
readClassFileIgnoring: classesbeingLoaded |
7 | 596 |
"reads a class from inStream and returns it. |
38 | 597 |
The JavaClass is not installed as global and its constants |
598 |
(especially strings) may not be fully resolved." |
|
2966 | 599 |
|
3288
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
600 |
| access_flags this_class_index super_class super_class_index this_class_ref existingSuperClass fields interfaces staticFields nStatic superClassName thisClassName existing_class thisMetaClass | |
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
601 |
|
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
602 |
self readMagic. |
3289
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
603 |
self readVersion. |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
604 |
|
1 | 605 |
"/ |
606 |
"/ get constant pool |
|
607 |
"/ |
|
2966 | 608 |
|
1 | 609 |
self readConstantPool. |
2966 | 610 |
|
1 | 611 |
"/ |
612 |
"/ access flags |
|
613 |
"/ |
|
2966 | 614 |
|
2151 | 615 |
access_flags := inStream nextUnsignedShortMSB: msb. |
616 |
this_class_index := inStream nextUnsignedShortMSB: msb. |
|
617 |
super_class_index := inStream nextUnsignedShortMSB: msb. |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
618 |
super_class_index == 0 ifTrue: [ super_class := nil ] ifFalse: [ |
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
619 |
super_class := self constantPoolAt: super_class_index. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
620 |
superClassName := super_class fullName. |
2966 | 621 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
622 |
"/ special for ST-classes |
2966 | 623 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
624 |
(superClassName startsWith: 'smalltalk.') ifTrue: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
625 |
"/ a Smalltalk class |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
626 |
superClassName := superClassName copyFrom: 11. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
627 |
existingSuperClass := Smalltalk at: superClassName asSymbol. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
628 |
existingSuperClass notNil ifTrue: [ super_class := existingSuperClass ] ifFalse: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
629 |
"/ self halt - must load superclass ... |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
630 |
] |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
631 |
] ifFalse: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
632 |
"/ a JAVA class |
2578
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
633 |
super_class := JavaVM classNamed: superClassName definedBy: classLoader. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
634 |
super_class isNil ifTrue: [ |
2966 | 635 |
super_class := self |
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
636 |
loadSuperclassIdentifiedBy: (self constantPoolAt: super_class_index) |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
637 |
ignoring: classesbeingLoaded |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
638 |
]. |
2460 | 639 |
super_class isNil ifTrue: [ |
2966 | 640 |
self breakPoint:#jv info: 'Cannot find super class?!!' |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
641 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
642 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
643 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
644 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
645 |
"/ If superclass is finalized, mark class so as well. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
646 |
(super_class notNil and:[super_class hasFinalize]) ifTrue:[ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
647 |
access_flags := access_flags bitOr: ACX_HASFINALIZE |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
648 |
]. |
2966 | 649 |
|
1 | 650 |
"/ |
651 |
"/ get interfaces |
|
652 |
"/ |
|
2966 | 653 |
|
38 | 654 |
interfaces := self readInterfaces. |
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
655 |
interfaces do:[:ifaceRefIndex | |
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
656 |
(self constantPoolAt: ifaceRefIndex) javaClassName = 'java/lang/Cloneable' ifTrue:[ |
2914
1f4c3054998c
Native java.lang.Object#clone() refactored to use ACX_CLOENABLE flag.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2868
diff
changeset
|
657 |
access_flags := access_flags bitOr: ACX_CLONEABLE. |
2966 | 658 |
]. |
2914
1f4c3054998c
Native java.lang.Object#clone() refactored to use ACX_CLOENABLE flag.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2868
diff
changeset
|
659 |
]. |
2966 | 660 |
|
1 | 661 |
"/ |
662 |
"/ get fields |
|
663 |
"/ |
|
2966 | 664 |
|
38 | 665 |
fields := self readFieldInfofields. |
2966 | 666 |
|
40 | 667 |
"/ |
668 |
"/ create the fields as instVars |
|
669 |
"/ static fields are created as class-InstVars |
|
670 |
"/ |
|
2966 | 671 |
|
2151 | 672 |
staticFields := fields select: [:f | f isStatic ]. |
40 | 673 |
nStatic := staticFields size. |
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
674 |
this_class_ref := self constantPoolAt: this_class_index. |
2868
90724c4fa7f8
Fix to recompile erroneous classes upon reload.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2866
diff
changeset
|
675 |
thisClassName := this_class_ref name. |
2914
1f4c3054998c
Native java.lang.Object#clone() refactored to use ACX_CLOENABLE flag.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2868
diff
changeset
|
676 |
thisClassName = 'java/lang/Cloneable' ifTrue:[ |
1f4c3054998c
Native java.lang.Object#clone() refactored to use ACX_CLOENABLE flag.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2868
diff
changeset
|
677 |
access_flags := access_flags bitOr: ACX_CLONEABLE. |
1f4c3054998c
Native java.lang.Object#clone() refactored to use ACX_CLOENABLE flag.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2868
diff
changeset
|
678 |
]. |
2966 | 679 |
|
350 | 680 |
"/ care for smalltalk classes ... |
2966 | 681 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
682 |
(thisClassName startsWith: 'smalltalk.') ifTrue: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
683 |
thisClassName := thisClassName copyFrom: 11. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
684 |
existing_class := Smalltalk at: thisClassName asSymbol. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
685 |
existing_class notNil ifTrue: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
686 |
self halt: ('overloading existing class: ' , thisClassName). |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
687 |
thisClassName := (thisClassName , '_new') asSymbol. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
688 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
689 |
thisMetaClass := Metaclass new. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
690 |
thisMetaClass setSuperclass: super_class class. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
691 |
thisMetaClass instSize: (super_class class instSize + nStatic). |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
692 |
classBeingLoaded := thisMetaClass new. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
693 |
classBeingLoaded setSuperclass: super_class. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
694 |
classBeingLoaded setName: thisClassName asSymbol. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
695 |
] ifFalse: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
696 |
"/ a java class |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
697 |
Class withoutUpdatingChangesDo:[ |
2841
6fa1bcf9c997
JavaClass>>#name vs. #binaryName refactoring
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2812
diff
changeset
|
698 |
classBeingLoaded := JavaClass binaryName: thisClassName numStatic: nStatic. |
3655 | 699 |
classBeingLoaded classLoader: ClassLoaderQuerySignal query. |
2151 | 700 |
fields := fields select: [:f | f isStatic not ]. |
701 |
JavaClass setInstanceVariableStringFromFields: staticFields |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
702 |
in: classBeingLoaded class. |
2151 | 703 |
classBeingLoaded setStaticFields: staticFields. |
704 |
classBeingLoaded setAccessFlags: access_flags. |
|
705 |
classBeingLoaded setSuperclass: super_class. |
|
706 |
classBeingLoaded setConstantPool: constants. |
|
707 |
classBeingLoaded setFields: fields. |
|
708 |
classBeingLoaded setInterfaces: interfaces. |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
709 |
] |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
710 |
]. |
2966 | 711 |
|
1 | 712 |
"/ |
713 |
"/ get methods |
|
714 |
"/ |
|
2966 | 715 |
|
2151 | 716 |
self readMethodsFor: classBeingLoaded. |
717 |
self readAttributesFor: classBeingLoaded. |
|
2729
ac412f6ea6d4
More support for method's source display. Not yet working.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2591
diff
changeset
|
718 |
classBeingLoaded setAttributes: attributes. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
719 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
720 |
"/ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
721 |
"/ get extensions |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
722 |
"/ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
723 |
self readExtensionsFor: classBeingLoaded. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
724 |
|
2151 | 725 |
classBeingLoaded fields do: [:each | self updateOwnerInField: each ]. |
2966 | 726 |
classBeingLoaded staticFields do: [:each | self updateOwnerInField: each ]. |
2578
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
727 |
classBeingLoaded classLoader: classLoader. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
728 |
classesbeingLoaded remove: classBeingLoaded name ifAbsent:[]. |
2151 | 729 |
^ classBeingLoaded. |
5 | 730 |
|
1 | 731 |
" |
355 | 732 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
733 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
734 |
JavaClassReader loadFile:'foo.cls' |
|
9 | 735 |
|
736 |
JavaClassReader verbose:true. |
|
355 | 737 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/java/lang/ArithmeticException.class' |
2151 | 738 |
JavaClassReader loadFile:'/phys/ibm3/java/lib/java/lang/ArithmeticException.class'" |
739 |
||
740 |
"Created: / 15-04-1996 / 15:02:47 / cg" |
|
741 |
"Modified: / 12-11-1998 / 21:14:45 / cg" |
|
742 |
"Modified: / 15-10-2010 / 17:37:38 / Jan Kurs <kurs.jan@post.cz>" |
|
743 |
"Modified: / 28-01-2011 / 15:09:48 / Marcel Hlopko <hlopik@gmail.com>" |
|
744 |
"Modified: / 18-05-2011 / 15:30:29 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
745 |
"Modified (format): / 27-11-2014 / 17:02:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3288
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
746 |
! |
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
747 |
|
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
748 |
readMagic |
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
749 |
"Read magic, determine byte order" |
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
750 |
| magic | |
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
751 |
|
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
752 |
msb := true. |
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
753 |
magic := inStream nextUnsignedLongMSB: true. |
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
754 |
magic = (self class magic_MSB) ifFalse: [ |
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
755 |
magic = (self class magic_LSB) ifFalse: [ |
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
756 |
InvalidClassFormatSignal raiseErrorString: 'not a java class file'. |
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
757 |
^ nil |
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
758 |
]. |
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
759 |
msb := false. |
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
760 |
] |
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
761 |
|
90f0566d8145
Extracted readMagic to alow lazy loading of constant pool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3279
diff
changeset
|
762 |
"Created: / 04-12-2014 / 17:32:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
5 | 763 |
! |
764 |
||
54 | 765 |
readStream:aStream ignoring:classesBeingLoaded |
2578
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
766 |
<resource: #obsolete> |
7 | 767 |
"reads a class from aStream and returns it. |
768 |
The JavaClass is not installed as global" |
|
769 |
||
3655 | 770 |
^self readStream:aStream loader: ClassLoaderQuerySignal query ignoring:classesBeingLoaded |
2578
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
771 |
|
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
772 |
|
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
773 |
" |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
774 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
775 |
" |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
776 |
|
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
777 |
"Created: / 15-04-1996 / 15:00:55 / cg" |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
778 |
"Modified: / 02-05-2013 / 09:53:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
779 |
! |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
780 |
|
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
781 |
readStream:stream loader: classloader ignoring:classesBeingLoaded |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
782 |
"reads a class from aStream and returns it. |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
783 |
The JavaClass is not installed as global" |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
784 |
|
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
785 |
inStream := stream. |
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
786 |
classLoader := classloader. |
5 | 787 |
inStream binary. |
38 | 788 |
|
54 | 789 |
^ self readClassFileIgnoring:classesBeingLoaded |
5 | 790 |
|
791 |
" |
|
792 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
793 |
" |
|
794 |
||
2578
fc6186a4961f
Performance optimization: rewrote 'JavaVM classNamed:' to 'JavaVM classNamed:...definedBy:...'.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2566
diff
changeset
|
795 |
"Created: / 02-05-2013 / 09:52:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3289
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
796 |
! |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
797 |
|
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
798 |
readVersion |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
799 |
minorVsn := inStream nextUnsignedShortMSB: msb. |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
800 |
majorVsn := inStream nextUnsignedShortMSB: msb. |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
801 |
((self class fileMajorVersions includes: majorVsn) not |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
802 |
or: [ (self class fileMinorVersions includes: minorVsn) not ]) |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
803 |
ifTrue: [ |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
804 |
| path | |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
805 |
|
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
806 |
path := inStream isFileStream ifTrue:[ |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
807 |
path := inStream pathName |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
808 |
] ifFalse:[ |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
809 |
path := '<memory>' |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
810 |
]. |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
811 |
Verbose ifTrue:[ |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
812 |
self info: |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
813 |
('class reader: file ', path , ' has version ' , |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
814 |
majorVsn printString , |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
815 |
'.' , minorVsn printString) |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
816 |
]. |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
817 |
|
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
818 |
]. |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
819 |
|
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
820 |
"Created: / 06-12-2014 / 13:37:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
5 | 821 |
! ! |
822 |
||
823 |
!JavaClassReader methodsFor:'file reading - attributes'! |
|
824 |
||
2966 | 825 |
readAnnotationDefaultAttributeFor:something |
2151 | 826 |
"/ ('JAVA [info]: unhandled attribute: AnnotationDefault') infoPrintCR. |
2966 | 827 |
|
2151 | 828 |
|len startPos endPos annotationDefault| |
829 |
||
830 |
self assert:something isJavaMethod |
|
3616 | 831 |
message:'AnnotationDefault may only occur for methods!!'. |
2151 | 832 |
len := inStream nextUnsignedLongMSB:msb. |
833 |
startPos := inStream position. |
|
834 |
annotationDefault := (something ensureHasAnnotations) |
|
2966 | 835 |
default:(JavaAnnotationDefault new |
2151 | 836 |
value:(self readAnnotationValueFor:something)); |
837 |
default. |
|
838 |
endPos := inStream position. |
|
839 |
inStream position:startPos. |
|
840 |
annotationDefault bytes:(inStream next:len). |
|
841 |
self assert:inStream position = endPos |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
842 |
message:'self readAnnotationValueFor: something is reading what it shouldn'. |
2151 | 843 |
|
844 |
"Modified: / 28-02-2011 / 17:08:28 / Marcel Hlopko <hlopik@gmail.com>" |
|
845 |
"Modified: / 03-03-2011 / 23:06:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
846 |
! |
|
847 |
||
2966 | 848 |
readAnnotationFor:something |
2151 | 849 |
| typeIndex type result attrsCount | |
850 |
||
851 |
typeIndex := inStream nextUnsignedShortMSB:msb. |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
852 |
type := self constantPoolAt:typeIndex. |
2151 | 853 |
attrsCount := inStream nextUnsignedShortMSB:msb. |
854 |
result := JavaAnnotation for:something. |
|
855 |
result name:type. |
|
856 |
attrsCount timesRepeat: |
|
3385
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
857 |
[ | nameIndex name attr | |
2151 | 858 |
|
859 |
nameIndex := inStream nextUnsignedShortMSB:msb. |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
860 |
name := self constantPoolAt:nameIndex. |
2151 | 861 |
attr := self readAnnotationValueFor:something. |
862 |
attr name:name. |
|
3294
1013708261a8
JavaClass memory optimization (part 5)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3293
diff
changeset
|
863 |
result values at: name put:attr. |
2966 | 864 |
AnnotationsVerbose |
3385
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
865 |
ifTrue:[ Logger |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
866 |
log:('JAVA [INFO]: Reading annotation attribute: ' , name) |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
867 |
severity:Logger severityDEBUG |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
868 |
facility:#JVM. ]. ]. |
2151 | 869 |
^ result. |
870 |
||
871 |
"Created: / 17-12-2010 / 16:21:28 / Marcel Hlopko <hlopik@gmail.com>" |
|
872 |
"Modified: / 25-02-2011 / 12:25:36 / Marcel Hlopko <hlopik@gmail.com>" |
|
3294
1013708261a8
JavaClass memory optimization (part 5)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3293
diff
changeset
|
873 |
"Modified: / 08-12-2014 / 16:23:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3385
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
874 |
"Modified (format): / 02-03-2015 / 16:04:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2148 | 875 |
! |
876 |
||
2966 | 877 |
readAnnotationValueFor:something |
2151 | 878 |
| tag result | |
879 |
||
880 |
tag := (inStream nextByte) asCharacter. |
|
2966 | 881 |
tag = $e |
2151 | 882 |
ifTrue: |
883 |
[ result := JavaAnnotationEnumValue for:something. |
|
884 |
result nameIndex:(inStream nextUnsignedShortMSB:msb). |
|
885 |
result valueIndex:(inStream nextUnsignedShortMSB:msb). |
|
2966 | 886 |
AnnotationsVerbose |
2151 | 887 |
ifTrue: |
3385
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
888 |
[ Logger |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
889 |
log:('JAVA [INFO]: Reading annotation enum value: ' |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
890 |
, result name printString , ' -> ' |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
891 |
, result value printString) |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
892 |
severity:Logger severityDEBUG |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
893 |
facility:#JVM ]. |
2151 | 894 |
^ result ]. |
2966 | 895 |
tag = $c |
2151 | 896 |
ifTrue: |
897 |
[ result := JavaAnnotationClassValue for:something. |
|
898 |
result classIndex:(inStream nextUnsignedShortMSB:msb). |
|
2966 | 899 |
AnnotationsVerbose |
2151 | 900 |
ifTrue: |
3385
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
901 |
[ Logger |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
902 |
log:('JAVA [INFO]: Reading annotation class value: ' |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
903 |
, result name printString , ' -> ' |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
904 |
, result value printString) |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
905 |
severity:Logger severityDEBUG |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
906 |
facility:#JVM ]. |
2151 | 907 |
^ result ]. |
2966 | 908 |
tag = $@ |
2151 | 909 |
ifTrue: |
910 |
[ result := JavaAnnotationNestedAnnotationValue for:something. |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
911 |
result nestedAnnotation:(self readAnnotationFor: something). |
2966 | 912 |
AnnotationsVerbose |
2151 | 913 |
ifTrue: |
3385
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
914 |
[ Logger |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
915 |
log:('JAVA [INFO]: Reading annotation nested annotation value: ' |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
916 |
, result name printString , ' -> ' |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
917 |
, result value printString) |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
918 |
severity:Logger severityDEBUG |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
919 |
facility:#JVM ]. |
2151 | 920 |
^ result ]. |
2966 | 921 |
tag = $[ |
2151 | 922 |
ifTrue: |
923 |
[ result := JavaAnnotationArrayValue for:something. |
|
924 |
result count:(inStream nextUnsignedShortMSB:msb). |
|
2966 | 925 |
AnnotationsVerbose |
3385
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
926 |
ifTrue:[ Logger |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
927 |
log:('JAVA [INFO]: Reading annotation array value') |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
928 |
severity:Logger severityDEBUG |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
929 |
facility:#JVM ]. |
2151 | 930 |
1 to:result count |
931 |
do:[:index | result values at:index put:(self readAnnotationValueFor:something) ]. |
|
2966 | 932 |
AnnotationsVerbose |
2151 | 933 |
ifTrue: |
3385
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
934 |
[ Logger |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
935 |
log:('JAVA [INFO]: Finished reading annotation array value: ' |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
936 |
, result value printString) |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
937 |
severity:Logger severityDEBUG |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
938 |
facility:#JVM ]. |
2151 | 939 |
^ result ]. |
940 |
result := JavaAnnotationPrimitiveValue for:something. |
|
941 |
result valueIndex:(inStream nextUnsignedShortMSB:msb). |
|
2966 | 942 |
AnnotationsVerbose |
2151 | 943 |
ifTrue: |
3385
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
944 |
[ Logger |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
945 |
log:('JAVA [INFO]: Finished reading annotation primitive value: ' |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
946 |
, result name printString , ' -> ' |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
947 |
, result value printString) |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
948 |
severity:Logger severityDEBUG |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
949 |
facility:#JVM ]. |
2151 | 950 |
^ result. |
951 |
||
952 |
"Created: / 17-12-2010 / 16:44:14 / Marcel Hlopko <hlopik@gmail.com>" |
|
953 |
"Modified: / 28-02-2011 / 16:12:09 / Marcel Hlopko <hlopik@gmail.com>" |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
954 |
"Modified: / 12-02-2013 / 19:35:15 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>" |
2151 | 955 |
! |
956 |
||
2966 | 957 |
readAttribute:attributeName for:something |
2148 | 958 |
"/ implemented JAVA attributes |
2966 | 959 |
|
960 |
(attributeName = 'ConstantValue') |
|
2151 | 961 |
ifTrue: |
962 |
[ self readConstantValueAttributeFor:something. |
|
963 |
^ self. ]. |
|
2966 | 964 |
(attributeName = 'Code') |
2151 | 965 |
ifTrue: |
966 |
[ self readCodeAttributeFor:something. |
|
967 |
^ self. ]. |
|
2966 | 968 |
(attributeName = 'Exceptions') |
2151 | 969 |
ifTrue: |
970 |
[ self readExceptionsAttributeFor:something. |
|
971 |
^ self. ]. |
|
2966 | 972 |
(attributeName = 'InnerClasses') |
2151 | 973 |
ifTrue: |
974 |
[ self readInnerClassesAttributeFor:something. |
|
975 |
^ self. ]. |
|
2966 | 976 |
(attributeName = 'EnclosingMethod') |
2151 | 977 |
ifTrue: |
978 |
[ self readEnclosingMethodAttributeFor:something. |
|
979 |
^ self. ]. |
|
2966 | 980 |
(attributeName = 'LineNumberTable') |
2151 | 981 |
ifTrue: |
982 |
[ self readLineNumberTableAttributeFor:something. |
|
983 |
^ self. ]. |
|
2966 | 984 |
(attributeName = 'LocalVariableTable') |
2151 | 985 |
ifTrue: |
986 |
[ self readLocalVariableTableAttributeFor:something. |
|
987 |
^ self. ]. |
|
2966 | 988 |
(attributeName = 'LocalVariableTypeTable') |
2151 | 989 |
ifTrue: |
990 |
[ self readLocalVariableTypeTableAttributeFor:something. |
|
991 |
^ self. ]. |
|
2966 | 992 |
(attributeName = 'SourceFile') |
2151 | 993 |
ifTrue: |
994 |
[ self readSourceFileAttributeFor:something. |
|
995 |
^ self. ]. |
|
2966 | 996 |
(attributeName = 'SourceDebugExtension') |
2151 | 997 |
ifTrue: |
998 |
[ self readSourceDebugExtensionAttributeFor:something. |
|
999 |
^ self. ]. |
|
2966 | 1000 |
(attributeName = 'Synthetic') |
2151 | 1001 |
ifTrue: |
1002 |
[ self readSyntheticAttributeFor:something. |
|
1003 |
^ self. ]. |
|
2966 | 1004 |
(attributeName = 'Signature') |
2151 | 1005 |
ifTrue: |
1006 |
[ self readSignatureAttributeFor:something. |
|
1007 |
^ self. ]. |
|
2966 | 1008 |
(attributeName = 'Deprecated') |
2151 | 1009 |
ifTrue: |
1010 |
[ self readDeprecatedAttributeFor:something. |
|
1011 |
^ self. ]. |
|
2966 | 1012 |
(attributeName = 'RuntimeVisibleAnnotations') |
2151 | 1013 |
ifTrue: |
1014 |
[ self readRuntimeAnnotationsAttributeFor:something visible:true. |
|
1015 |
^ self. ]. |
|
2966 | 1016 |
(attributeName = 'RuntimeInvisibleAnnotations') |
2151 | 1017 |
ifTrue: |
1018 |
[ self readRuntimeAnnotationsAttributeFor:something visible:false. |
|
1019 |
^ self. ]. |
|
2966 | 1020 |
(attributeName = 'RuntimeVisibleParameterAnnotations') |
2151 | 1021 |
ifTrue: |
1022 |
[ self readRuntimeParameterAnnotationsAttributeFor:something visible:true. |
|
1023 |
^ self. ]. |
|
2966 | 1024 |
(attributeName = 'RuntimeInvisibleParameterAnnotations') |
2151 | 1025 |
ifTrue: |
1026 |
[ self readRuntimeParameterAnnotationsAttributeFor:something visible:false. |
|
1027 |
^ self. ]. |
|
2966 | 1028 |
(attributeName = 'AnnotationDefault') |
2151 | 1029 |
ifTrue: |
1030 |
[ self readAnnotationDefaultAttributeFor:something. |
|
1031 |
^ self. ]. |
|
2966 | 1032 |
|
2148 | 1033 |
"/ ignored JAVA attributes |
2966 | 1034 |
|
1035 |
(attributeName = 'FastJavac1.0') |
|
2151 | 1036 |
ifTrue: |
1037 |
[ "/ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
|
1038 |
self skipAttribute:attributeName. |
|
1039 |
^ self. ]. |
|
2966 | 1040 |
(attributeName = 'AbsoluteSourcePath') |
2151 | 1041 |
ifTrue: |
3385
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
1042 |
[ "/ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
2151 | 1043 |
self skipAttribute:attributeName. |
1044 |
^ self. ]. |
|
2966 | 1045 |
(attributeName startsWith:((Character value:13) asString , 'WARNING:')) |
2151 | 1046 |
ifTrue: |
1047 |
[ "/ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
|
1048 |
self skipAttribute:attributeName. |
|
1049 |
^ self. ]. |
|
2966 | 1050 |
(attributeName = 'StackMapTable') |
2151 | 1051 |
ifTrue: |
1052 |
[ "/ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
|
1053 |
self readStackMapTableAttributeFor:something. |
|
1054 |
^ self. ]. |
|
2966 | 1055 |
|
2089 | 1056 |
"/ implemented ST attributes |
2966 | 1057 |
|
1058 |
(attributeName = 'STLiterals') |
|
2151 | 1059 |
ifTrue: |
1060 |
[ self readSTLiteralsAttributeFor:something. |
|
1061 |
^ self. ]. |
|
2966 | 1062 |
(attributeName = 'ClassRevision') |
2151 | 1063 |
ifTrue: |
1064 |
[ self readSTClassRevisionAttributeFor:something. |
|
1065 |
^ self. ]. |
|
2966 | 1066 |
(attributeName = 'ClassPackage') |
2151 | 1067 |
ifTrue: |
1068 |
[ self readSTClassPackageAttributeFor:something. |
|
1069 |
^ self. ]. |
|
2966 | 1070 |
(attributeName = 'ClassCategory') |
2151 | 1071 |
ifTrue: |
1072 |
[ self readSTClassCategoryAttributeFor:something. |
|
1073 |
^ self. ]. |
|
2966 | 1074 |
(attributeName = 'ClassVarNames') |
2151 | 1075 |
ifTrue: |
1076 |
[ self readSTClassVarNamesAttributeFor:something. |
|
1077 |
^ self. ]. |
|
2966 | 1078 |
(attributeName = 'ClassInstVarNames') |
2151 | 1079 |
ifTrue: |
1080 |
[ self readSTClassInstVarNamesAttributeFor:something. |
|
1081 |
^ self. ]. |
|
2966 | 1082 |
(attributeName = 'InstVarNames') |
2151 | 1083 |
ifTrue: |
1084 |
[ self readSTInstVarNamesAttributeFor:something. |
|
1085 |
^ self. ]. |
|
2966 | 1086 |
(attributeName = 'STCode') |
2151 | 1087 |
ifTrue: |
1088 |
[ self readSTCodeAttributeFor:something. |
|
1089 |
^ self. ]. |
|
2966 | 1090 |
(attributeName = 'MethodCategory') |
2151 | 1091 |
ifTrue: |
1092 |
[ self readSTMethodCategoryAttributeFor:something. |
|
1093 |
^ self. ]. |
|
2866
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1094 |
|
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1095 |
"/ Eclipse Java Compiler Specific Attributes |
2966 | 1096 |
(attributeName = 'MissingTypes') |
2866
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1097 |
ifTrue: |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1098 |
[ self readMissingTypesAttributeFor:something. |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1099 |
^ self. ]. |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1100 |
|
355 | 1101 |
"/ unknown attributes |
2966 | 1102 |
|
3385
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
1103 |
Logger |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
1104 |
log:('JAVA [warning]: unrecognized attribute: ' , attributeName) |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
1105 |
severity:Logger severityDEBUG |
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
1106 |
facility:#JVM. |
333 | 1107 |
self skipAttribute:attributeName. |
5 | 1108 |
|
2151 | 1109 |
"Modified: / 03-12-1998 / 13:13:42 / cg" |
1110 |
"Modified: / 25-02-2011 / 18:09:21 / Marcel Hlopko <hlopik@gmail.com>" |
|
3385
58d72cc6d5f6
Replaced old-style `'string' infoPrintCR` logging with new-style `Logger log:'string'` logging
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3384
diff
changeset
|
1111 |
"Modified: / 02-03-2015 / 16:04:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
5 | 1112 |
! |
1113 |
||
1114 |
readAttributeFor:something |
|
1115 |
|attribute_name_index attribute_name attribute_length attribute_info| |
|
1116 |
||
61 | 1117 |
Verbose ifTrue:[Transcript show:'attrib at pos: '; showCR:inStream position]. |
9 | 1118 |
|
128 | 1119 |
attribute_name_index := inStream nextUnsignedShortMSB:msb. |
2142 | 1120 |
attribute_name_index == 0 ifTrue:[ |
1121 |
self halt. |
|
2151 | 1122 |
"/self skipAttribute:'unnamed'. |
2142 | 1123 |
^ self. |
1124 |
]. |
|
9 | 1125 |
|
1126 |
"/ |
|
1127 |
"/ UNDOC feature ? |
|
1128 |
"/ |
|
1129 |
attribute_name_index > constants size ifTrue:[ |
|
333 | 1130 |
attribute_name_index == 16rb700 ifTrue:[ |
1131 |
self halt. |
|
1132 |
] |
|
9 | 1133 |
]. |
1134 |
||
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
1135 |
attribute_name := self constantPoolAt:attribute_name_index. |
9 | 1136 |
|
61 | 1137 |
Verbose ifTrue:[Transcript show:'attrib name: '; showCR:attribute_name]. |
9 | 1138 |
|
333 | 1139 |
self readAttribute:attribute_name for:something. |
5 | 1140 |
|
1141 |
" |
|
1142 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1143 |
" |
|
1144 |
||
2151 | 1145 |
"Created: / 15-04-1996 / 15:40:17 / cg" |
1146 |
"Modified: / 09-04-1998 / 18:13:34 / cg" |
|
1147 |
"Modified: / 19-10-2010 / 21:43:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
5 | 1148 |
! |
1149 |
||
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1150 |
readAttributeLength |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1151 |
^ inStream nextUnsignedLongMSB:msb |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1152 |
|
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1153 |
"Created: / 03-12-2014 / 12:53:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1154 |
! |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1155 |
|
5 | 1156 |
readAttributesFor:something |
1157 |
|attributes_count| |
|
1158 |
||
128 | 1159 |
attributes_count := inStream nextUnsignedShortMSB:msb. |
2729
ac412f6ea6d4
More support for method's source display. Not yet working.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2591
diff
changeset
|
1160 |
attributes := OrderedCollection new: attributes_count * 2. |
5 | 1161 |
|
1162 |
1 to:attributes_count do:[:i | |
|
2729
ac412f6ea6d4
More support for method's source display. Not yet working.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2591
diff
changeset
|
1163 |
self readAttributeFor:something. |
5 | 1164 |
]. |
1165 |
||
2729
ac412f6ea6d4
More support for method's source display. Not yet working.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2591
diff
changeset
|
1166 |
"Created: / 15-04-1996 / 15:40:17 / cg" |
ac412f6ea6d4
More support for method's source display. Not yet working.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2591
diff
changeset
|
1167 |
"Modified: / 13-09-2013 / 01:01:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
333 | 1168 |
! |
1169 |
||
2151 | 1170 |
readDeprecatedAttributeFor:aJavaMethodWithHandler |
1171 |
||
1172 |
self skipAttribute:'Deprecated'. |
|
1173 |
^self |
|
1174 |
||
1175 |
"Created: / 18-10-2010 / 22:26:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1176 |
! |
|
1177 |
||
2148 | 1178 |
readEnclosingMethodAttributeFor:something |
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1179 |
| class_ref_index method_ref_index | |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1180 |
|
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1181 |
self skipAttributeLength. |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1182 |
class_ref_index := inStream nextUnsignedShortMSB:msb. |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1183 |
method_ref_index := inStream nextUnsignedShortMSB:msb. |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1184 |
attributes add: #EnclosingMethod; add: (Array with: class_ref_index with: method_ref_index) |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1185 |
|
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1186 |
"Modified: / 03-12-2014 / 12:56:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2148 | 1187 |
! |
1188 |
||
1189 |
readInnerClassesAttributeFor:something |
|
2866
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1190 |
| attribute_length number_of_classes classes | |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1191 |
|
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1192 |
attribute_length := inStream nextUnsignedLongMSB:msb. "/ skip attribute length. |
2966 | 1193 |
number_of_classes := inStream nextUnsignedShortMSB:msb. |
2866
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1194 |
classes := JavaInnerClasses new: number_of_classes. |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1195 |
self assert: attribute_length == ((number_of_classes * 8) + 2). |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1196 |
1 to: number_of_classes do:[:i | |
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1197 |
| entry | |
2866
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1198 |
|
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1199 |
entry := JavaInnerClasses::Entry new. |
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1200 |
entry setInnerClassRefIndex:(inStream nextUnsignedShortMSB:msb). |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1201 |
entry setOuterClassRefIndex:(inStream nextUnsignedShortMSB:msb). |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1202 |
entry setNameIndex: (inStream nextUnsignedShortMSB:msb). |
2866
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1203 |
entry setAccessFlags: (inStream nextUnsignedShortMSB:msb). |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1204 |
classes at: i put: entry |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1205 |
]. |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1206 |
|
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1207 |
attributes add: #InnerClasses; add: classes. |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1208 |
|
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1209 |
"Modified: / 03-12-2014 / 14:06:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2148 | 1210 |
! |
1211 |
||
1212 |
readLocalVariableTypeTableAttributeFor:something |
|
1213 |
"/ ('JAVA [info]: unhandled attribute: LocalVariableTypeTable') infoPrintCR. |
|
1214 |
self skipAttribute:'LocalVariableTypeTable'. |
|
1215 |
! |
|
1216 |
||
2866
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1217 |
readMissingTypesAttributeFor:something |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1218 |
| attribute_length numMissingTypes missingTypes | |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1219 |
|
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1220 |
attribute_length := inStream nextUnsignedLongMSB:msb. "/ skip attribute length. |
2966 | 1221 |
numMissingTypes := inStream nextUnsignedShortMSB:msb. |
2866
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1222 |
missingTypes := Array new: numMissingTypes. |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1223 |
self assert: attribute_length == ((numMissingTypes * 2) + 2). |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1224 |
1 to: numMissingTypes do:[: i | |
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1225 |
missingTypes at: i put: (inStream nextUnsignedShortMSB:msb) |
2866
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1226 |
]. |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1227 |
|
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1228 |
attributes add: #MissingTypes; add: missingTypes. |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1229 |
|
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1230 |
"Created: / 16-10-2013 / 02:04:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1231 |
! |
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1232 |
|
2966 | 1233 |
readRuntimeAnnotationsAttributeFor: something visible: visible |
2151 | 1234 |
| length annotationsCount annotations rawAnnotations startPos endPos | |
1235 |
||
1236 |
self assert: inStream isPositionable |
|
1237 |
message: '.class file stream must be positionable'. |
|
1238 |
length := inStream nextUnsignedLongMSB: msb. |
|
1239 |
startPos := inStream position. |
|
1240 |
annotationsCount := inStream nextUnsignedShortMSB: msb. |
|
1241 |
annotationsCount = 0 ifTrue: [ ^ nil ]. |
|
1242 |
annotations := visible ifTrue: [something ensureHasAnnotations ensureRuntimeVisible] ifFalse: [something ensureHasAnnotations ensureRuntimeInvisible]. |
|
2966 | 1243 |
annotationsCount timesRepeat: |
2151 | 1244 |
[ | currentAnnotation | |
1245 |
||
1246 |
currentAnnotation := self readAnnotationFor: something. |
|
1247 |
annotations at: currentAnnotation name put: currentAnnotation. ]. |
|
1248 |
"Cut raw annotations as required by getRawAnnotations()" |
|
1249 |
endPos := inStream position. |
|
1250 |
inStream position: startPos. |
|
1251 |
rawAnnotations := inStream next: length. |
|
2966 | 1252 |
inStream position ~= endPos |
2151 | 1253 |
ifTrue: [ self halt: 'annotations are probably reading what they shouldnt' ]. |
1254 |
annotations rawAnnotations: rawAnnotations. |
|
1255 |
||
1256 |
"Modified: / 07-01-2011 / 22:00:07 / Jan Kurs <kurs.jan@post.cz>" |
|
1257 |
"Modified: / 25-02-2011 / 18:45:58 / Marcel Hlopko <hlopik@gmail.com>" |
|
1258 |
"Modified: / 03-03-2011 / 23:01:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1259 |
"Modified: / 16-03-2011 / 16:57:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
2148 | 1260 |
! |
1261 |
||
2966 | 1262 |
readRuntimeParameterAnnotationsAttributeFor: javaMethod visible: visible |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1263 |
| length paramsCount annotationsCount rawAnnotations startPos endPos | |
2151 | 1264 |
self assert: inStream isPositionable |
1265 |
message: '.class file stream must be positionable'. |
|
1266 |
length := inStream nextUnsignedLongMSB: msb. |
|
1267 |
startPos := inStream position. |
|
1268 |
paramsCount := inStream nextByte. |
|
1269 |
paramsCount = 0 ifTrue: [ ^ nil ]. |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1270 |
1 to: paramsCount do: [ |
2966 | 1271 |
:paramIndex | |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1272 |
annotationsCount := inStream nextUnsignedShortMSB: msb. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1273 |
annotationsCount > 0 ifTrue: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1274 |
| annotations | |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1275 |
annotations := visible ifTrue: [ |
2966 | 1276 |
javaMethod ensureHasAnnotations |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1277 |
ensureVisibleParameterAnnotationsAt: paramIndex |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1278 |
] ifFalse: [ |
2966 | 1279 |
javaMethod ensureHasAnnotations |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1280 |
ensureInvisibleParameterAnnotationsAt: paramIndex |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1281 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1282 |
annotationsCount timesRepeat: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1283 |
| annotation | |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1284 |
annotation := self readAnnotationFor: javaMethod. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1285 |
annotations at: (annotation name) put: annotation. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1286 |
] |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1287 |
] |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1288 |
]. |
2151 | 1289 |
endPos := inStream position. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1290 |
inStream position: startPos. |
2151 | 1291 |
rawAnnotations := inStream next: length. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1292 |
inStream position ~= endPos ifTrue: [ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1293 |
self halt: 'annotations are probably reading what they shouldnt' |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1294 |
]. |
3003
c9f0019485ff
get rid of old mh breakpoint
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
2966
diff
changeset
|
1295 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1296 |
javaMethod annotations rawParamAnnotations: rawAnnotations. |
2151 | 1297 |
|
1298 |
"Modified: / 28-02-2011 / 17:05:47 / Marcel Hlopko <hlopik@gmail.com>" |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1299 |
"Modified: / 01-12-2012 / 22:54:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
3003
c9f0019485ff
get rid of old mh breakpoint
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
2966
diff
changeset
|
1300 |
"Modified: / 25-01-2014 / 21:44:28 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>" |
2148 | 1301 |
! |
1302 |
||
1303 |
readSignatureAttributeFor:something |
|
2151 | 1304 |
|
1305 |
|attribute_length signature_index signature| |
|
1306 |
||
1307 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1308 |
||
1309 |
signature_index := inStream nextUnsignedShortMSB:msb. |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
1310 |
signature := self constantPoolAt:signature_index. |
2151 | 1311 |
|
3293
14292924cac7
JavaClass memory optimization (part 4)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3291
diff
changeset
|
1312 |
something isJavaClass ifTrue:[ |
14292924cac7
JavaClass memory optimization (part 4)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3291
diff
changeset
|
1313 |
attributes add: #GenericSignature; add: signature |
14292924cac7
JavaClass memory optimization (part 4)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3291
diff
changeset
|
1314 |
] ifFalse:[ |
14292924cac7
JavaClass memory optimization (part 4)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3291
diff
changeset
|
1315 |
something setSignature: signature. |
14292924cac7
JavaClass memory optimization (part 4)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3291
diff
changeset
|
1316 |
]. |
14292924cac7
JavaClass memory optimization (part 4)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3291
diff
changeset
|
1317 |
|
14292924cac7
JavaClass memory optimization (part 4)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3291
diff
changeset
|
1318 |
"Modified: / 07-12-2014 / 01:43:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2148 | 1319 |
! |
1320 |
||
1321 |
readSourceDebugExtensionAttributeFor:something |
|
1322 |
"/ ('JAVA [info]: unhandled attribute: SourceDebugExtension') infoPrintCR. |
|
1323 |
self skipAttribute:'SourceDebugExtension'. |
|
1324 |
! |
|
1325 |
||
353 | 1326 |
readSourceFileAttributeFor:aClass |
350 | 1327 |
|attribute_length sourceFile_index sourceFile| |
1328 |
||
1329 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1330 |
||
1331 |
sourceFile_index := inStream nextUnsignedShortMSB:msb. |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
1332 |
sourceFile := self constantPoolAt:sourceFile_index. |
350 | 1333 |
|
353 | 1334 |
aClass isJavaClass ifTrue:[ |
1335 |
aClass setSourceFile:sourceFile. |
|
1336 |
] ifFalse:[ |
|
1337 |
aClass setClassFilename:sourceFile |
|
1338 |
]. |
|
350 | 1339 |
|
1340 |
Verbose ifTrue:[Transcript show:'sourceFile: '; showCR:sourceFile]. |
|
1341 |
^ true |
|
1342 |
||
1343 |
" |
|
1344 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1345 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1346 |
JavaClassReader loadFile:'foo.cls' |
|
1347 |
" |
|
1348 |
||
1349 |
"Created: / 15.4.1996 / 15:40:17 / cg" |
|
353 | 1350 |
"Modified: / 12.5.1998 / 22:01:07 / cg" |
350 | 1351 |
! |
1352 |
||
2966 | 1353 |
readStackMapTableAttributeFor:something |
2151 | 1354 |
"/ ('JAVA [info]: unhandled attribute: StackMapTable') infoPrintCR. |
1355 |
self skipAttribute:'StackMapTable'. |
|
1356 |
||
1357 |
"Created: / 09-02-2011 / 01:19:20 / Marcel Hlopko <hlopik@gmail.com>" |
|
1358 |
! |
|
1359 |
||
2148 | 1360 |
readSyntheticAttributeFor:something |
1361 |
"/ ('JAVA [info]: unhandled attribute: Synthetic') infoPrintCR. |
|
1362 |
self skipAttribute:'Synthetic'. |
|
2729
ac412f6ea6d4
More support for method's source display. Not yet working.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2591
diff
changeset
|
1363 |
attributes add: #Synthetic; add: true. |
ac412f6ea6d4
More support for method's source display. Not yet working.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2591
diff
changeset
|
1364 |
|
ac412f6ea6d4
More support for method's source display. Not yet working.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2591
diff
changeset
|
1365 |
"Modified: / 13-09-2013 / 01:08:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2148 | 1366 |
! |
1367 |
||
3289
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
1368 |
skipAttribute |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
1369 |
"Skip attribute, advance in .class file stream to next entity" |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
1370 |
inStream skip: self readAttributeLength. |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
1371 |
|
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
1372 |
"Created: / 06-12-2014 / 10:53:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
1373 |
! |
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
1374 |
|
333 | 1375 |
skipAttribute:attributeName |
1376 |
"dont know about this attribute - skip it here" |
|
1377 |
||
1378 |
Verbose ifTrue:[Transcript show:'skipped '; show:attributeName; showCR:'-attribute']. |
|
3289
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
1379 |
self skipAttribute |
333 | 1380 |
|
2866
d92f88db7514
Improved JavaClassReader to read InnerClasses and MissingTypes attributes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2841
diff
changeset
|
1381 |
"Created: / 09-04-1998 / 18:12:46 / cg" |
3289
3aaf43a51816
Extracted magic and version detection into separate methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3288
diff
changeset
|
1382 |
"Modified: / 06-12-2014 / 10:54:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1383 |
! |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1384 |
|
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1385 |
skipAttributeLength |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1386 |
inStream skip:4. |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1387 |
|
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1388 |
"Created: / 03-12-2014 / 12:53:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
5 | 1389 |
! ! |
1390 |
||
350 | 1391 |
!JavaClassReader methodsFor:'file reading - attributes-ST'! |
1392 |
||
1393 |
readSTClassCategoryAttributeFor:aClass |
|
1394 |
|attribute_length categoryString_index categoryString| |
|
1395 |
||
1396 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1397 |
||
1398 |
categoryString_index := inStream nextUnsignedShortMSB:msb. |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
1399 |
categoryString := self constantPoolAt:categoryString_index. |
350 | 1400 |
|
1401 |
aClass category:categoryString. |
|
1402 |
||
1403 |
Verbose ifTrue:[Transcript show:'categoryString: '; showCR:categoryString]. |
|
1404 |
^ true |
|
1405 |
||
1406 |
" |
|
1407 |
JavaClassReader loadFile:'foo.cls' |
|
1408 |
" |
|
1409 |
||
1410 |
"Created: / 9.5.1998 / 02:33:13 / cg" |
|
1411 |
"Modified: / 9.5.1998 / 02:36:55 / cg" |
|
1412 |
! |
|
1413 |
||
353 | 1414 |
readSTClassInstVarNamesAttributeFor:aClass |
1415 |
|attribute_length nameString_index nameString| |
|
1416 |
||
1417 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1418 |
||
1419 |
nameString_index := inStream nextUnsignedShortMSB:msb. |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
1420 |
nameString := self constantPoolAt:nameString_index. |
353 | 1421 |
|
1422 |
aClass class instanceVariableString:nameString. |
|
1423 |
||
1424 |
Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString]. |
|
1425 |
^ true |
|
1426 |
||
1427 |
" |
|
1428 |
JavaClassReader loadFile:'foo.cls' |
|
1429 |
" |
|
1430 |
||
1431 |
"Modified: / 12.5.1998 / 22:18:03 / cg" |
|
1432 |
"Created: / 12.5.1998 / 22:18:24 / cg" |
|
1433 |
! |
|
1434 |
||
350 | 1435 |
readSTClassPackageAttributeFor:aClass |
1436 |
|attribute_length packageString_index packageString| |
|
1437 |
||
1438 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1439 |
||
1440 |
packageString_index := inStream nextUnsignedShortMSB:msb. |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
1441 |
packageString := self constantPoolAt:packageString_index. |
350 | 1442 |
|
1443 |
aClass package:packageString asSymbol. |
|
1444 |
||
1445 |
Verbose ifTrue:[Transcript show:'packageString: '; showCR:packageString]. |
|
1446 |
^ true |
|
1447 |
||
1448 |
" |
|
1449 |
JavaClassReader loadFile:'foo.cls' |
|
1450 |
" |
|
1451 |
||
1452 |
"Modified: / 9.5.1998 / 02:32:38 / cg" |
|
1453 |
"Created: / 9.5.1998 / 02:33:44 / cg" |
|
1454 |
! |
|
1455 |
||
1456 |
readSTClassRevisionAttributeFor:aClass |
|
1457 |
|attribute_length revisionString_index revisionString| |
|
1458 |
||
1459 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1460 |
||
1461 |
revisionString_index := inStream nextUnsignedShortMSB:msb. |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
1462 |
revisionString := self constantPoolAt:revisionString_index. |
350 | 1463 |
|
1464 |
aClass setBinaryRevision:revisionString. |
|
1465 |
||
1466 |
Verbose ifTrue:[Transcript show:'revisionString: '; showCR:revisionString]. |
|
1467 |
^ true |
|
1468 |
||
1469 |
" |
|
1470 |
JavaClassReader loadFile:'foo.cls' |
|
1471 |
" |
|
1472 |
||
1473 |
"Created: / 9.5.1998 / 02:33:13 / cg" |
|
1474 |
"Modified: / 9.5.1998 / 02:35:01 / cg" |
|
353 | 1475 |
! |
1476 |
||
1477 |
readSTClassVarNamesAttributeFor:aClass |
|
1478 |
|attribute_length nameString_index nameString| |
|
1479 |
||
1480 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1481 |
||
1482 |
nameString_index := inStream nextUnsignedShortMSB:msb. |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
1483 |
nameString := self constantPoolAt:nameString_index. |
353 | 1484 |
|
1485 |
aClass classVariableString:nameString. |
|
1486 |
||
1487 |
Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString]. |
|
1488 |
^ true |
|
1489 |
||
1490 |
" |
|
1491 |
JavaClassReader loadFile:'foo.cls' |
|
1492 |
" |
|
1493 |
||
1494 |
"Created: / 9.5.1998 / 02:33:13 / cg" |
|
1495 |
"Modified: / 12.5.1998 / 22:18:03 / cg" |
|
1496 |
! |
|
1497 |
||
1498 |
readSTInstVarNamesAttributeFor:aClass |
|
1499 |
|attribute_length nameString_index nameString| |
|
1500 |
||
1501 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1502 |
||
1503 |
nameString_index := inStream nextUnsignedShortMSB:msb. |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
1504 |
nameString := self constantPoolAt:nameString_index. |
353 | 1505 |
|
1506 |
aClass setInstanceVariableString:nameString. |
|
1507 |
||
1508 |
Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString]. |
|
1509 |
^ true |
|
1510 |
||
1511 |
" |
|
1512 |
JavaClassReader loadFile:'foo.cls' |
|
1513 |
" |
|
1514 |
||
1515 |
"Created: / 12.5.1998 / 22:18:14 / cg" |
|
1516 |
"Modified: / 12.5.1998 / 22:21:10 / cg" |
|
350 | 1517 |
! ! |
1518 |
||
5 | 1519 |
!JavaClassReader methodsFor:'file reading - constants'! |
1520 |
||
1 | 1521 |
readConstant |
3106
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1522 |
|tag constReader| |
1 | 1523 |
|
1524 |
||
11 | 1525 |
constNeeds2Slots := false. |
1526 |
||
1 | 1527 |
"/ |
1528 |
"/ get tag |
|
1529 |
"/ |
|
128 | 1530 |
tag := inStream nextByte. |
61 | 1531 |
Verbose ifTrue:[Transcript show:'tag = '; showCR:tag]. |
1 | 1532 |
|
350 | 1533 |
tag >= 250 ifTrue:[ |
1534 |
constReader := #( |
|
1535 |
"/ ST types |
|
1536 |
readConstant_ST_Large "/ 249 |
|
1537 |
readConstant_ST_Special "/ 250 |
|
1538 |
readConstant_ST_Character "/ 251 |
|
1539 |
readConstant_ST_ByteArray "/ 252 |
|
1540 |
readConstant_ST_Array "/ 253 |
|
1541 |
readConstant_ST_Symbol "/ 254 |
|
1542 |
readConstant_ST_Reserved "/ 255 |
|
1543 |
) at:tag-249+1. |
|
1544 |
] ifFalse:[ |
|
1545 |
constReader := #( |
|
344 | 1546 |
"/ JAVA types |
695 | 1547 |
readConstant_Utf8 "/ 1 - now called Utf8 |
344 | 1548 |
readConstant_Unicode "/ 2 |
1549 |
readConstant_Integer "/ 3 |
|
1550 |
readConstant_Float "/ 4 |
|
1551 |
readConstant_Long "/ 5 |
|
1552 |
readConstant_Double "/ 6 |
|
1553 |
readConstant_Class "/ 7 |
|
1554 |
readConstant_String "/ 8 |
|
1555 |
readConstant_Fieldref "/ 9 |
|
1556 |
readConstant_Methodref "/ 10 |
|
1557 |
readConstant_InterfaceMethodref "/ 11 |
|
1558 |
readConstant_NameAndType "/ 12 |
|
3106
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1559 |
readConstant_Undef "/ 13 |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1560 |
readConstant_Undef "/ 14 |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1561 |
readConstant_MethodHandle "/ 15 |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1562 |
readConstant_MethodType "/ 16 |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1563 |
readConstant_Undef "/ 17 |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1564 |
readConstant_InvokeDynamic "/ 18 |
344 | 1565 |
) at:tag ifAbsent:[#readConstant_Undef]. |
350 | 1566 |
]. |
1 | 1567 |
^ self perform:constReader. |
1568 |
||
1569 |
" |
|
1570 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1571 |
" |
|
1572 |
||
3106
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1573 |
"Created: / 15-04-1996 / 15:46:32 / cg" |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1574 |
"Modified: / 09-05-1998 / 01:26:05 / cg" |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1575 |
"Modified: / 20-05-2014 / 17:15:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 1576 |
! |
1577 |
||
1578 |
readConstantPool |
|
2151 | 1579 |
| constantPoolSize const | |
1 | 1580 |
|
1581 |
"/ |
|
1582 |
"/ get constant pool |
|
1583 |
"/ |
|
2151 | 1584 |
constantPoolSize := inStream nextUnsignedShortMSB: msb. |
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1585 |
Verbose ifTrue:[ |
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1586 |
self info: 'constantPoolSize = ' , constantPoolSize printString. |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1587 |
]. |
2151 | 1588 |
constants := JavaConstantPool new: constantPoolSize - 1. |
21 | 1589 |
constSlot := 1. |
2151 | 1590 |
[ constSlot < constantPoolSize ] whileTrue: [ |
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1591 |
Verbose ifTrue:[ |
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1592 |
self info: 'const slot: ' , constSlot printString. |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1593 |
]. |
2151 | 1594 |
const := self readConstant. |
1595 |
constants at: constSlot put: const. |
|
2966 | 1596 |
|
2151 | 1597 |
"/ long & double consts take 2 slots |
1598 |
"/ (only first is used) |
|
2966 | 1599 |
|
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1600 |
constSlot := constNeeds2Slots ifTrue: [ constSlot + 2. ] ifFalse: [ constSlot + 1. ]]. |
52 | 1601 |
constSlot := -1. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1602 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1603 |
constants do:[:ref|ref isJavaRef ifTrue:[ref preResolve]]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1604 |
"/ 1 to: constantPoolSize - 1 |
2966 | 1605 |
"/ do: |
1606 |
"/ [:i | |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1607 |
"/ | const value | |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1608 |
"/ |
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
1609 |
"/ const := self constantPoolAt: i. |
2966 | 1610 |
"/ const notNil ifTrue: |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1611 |
"/ [ "/ kludge for 2-slot constants (which only take 1 slot in ST/X) |
2966 | 1612 |
"/ (const isKindOf: JavaUnresolvedConstant) |
1613 |
"/ ifTrue: |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1614 |
"/ [ value := const preResolve. |
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
1615 |
"/ value ~~ const ifTrue: [ self constantPoolAt: i put: value. ] ] ] ]. |
1 | 1616 |
|
1617 |
" |
|
1618 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2151 | 1619 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'" |
1620 |
||
1621 |
"Modified: / 07-05-1998 / 11:44:06 / cg" |
|
1622 |
"Created: / 13-05-2011 / 16:52:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1623 |
"Modified: / 04-08-2014 / 15:41:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 1624 |
! |
1625 |
||
1626 |
readConstant_Asciz |
|
2151 | 1627 |
| len string | |
1628 |
||
1629 |
||
1630 |
len := inStream nextUnsignedShortMSB: msb. |
|
1631 |
string := String new: len. |
|
2966 | 1632 |
inStream |
2151 | 1633 |
nextBytes: len |
1634 |
into: string |
|
1635 |
startingAt: 1. |
|
3275
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
1636 |
string := InternedStrings elementAt: string ifAbsent: [ InternedStrings add: string ]. |
2966 | 1637 |
Verbose |
1638 |
ifTrue: |
|
2151 | 1639 |
[ Transcript |
1640 |
show: 'asciz; string= '; |
|
1641 |
showCR: string ]. |
|
1 | 1642 |
^ string |
1643 |
||
1644 |
" |
|
1645 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2151 | 1646 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'" |
1647 |
||
1648 |
"Created: / 15-04-1996 / 15:15:35 / cg" |
|
1649 |
"Modified: / 15-04-1996 / 16:33:45 / cg" |
|
1650 |
"Modified: / 13-05-2011 / 17:31:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
3275
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
1651 |
"Modified: / 13-11-2014 / 11:53:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 1652 |
! |
1653 |
||
1654 |
readConstant_Class |
|
2151 | 1655 |
| nameIndex | |
1656 |
||
1657 |
nameIndex := inStream nextUnsignedShortMSB: msb. |
|
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1658 |
Verbose ifTrue:[ |
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
1659 |
((self constantPoolAt: nameIndex) isNil) ifTrue: [ |
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1660 |
self info: ('reading class; index=' , nameIndex printString , ' name=' |
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
1661 |
, (self constantPoolAt: nameIndex) printString) |
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1662 |
] ifFalse: [ |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1663 |
self info: ('reading class; index= ' , nameIndex printString) |
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1664 |
]. |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1665 |
]. |
2151 | 1666 |
^ JavaClassRef2 in: constants withNameAt: nameIndex. |
1667 |
||
1668 |
"Modified: / 18-05-2011 / 18:21:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1669 |
"Modified: / 04-08-2014 / 15:39:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 1670 |
! |
1671 |
||
11 | 1672 |
readConstant_Double |
350 | 1673 |
|high low aFloat bytes| |
1674 |
||
1675 |
"/ new code - to be tested |
|
1676 |
"/ bytes := ByteArray new:8. |
|
1677 |
"/ |
|
1678 |
"/ inStream nextBytes:8 into:bytes startingAt:1. |
|
1679 |
"/ msb ~~ UninterpretedBytes isBigEndian ifTrue:[ |
|
1680 |
"/ bytes reverse |
|
1681 |
"/ ]. |
|
1682 |
"/ aFloat := bytes doubleAt:1. |
|
1683 |
||
1684 |
"/ old code |
|
11 | 1685 |
|
128 | 1686 |
high := inStream nextUnsignedLongMSB:msb. |
1687 |
low := inStream nextUnsignedLongMSB:msb. |
|
11 | 1688 |
|
1689 |
aFloat := Float new. |
|
1690 |
UninterpretedBytes isBigEndian ifTrue:[ |
|
350 | 1691 |
aFloat basicAt:1 put:((high bitShift:-24) bitAnd:16rFF). |
1692 |
aFloat basicAt:2 put:((high bitShift:-16) bitAnd:16rFF). |
|
1693 |
aFloat basicAt:3 put:((high bitShift:-8) bitAnd:16rFF). |
|
1694 |
aFloat basicAt:4 put:(high bitAnd:16rFF). |
|
1695 |
aFloat basicAt:5 put:((low bitShift:-24) bitAnd:16rFF). |
|
1696 |
aFloat basicAt:6 put:((low bitShift:-16) bitAnd:16rFF). |
|
1697 |
aFloat basicAt:7 put:((low bitShift:-8) bitAnd:16rFF). |
|
1698 |
aFloat basicAt:8 put:(low bitAnd:16rFF). |
|
11 | 1699 |
] ifFalse:[ |
350 | 1700 |
aFloat basicAt:1 put:(low bitAnd:16rFF). |
1701 |
aFloat basicAt:2 put:((low bitShift:-8) bitAnd:16rFF). |
|
1702 |
aFloat basicAt:3 put:((low bitShift:-16) bitAnd:16rFF). |
|
1703 |
aFloat basicAt:4 put:((low bitShift:-24) bitAnd:16rFF). |
|
1704 |
aFloat basicAt:5 put:(high bitAnd:16rFF). |
|
1705 |
aFloat basicAt:6 put:((high bitShift:-8) bitAnd:16rFF). |
|
1706 |
aFloat basicAt:7 put:((high bitShift:-16) bitAnd:16rFF). |
|
1707 |
aFloat basicAt:8 put:((high bitShift:-24) bitAnd:16rFF). |
|
11 | 1708 |
]. |
1709 |
||
1710 |
constNeeds2Slots := true. |
|
1711 |
||
61 | 1712 |
Verbose ifTrue:[Transcript show:'double; value= '; showCR:aFloat]. |
11 | 1713 |
^ aFloat |
1714 |
||
1715 |
" |
|
1716 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1717 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1718 |
" |
|
1719 |
||
350 | 1720 |
"Created: / 15.4.1996 / 16:34:42 / cg" |
1721 |
"Modified: / 8.5.1998 / 22:06:07 / cg" |
|
11 | 1722 |
! |
1723 |
||
2966 | 1724 |
readConstant_Fieldref |
2151 | 1725 |
"incrementally changing resolving logic, fields will come later" |
1726 |
||
1727 |
| classIndex nameAndTypeIndex | |
|
1728 |
||
1729 |
classIndex := inStream nextUnsignedShortMSB: msb. |
|
1730 |
nameAndTypeIndex := inStream nextUnsignedShortMSB: msb. |
|
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1731 |
Verbose ifTrue:[ |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1732 |
self |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1733 |
info: 'reading fieldref; classindex=' , classIndex printString |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1734 |
, ' nameAndTypeIndex=' , nameAndTypeIndex printString. |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1735 |
]. |
2966 | 1736 |
^ JavaFieldRef2 |
2151 | 1737 |
in: constants |
1738 |
withNameAndTypeAt: nameAndTypeIndex |
|
1739 |
andClassAt: classIndex. |
|
1740 |
||
1741 |
"Modified: / 15-05-2011 / 14:20:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1742 |
"Modified: / 04-08-2014 / 15:38:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 1743 |
! |
1744 |
||
11 | 1745 |
readConstant_Float |
433 | 1746 |
|b1 b2 b3 b4 aFloat bytes| |
350 | 1747 |
|
1748 |
"/ new code - to be tested ... |
|
352 | 1749 |
"/ |
1750 |
"/ bytes := ByteArray new:4. |
|
1751 |
"/ inStream nextBytes:4 into:bytes startingAt:1. |
|
1752 |
"/ msb ~~ UninterpretedBytes isBigEndian ifTrue:[ |
|
1753 |
"/ bytes reverse |
|
1754 |
"/ ]. |
|
1755 |
"/ aFloat := bytes floatAt:1. |
|
1756 |
"/ Verbose ifTrue:[Transcript show:'float; value= '; showCR:aFloat]. |
|
1757 |
"/ ^ aFloat. |
|
350 | 1758 |
|
1759 |
"/ old code |
|
11 | 1760 |
|
1761 |
aFloat := ShortFloat basicNew. |
|
433 | 1762 |
|
1763 |
b1 := inStream nextByte. |
|
1764 |
b2 := inStream nextByte. |
|
1765 |
b3 := inStream nextByte. |
|
1766 |
b4 := inStream nextByte. |
|
1767 |
||
11 | 1768 |
UninterpretedBytes isBigEndian ifTrue:[ |
433 | 1769 |
aFloat basicAt:1 put:b1. |
1770 |
aFloat basicAt:2 put:b2. |
|
1771 |
aFloat basicAt:3 put:b3. |
|
1772 |
aFloat basicAt:4 put:b4. |
|
11 | 1773 |
] ifFalse:[ |
433 | 1774 |
aFloat basicAt:4 put:b1. |
1775 |
aFloat basicAt:3 put:b2. |
|
1776 |
aFloat basicAt:2 put:b3. |
|
1777 |
aFloat basicAt:1 put:b4. |
|
11 | 1778 |
]. |
61 | 1779 |
Verbose ifTrue:[Transcript show:'float; value= '; showCR:aFloat]. |
11 | 1780 |
^ aFloat |
1781 |
||
1782 |
" |
|
1783 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1784 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1785 |
" |
|
1786 |
||
350 | 1787 |
"Created: / 15.4.1996 / 16:34:42 / cg" |
433 | 1788 |
"Modified: / 10.11.1998 / 22:04:59 / cg" |
11 | 1789 |
! |
1790 |
||
1 | 1791 |
readConstant_Integer |
1792 |
|value| |
|
1793 |
||
128 | 1794 |
value := inStream nextLongMSB:msb. |
1 | 1795 |
|
61 | 1796 |
Verbose ifTrue:[Transcript show:'integer; value= '; showCR:value]. |
1 | 1797 |
|
1798 |
^ value |
|
1799 |
||
1800 |
" |
|
1801 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1802 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1803 |
" |
|
1804 |
||
1805 |
"Modified: 15.4.1996 / 15:42:16 / cg" |
|
1806 |
"Created: 15.4.1996 / 16:34:42 / cg" |
|
1807 |
! |
|
1808 |
||
14
c1d9f60eb650
can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents:
11
diff
changeset
|
1809 |
readConstant_InterfaceMethodref |
2151 | 1810 |
| classIndex nameAndTypeIndex | |
1811 |
||
1812 |
classIndex := inStream nextUnsignedShortMSB: msb. |
|
2966 | 1813 |
nameAndTypeIndex := inStream nextUnsignedShortMSB: msb. |
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1814 |
Verbose ifTrue:[ |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1815 |
self |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1816 |
info: 'reading interface methodref; classindex=' , classIndex printString |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1817 |
, ' nameAndTypeIndex=' , nameAndTypeIndex printString. |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1818 |
]. |
2966 | 1819 |
^ JavaInterfaceMethodRef2 |
2151 | 1820 |
in: constants |
1821 |
withNameAndTypeAt: nameAndTypeIndex |
|
1822 |
andClassAt: classIndex. |
|
1823 |
||
1824 |
"Modified: / 12-05-2011 / 18:57:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1825 |
"Modified: / 04-08-2014 / 15:38:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
14
c1d9f60eb650
can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents:
11
diff
changeset
|
1826 |
! |
c1d9f60eb650
can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents:
11
diff
changeset
|
1827 |
|
3106
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1828 |
readConstant_InvokeDynamic |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1829 |
| bootstrapMethodAttrIndex nameAndTypeIndex | |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1830 |
|
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1831 |
bootstrapMethodAttrIndex := inStream nextUnsignedShortMSB: msb. |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1832 |
nameAndTypeIndex := inStream nextUnsignedShortMSB: msb. |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1833 |
|
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1834 |
^ JavaInvokeDynamic2 |
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1835 |
in: constants |
3106
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1836 |
bootstrapMethodAttrIndex:bootstrapMethodAttrIndex |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1837 |
nameAndTypeIndex:nameAndTypeIndex |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1838 |
|
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1839 |
"Created: / 20-05-2014 / 17:37:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1840 |
! |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1841 |
|
11 | 1842 |
readConstant_Long |
1843 |
|high low value| |
|
1844 |
||
128 | 1845 |
high := inStream nextUnsignedLongMSB:msb. |
1846 |
low := inStream nextUnsignedLongMSB:msb. |
|
11 | 1847 |
|
1848 |
value := (high bitShift:32) bitOr:low. |
|
60 | 1849 |
(high bitTest:16r80000000) ifTrue:[ |
252 | 1850 |
value := value - 16r10000000000000000. |
60 | 1851 |
]. |
11 | 1852 |
constNeeds2Slots := true. |
1853 |
||
61 | 1854 |
Verbose ifTrue:[Transcript show:'long; value= '; showCR:value]. |
11 | 1855 |
^ value |
1856 |
||
1857 |
" |
|
1858 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1859 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1860 |
" |
|
1861 |
||
1862 |
"Modified: 15.4.1996 / 15:42:16 / cg" |
|
1863 |
"Created: 15.4.1996 / 16:34:42 / cg" |
|
1864 |
! |
|
1865 |
||
3106
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1866 |
readConstant_MethodHandle |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1867 |
| reference_kind reference_index | |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1868 |
|
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1869 |
reference_kind := inStream next. |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1870 |
reference_index := inStream nextUnsignedShortMSB: msb. |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1871 |
|
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1872 |
^ JavaMethodHandle2 |
3106
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1873 |
in:constants |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1874 |
kind:reference_kind |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1875 |
index:reference_index |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1876 |
|
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1877 |
"Created: / 20-05-2014 / 17:30:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1878 |
! |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1879 |
|
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1880 |
readConstant_MethodType |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1881 |
| descriptorIndex | |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1882 |
|
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1883 |
descriptorIndex := inStream nextUnsignedShortMSB: msb. |
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
1884 |
^ JavaMethodType2 |
3106
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1885 |
in:constants |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1886 |
index:descriptorIndex |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1887 |
|
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1888 |
"Created: / 20-05-2014 / 17:40:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1889 |
! |
e53888146940
Added support for new constants used bu JSR 272 Invoke dynamic.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3003
diff
changeset
|
1890 |
|
1 | 1891 |
readConstant_Methodref |
2151 | 1892 |
| classIndex nameAndTypeIndex | |
1893 |
||
1894 |
classIndex := inStream nextUnsignedShortMSB: msb. |
|
2966 | 1895 |
nameAndTypeIndex := inStream nextUnsignedShortMSB: msb. |
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1896 |
Verbose ifTrue:[ |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1897 |
self |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1898 |
info: 'reading methodref; classindex=' , classIndex printString , ' nameAndTypeIndex=' |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1899 |
, nameAndTypeIndex printString. |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1900 |
]. |
2966 | 1901 |
^ JavaMethodRef2 |
2151 | 1902 |
in: constants |
1903 |
withNameAndTypeAt: nameAndTypeIndex |
|
1904 |
andClassAt: classIndex. |
|
1905 |
||
1906 |
"Modified: / 15-05-2011 / 14:20:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1907 |
"Modified: / 04-08-2014 / 15:38:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 1908 |
! |
1909 |
||
91 | 1910 |
readConstant_NameAndType |
2151 | 1911 |
| nameIndex descriptorIndex | |
1912 |
||
1913 |
nameIndex := inStream nextUnsignedShortMSB: msb. |
|
1914 |
descriptorIndex := inStream nextUnsignedShortMSB: msb. |
|
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1915 |
Verbose ifTrue:[ |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1916 |
self |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1917 |
info: 'reading nameAndType; nameindex=' , nameIndex printString |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1918 |
, ' descriptorIndex= ' , descriptorIndex printString. |
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1919 |
]. |
2966 | 1920 |
^JavaNameAndType2 |
2151 | 1921 |
in: constants |
1922 |
withNameAt: nameIndex |
|
1923 |
andDescriptorAt: descriptorIndex. |
|
1924 |
||
1925 |
"Modified: / 10-05-2011 / 17:09:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1926 |
"Modified: / 04-08-2014 / 15:38:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 1927 |
! |
1928 |
||
1929 |
readConstant_String |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1930 |
| string_index | |
2151 | 1931 |
|
1932 |
string_index := inStream nextUnsignedShortMSB: msb. |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1933 |
^ JavaStringRef2 in: constants withValueAt: string_index. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
1934 |
|
2966 | 1935 |
|
1936 |
||
2151 | 1937 |
"Created: / 15-04-1996 / 15:20:33 / cg" |
1938 |
"Modified: / 07-05-1998 / 11:42:45 / cg" |
|
1939 |
"Modified: / 13-05-2011 / 17:31:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1940 |
"Modified: / 10-08-2011 / 23:25:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
695 | 1941 |
! |
1942 |
||
1943 |
readConstant_Unicode |
|
2151 | 1944 |
| len string ascii | |
1945 |
||
1946 |
len := inStream nextUnsignedShortMSB: msb. |
|
1947 |
string := TwoByteString new: len. |
|
1948 |
1 to: len |
|
2966 | 1949 |
do: |
1950 |
[:idx | |
|
2151 | 1951 |
ascii := inStream nextUnsignedShortMSB: msb. |
1952 |
string at: idx put: (Character value: ascii). ]. |
|
3275
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
1953 |
string := InternedStrings elementAt: string ifAbsent: [ InternedStrings add: string ]. |
2966 | 1954 |
Verbose |
1955 |
ifTrue: |
|
2151 | 1956 |
[ Transcript |
1957 |
show: 'asciz; unicodeString= '; |
|
1958 |
showCR: string ]. |
|
695 | 1959 |
^ string |
2151 | 1960 |
|
1961 |
"Modified: / 13-05-2011 / 17:31:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
3275
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
1962 |
"Modified: / 13-11-2014 / 11:53:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
695 | 1963 |
! |
1964 |
||
1965 |
readConstant_Utf8 |
|
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1966 |
| len string | |
2151 | 1967 |
|
1968 |
len := inStream nextUnsignedShortMSB: msb. |
|
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1969 |
string := String uninitializedNew: len. |
2966 | 1970 |
inStream |
2151 | 1971 |
nextBytes: len |
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1972 |
into: string |
2151 | 1973 |
startingAt: 1. |
3195
0b6a9ff08acd
Class reading optimization [1/4]: optimize CharacterArray class>>decodeFromJavaUTF8:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3110
diff
changeset
|
1974 |
string := CharacterArray decodeFromJavaUTF8: string. |
3275
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
1975 |
string := InternedStrings elementAt: string ifAbsent: [ InternedStrings add: string ]. |
2966 | 1976 |
Verbose |
1977 |
ifTrue: |
|
2151 | 1978 |
[ Transcript |
1979 |
show: 'asciz; string= '; |
|
1980 |
showCR: string ]. |
|
695 | 1981 |
^ string |
2151 | 1982 |
|
1983 |
"Modified: / 13-05-2011 / 17:31:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
3275
881799d310e3
Intern all constant pool strings.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3198
diff
changeset
|
1984 |
"Modified: / 13-11-2014 / 11:53:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
344 | 1985 |
! ! |
1986 |
||
1987 |
!JavaClassReader methodsFor:'file reading - constants-ST'! |
|
1988 |
||
1989 |
readConstant_ST_Array |
|
1990 |
|aSize arr| |
|
1991 |
||
1992 |
aSize := inStream nextUnsignedShortMSB:msb. |
|
1993 |
arr := Array new:aSize. |
|
1994 |
||
1995 |
1 to:aSize do:[:i | |
|
350 | 1996 |
|element_index element| |
344 | 1997 |
|
1998 |
element_index := inStream nextUnsignedShortMSB:msb. |
|
1999 |
arr at:i put:element_index. |
|
2000 |
]. |
|
2001 |
Verbose ifTrue:[Transcript show:'array; size= '; showCR:aSize]. |
|
2002 |
||
2966 | 2003 |
^ JavaUnresolvedSTArrayConstant |
344 | 2004 |
pool:constants |
2005 |
poolIndex:constSlot |
|
2006 |
array:arr |
|
2007 |
||
2008 |
"Created: / 7.5.1998 / 11:47:01 / cg" |
|
350 | 2009 |
"Modified: / 9.5.1998 / 00:25:34 / cg" |
344 | 2010 |
! |
2011 |
||
2012 |
readConstant_ST_ByteArray |
|
2013 |
|aSize arr| |
|
2014 |
||
2015 |
aSize := inStream nextUnsignedShortMSB:msb. |
|
2016 |
arr := ByteArray new:aSize. |
|
2017 |
||
2018 |
1 to:aSize do:[:i | |
|
2019 |
|element_index| |
|
2020 |
||
2021 |
arr at:i put:(inStream nextByte). |
|
2022 |
]. |
|
2023 |
Verbose ifTrue:[Transcript show:'byteArray; size= '; showCR:aSize]. |
|
2024 |
||
2025 |
^ arr |
|
2026 |
||
2027 |
"Created: / 7.5.1998 / 11:47:12 / cg" |
|
2028 |
! |
|
2029 |
||
2030 |
readConstant_ST_Character |
|
2031 |
|ascii| |
|
2032 |
||
2033 |
ascii := inStream nextUnsignedShortMSB:msb. |
|
2034 |
||
2035 |
Verbose ifTrue:[Transcript show:'char; ascii= '; showCR:ascii]. |
|
2036 |
^ Character value:ascii |
|
2037 |
||
2038 |
"Created: / 7.5.1998 / 11:48:12 / cg" |
|
2039 |
! |
|
2040 |
||
350 | 2041 |
readConstant_ST_Special |
2042 |
|type| |
|
2043 |
||
2044 |
type := inStream nextUnsignedShortMSB:msb. |
|
2045 |
^ #( |
|
2046 |
nil |
|
2047 |
true |
|
2048 |
false |
|
2049 |
) at:(type + 1) |
|
2050 |
||
2051 |
"Created: / 8.5.1998 / 23:06:56 / cg" |
|
2052 |
"Modified: / 9.5.1998 / 00:40:14 / cg" |
|
2053 |
! |
|
2054 |
||
344 | 2055 |
readConstant_ST_String |
2151 | 2056 |
| tag string_index chars | |
2057 |
||
2058 |
||
2059 |
string_index := inStream nextUnsignedShortMSB: msb. |
|
2966 | 2060 |
Verbose |
2061 |
ifTrue: |
|
2151 | 2062 |
[ Transcript |
2063 |
show: 'string; index= '; |
|
2064 |
showCR: string_index ]. |
|
2966 | 2065 |
|
344 | 2066 |
"/ resolve here if possible |
2966 | 2067 |
|
2068 |
string_index < constSlot |
|
2069 |
ifTrue: |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
2070 |
[ chars := (self constantPoolAt: string_index). |
2151 | 2071 |
^ chars ]. |
2966 | 2072 |
^ JavaUnresolvedSTStringConstant |
2151 | 2073 |
pool: constants |
2074 |
poolIndex: constSlot |
|
2075 |
stringIndex: string_index |
|
2076 |
||
2077 |
"Created: / 07-05-1998 / 11:49:55 / cg" |
|
2078 |
"Modified: / 13-05-2011 / 17:32:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
344 | 2079 |
! |
2080 |
||
2081 |
readConstant_ST_Symbol |
|
2151 | 2082 |
| tag string_index chars | |
2083 |
||
2084 |
||
2085 |
string_index := inStream nextUnsignedShortMSB: msb. |
|
2966 | 2086 |
Verbose |
2087 |
ifTrue: |
|
2151 | 2088 |
[ Transcript |
2089 |
show: 'symbol; index= '; |
|
2090 |
showCR: string_index ]. |
|
2966 | 2091 |
|
344 | 2092 |
"/ resolve here if possible |
2966 | 2093 |
|
2094 |
string_index < constSlot |
|
2095 |
ifTrue: |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
2096 |
[ chars := (self constantPoolAt: string_index). |
2151 | 2097 |
chars isString ifFalse: [ self halt: 'should not happen' ]. |
2098 |
^ chars asSymbol ]. |
|
2966 | 2099 |
^ JavaUnresolvedSTSymbolConstant |
2151 | 2100 |
pool: constants |
2101 |
poolIndex: constSlot |
|
2102 |
stringIndex: string_index |
|
2103 |
||
2104 |
"Modified: / 07-05-1998 / 11:48:28 / cg" |
|
2105 |
"Modified: / 13-05-2011 / 17:32:09 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
5 | 2106 |
! ! |
2107 |
||
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2108 |
!JavaClassReader methodsFor:'file reading - extensions'! |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2109 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2110 |
readExtensionsFor: class |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2111 |
"Given a class, load extensions (i.e., non-java methods) for that class" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2112 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2113 |
| classnameAsPath | |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2114 |
|
2841
6fa1bcf9c997
JavaClass>>#name vs. #binaryName refactoring
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2812
diff
changeset
|
2115 |
classnameAsPath := class binaryName copyReplaceAll: $/ with: Filename separator. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2116 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2117 |
Java effectiveExtensionsPath do:[:each| |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2118 |
ProgrammingLanguage allDo:[:lang| |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2119 |
lang supportsExtensionMethods ifTrue:[ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2120 |
| file | |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2121 |
file := each asString , Filename separator , classnameAsPath , '.' , lang sourceFileSuffix. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2122 |
file := file asFilename. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2123 |
file exists ifTrue:[ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2124 |
self readExtensionsFor: class from: file language: lang |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2125 |
] |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2126 |
] |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2127 |
] |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2128 |
] |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2129 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2130 |
"Created: / 06-09-2012 / 11:37:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2841
6fa1bcf9c997
JavaClass>>#name vs. #binaryName refactoring
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2812
diff
changeset
|
2131 |
"Modified: / 08-10-2013 / 22:59:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2132 |
! |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2133 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2134 |
readExtensionsFor: class from: file |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2135 |
"Given a class, load extensions (i.e., non-java methods) for that class" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2136 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2137 |
JAVA isNil ifTrue:[ JavaPackage initialize ]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2138 |
[ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2139 |
Smalltalk fileIn: file. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2140 |
] on: JavaClassQuery do:[:query | |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2141 |
query className = class name ifTrue:[ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2142 |
query resumeWith: class |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2143 |
] ifFalse:[ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2144 |
query resumeWith: nil. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2145 |
] |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2146 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2147 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2148 |
"Created: / 06-09-2012 / 12:04:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2149 |
! |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2150 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2151 |
readExtensionsFor: class from: file language: language |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2152 |
"Given a class, load extensions (i.e., non-java methods) for that class" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2153 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2154 |
JAVA isNil ifTrue:[ JavaPackage initialize ]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2155 |
[ |
2812
7cd5e50a6c5a
Load java extension methods silently.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2732
diff
changeset
|
2156 |
| wasSilent | |
7cd5e50a6c5a
Load java extension methods silently.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2732
diff
changeset
|
2157 |
|
7cd5e50a6c5a
Load java extension methods silently.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2732
diff
changeset
|
2158 |
wasSilent := Smalltalk silentLoading. |
7cd5e50a6c5a
Load java extension methods silently.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2732
diff
changeset
|
2159 |
Smalltalk silentLoading: true. |
7cd5e50a6c5a
Load java extension methods silently.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2732
diff
changeset
|
2160 |
[ |
7cd5e50a6c5a
Load java extension methods silently.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2732
diff
changeset
|
2161 |
Class withoutUpdatingChangesDo:[ |
7cd5e50a6c5a
Load java extension methods silently.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2732
diff
changeset
|
2162 |
language fileIn: file. |
7cd5e50a6c5a
Load java extension methods silently.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2732
diff
changeset
|
2163 |
]. |
7cd5e50a6c5a
Load java extension methods silently.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2732
diff
changeset
|
2164 |
] ensure:[ |
2966 | 2165 |
Smalltalk silentLoading: wasSilent |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2166 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2167 |
] on: JavaClassQuery do:[:query | |
2841
6fa1bcf9c997
JavaClass>>#name vs. #binaryName refactoring
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2812
diff
changeset
|
2168 |
query className = class binaryName ifTrue:[ |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2169 |
query resumeWith: class |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2170 |
] ifFalse:[ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2171 |
query resumeWith: nil. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2172 |
] |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2173 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2174 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2175 |
"Created: / 06-09-2012 / 12:14:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2812
7cd5e50a6c5a
Load java extension methods silently.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2732
diff
changeset
|
2176 |
"Modified: / 08-10-2013 / 11:12:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2177 |
! ! |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2178 |
|
5 | 2179 |
!JavaClassReader methodsFor:'file reading - fields'! |
2180 |
||
2181 |
readConstantValueAttributeFor:aField |
|
2182 |
|attribute_length constantvalue_index constantValue| |
|
2183 |
||
128 | 2184 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
5 | 2185 |
|
128 | 2186 |
constantvalue_index := inStream nextUnsignedShortMSB:msb. |
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
2187 |
constantValue := self constantPoolAt:constantvalue_index. |
5 | 2188 |
|
59 | 2189 |
aField constantValue:constantValue. |
2190 |
||
61 | 2191 |
Verbose ifTrue:[Transcript show:'constantValue: '; showCR:constantValue]. |
5 | 2192 |
^ true |
2193 |
||
2194 |
" |
|
2195 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2196 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
2197 |
" |
|
2198 |
||
2199 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
2200 |
"Created: 15.4.1996 / 15:40:17 / cg" |
|
1 | 2201 |
! |
2202 |
||
2203 |
readFieldInfofield |
|
2151 | 2204 |
| access_flags name_index descriptor_index attributes_count field | |
2205 |
||
2206 |
access_flags := inStream nextUnsignedShortMSB: msb. |
|
2207 |
name_index := inStream nextUnsignedShortMSB: msb. |
|
2208 |
descriptor_index := inStream nextUnsignedShortMSB: msb. |
|
5 | 2209 |
field := JavaField new. |
2151 | 2210 |
field setAccessFlags: access_flags. |
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
2211 |
field setName: (self constantPoolAt: name_index) asSymbol. |
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
2212 |
field setDescriptor: (self constantPoolAt: descriptor_index) asSymbol. |
2151 | 2213 |
attributes_count := inStream nextUnsignedShortMSB: msb. |
2729
ac412f6ea6d4
More support for method's source display. Not yet working.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2591
diff
changeset
|
2214 |
attributes := OrderedCollection new: attributes_count * 2. |
2966 | 2215 |
Verbose |
2216 |
ifTrue: |
|
2151 | 2217 |
[ Transcript |
2218 |
show: ' field name: '; |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
2219 |
show: (self constantPoolAt: name_index); |
2151 | 2220 |
show: ' access: '; |
2221 |
show: access_flags; |
|
2222 |
show: ' attrib_cnt: '; |
|
2223 |
showCR: attributes_count ]. |
|
2224 |
1 to: attributes_count do: [:i | self readAttributeFor: field. ]. |
|
2225 |
^ field. |
|
27 | 2226 |
|
1 | 2227 |
" |
2151 | 2228 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'" |
2229 |
||
2230 |
"Created: / 15-04-1996 / 15:38:43 / cg" |
|
2231 |
"Modified: / 15-10-1998 / 10:38:01 / cg" |
|
2232 |
"Modified: / 17-12-2010 / 18:44:30 / Marcel Hlopko <hlopik@gmail.com>" |
|
2233 |
"Modified: / 18-05-2011 / 14:11:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
3294
1013708261a8
JavaClass memory optimization (part 5)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3293
diff
changeset
|
2234 |
"Modified: / 08-12-2014 / 16:25:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 2235 |
! |
2236 |
||
2237 |
readFieldInfofields |
|
38 | 2238 |
|nFields fields| |
1 | 2239 |
|
2240 |
"/ |
|
38 | 2241 |
"/ get fieldInfos |
1 | 2242 |
"/ |
128 | 2243 |
nFields := inStream nextUnsignedShortMSB:msb. |
61 | 2244 |
Verbose ifTrue:[Transcript show:'fieldsCount = '; showCR:nFields]. |
1 | 2245 |
|
27 | 2246 |
fields := Array new:nFields. |
2247 |
||
2248 |
1 to:nFields do:[:i | |
|
252 | 2249 |
Verbose ifTrue:[Transcript show:'field: '; showCR:i]. |
2250 |
fields at:i put:(self readFieldInfofield) |
|
1 | 2251 |
]. |
38 | 2252 |
^ fields |
1 | 2253 |
|
2254 |
" |
|
2255 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2256 |
" |
|
2257 |
||
2258 |
"Created: 15.4.1996 / 15:34:41 / cg" |
|
2259 |
"Modified: 15.4.1996 / 15:35:28 / cg" |
|
5 | 2260 |
! ! |
2261 |
||
38 | 2262 |
!JavaClassReader methodsFor:'file reading - interfaces'! |
2263 |
||
2264 |
readInterfaces |
|
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2265 |
| interfacesCount interface_index interfaces | |
38 | 2266 |
|
2267 |
"/ |
|
2268 |
"/ get interfaces |
|
2269 |
"/ |
|
128 | 2270 |
interfacesCount := inStream nextUnsignedShortMSB:msb. |
61 | 2271 |
Verbose ifTrue:[Transcript show:'interfacesCount = '; showCR:interfacesCount]. |
38 | 2272 |
|
2273 |
interfaces := Array new:interfacesCount. |
|
2274 |
||
2275 |
1 to:interfacesCount do:[:i | |
|
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2276 |
Verbose ifTrue:[Transcript show:'interface: '; showCR:i]. |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2277 |
interface_index := inStream nextUnsignedShortMSB:msb. |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2278 |
interfaces at:i put:interface_index. |
38 | 2279 |
]. |
2280 |
^ interfaces |
|
2281 |
||
2282 |
" |
|
2283 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2284 |
" |
|
2285 |
||
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2286 |
"Created: / 15-04-1996 / 15:31:59 / cg" |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2287 |
"Modified: / 27-11-2014 / 16:55:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
38 | 2288 |
! ! |
2289 |
||
5 | 2290 |
!JavaClassReader methodsFor:'file reading - methods'! |
2291 |
||
2292 |
readCodeAttributeFor:aJavaMethod |
|
2293 |
|attribute_length max_stack max_locals code_length code |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2294 |
exception_table_length exception_table unknown1 unknown2 | |
1 | 2295 |
|
128 | 2296 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
1 | 2297 |
|
357 | 2298 |
Verbose ifTrue:[Transcript show:'code_attribute_length: 0x'; showCR:(attribute_length printStringRadix:16)]. |
9 | 2299 |
|
2151 | 2300 |
((minorVsn > 2) or:[majorVsn > 45]) ifTrue:[ |
348 | 2301 |
"/ should be: |
2302 |
max_stack := inStream nextUnsignedShortMSB:msb. |
|
2303 |
max_locals := inStream nextUnsignedShortMSB:msb. |
|
2304 |
code_length := inStream nextUnsignedLongMSB:msb. |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2305 |
"/ Remember max context size so far, will be used to |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2306 |
"/ optimize context size as alloca() won't work. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2307 |
MaxContextSize := MaxContextSize max: (max_stack + max_locals + 4"safe area"). |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2308 |
" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2309 |
MaxContextSize > MaxContextSizeLimit ifTrue:[ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2310 |
self error:'method''s stack depth overflows VM limit'. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2311 |
^false |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2312 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2313 |
" |
348 | 2314 |
|
2315 |
"/ unknown1 := inStream nextByte. |
|
2316 |
"/ max_stack := inStream nextByte. |
|
2317 |
"/ max_locals := inStream nextUnsignedShortMSB:msb. |
|
2318 |
"/ unknown2 := inStream nextUnsignedShortMSB:msb. |
|
2319 |
"/ code_length := inStream nextUnsignedShortMSB:msb. |
|
2320 |
"/ Verbose ifTrue:[Transcript show:'?1: '; showCR:unknown1]. |
|
2321 |
"/ Verbose ifTrue:[Transcript show:'?2: '; showCR:unknown2]. |
|
39 | 2322 |
] ifFalse:[ |
348 | 2323 |
max_stack := inStream nextByte. |
2324 |
max_locals := inStream nextByte. |
|
2325 |
code_length := inStream nextUnsignedShortMSB:msb. |
|
9 | 2326 |
]. |
2327 |
||
357 | 2328 |
Verbose ifTrue:[ |
2329 |
Transcript show:'code_length: '; showCR:(code_length printStringRadix:16). |
|
2330 |
Transcript show:'code at pos: '; showCR:inStream position |
|
2331 |
]. |
|
38 | 2332 |
|
357 | 2333 |
code_length ~~ 0 ifTrue:[ |
2334 |
code := ByteArray new:code_length. |
|
2335 |
inStream nextBytes:code_length into:code startingAt:1. |
|
2336 |
]. |
|
2337 |
Verbose ifTrue:[Transcript show:'method code: '; showCR:code.]. |
|
9 | 2338 |
|
128 | 2339 |
exception_table_length := inStream nextUnsignedShortMSB:msb. |
61 | 2340 |
Verbose ifTrue:[Transcript show:'exception_table_length: '; showCR:(exception_table_length printStringRadix:16)]. |
5 | 2341 |
exception_table_length ~~ 0 ifTrue:[ |
348 | 2342 |
Verbose ifTrue:[Transcript show:'exceptionTable length:'; showCR:exception_table_length.]. |
9 | 2343 |
|
2585
14ab287e17ca
Exception table refactored to use more compact & VM friendly format.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2578
diff
changeset
|
2344 |
exception_table := JavaExceptionTable new:exception_table_length * 4. |
348 | 2345 |
1 to:exception_table_length do:[:i | |
2585
14ab287e17ca
Exception table refactored to use more compact & VM friendly format.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2578
diff
changeset
|
2346 |
|
14ab287e17ca
Exception table refactored to use more compact & VM friendly format.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2578
diff
changeset
|
2347 |
"/ start PC |
14ab287e17ca
Exception table refactored to use more compact & VM friendly format.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2578
diff
changeset
|
2348 |
exception_table at:((i-1) * 4) + 1 put: (inStream nextUnsignedShortMSB:msb). |
14ab287e17ca
Exception table refactored to use more compact & VM friendly format.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2578
diff
changeset
|
2349 |
"/ end PC |
14ab287e17ca
Exception table refactored to use more compact & VM friendly format.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2578
diff
changeset
|
2350 |
exception_table at:((i-1) * 4) + 2 put: (inStream nextUnsignedShortMSB:msb). |
14ab287e17ca
Exception table refactored to use more compact & VM friendly format.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2578
diff
changeset
|
2351 |
"/ handler PC |
14ab287e17ca
Exception table refactored to use more compact & VM friendly format.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2578
diff
changeset
|
2352 |
exception_table at:((i-1) * 4) + 3 put: (inStream nextUnsignedShortMSB:msb). |
14ab287e17ca
Exception table refactored to use more compact & VM friendly format.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2578
diff
changeset
|
2353 |
"/ catch type |
14ab287e17ca
Exception table refactored to use more compact & VM friendly format.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2578
diff
changeset
|
2354 |
exception_table at:((i-1) * 4) + 4 put: (inStream nextUnsignedShortMSB:msb). |
348 | 2355 |
]. |
2356 |
aJavaMethod setExceptionHandlerTable:exception_table. |
|
1 | 2357 |
]. |
2358 |
||
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2359 |
(max_stack + max_locals + 4) > MaxContextSizeLimit ifTrue:[ |
2585
14ab287e17ca
Exception table refactored to use more compact & VM friendly format.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2578
diff
changeset
|
2360 |
code := nil |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2361 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2362 |
|
2966 | 2363 |
aJavaMethod |
2364 |
setCode:code |
|
2365 |
maxStack:max_stack |
|
2366 |
maxLocals:max_locals |
|
2367 |
u1:unknown1 |
|
348 | 2368 |
u2:unknown2. |
5 | 2369 |
|
2370 |
self readAttributesFor:aJavaMethod. |
|
2371 |
^ true |
|
2372 |
||
1 | 2373 |
" |
2374 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
5 | 2375 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
1 | 2376 |
" |
2377 |
||
2151 | 2378 |
"Created: / 15-04-1996 / 15:40:17 / cg" |
2379 |
"Modified: / 16-05-1998 / 01:39:42 / cg" |
|
2585
14ab287e17ca
Exception table refactored to use more compact & VM friendly format.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2578
diff
changeset
|
2380 |
"Modified: / 06-05-2013 / 22:08:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
5 | 2381 |
! |
2382 |
||
83 | 2383 |
readExceptionsAttributeFor:aJavaMethod |
2384 |
|attribute_length exception_table_length exception_table| |
|
2385 |
||
128 | 2386 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
83 | 2387 |
|
128 | 2388 |
exception_table_length := inStream nextUnsignedShortMSB:msb. |
83 | 2389 |
exception_table_length ~~ 0 ifTrue:[ |
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2390 |
exception_table := Array new:exception_table_length. |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2391 |
1 to:exception_table_length do:[:i | |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2392 |
| idx | |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2393 |
|
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2394 |
idx := inStream nextUnsignedShortMSB:msb. |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2395 |
exception_table at:i put:idx. |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2396 |
]. |
83 | 2397 |
]. |
2398 |
||
2399 |
Verbose ifTrue:[Transcript showCR:'method has an exceptionTable']. |
|
2400 |
||
2401 |
aJavaMethod setExceptionTable:exception_table. |
|
2402 |
^ true |
|
2403 |
||
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2404 |
"Created: / 15-04-1996 / 15:40:17 / cg" |
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2405 |
"Modified: / 04-12-2014 / 14:29:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
83 | 2406 |
! |
2407 |
||
5 | 2408 |
readLineNumberTableAttributeFor:aJavaMethod |
2409 |
|attribute_length line_number_table_length line_number_table| |
|
2410 |
||
128 | 2411 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
5 | 2412 |
|
128 | 2413 |
line_number_table_length := inStream nextUnsignedShortMSB:msb. |
5 | 2414 |
line_number_table_length ~~ 0 ifTrue:[ |
330 | 2415 |
line_number_table := Array new:line_number_table_length. |
2416 |
1 to:line_number_table_length do:[:i | |
|
2417 |
|start_pc line_number| |
|
5 | 2418 |
|
330 | 2419 |
start_pc := inStream nextUnsignedShortMSB:msb. |
2420 |
line_number := inStream nextUnsignedShortMSB:msb. |
|
2421 |
line_number_table at:i put:(start_pc -> line_number). |
|
2422 |
]. |
|
2423 |
Verbose ifTrue:[Transcript showCR:'method has a lineNumberTable']. |
|
2424 |
||
2425 |
aJavaMethod setLineNumberTable:line_number_table. |
|
5 | 2426 |
]. |
2427 |
||
2428 |
^ true |
|
2429 |
||
2430 |
" |
|
2431 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2432 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/java/lang/Boolean.class' |
|
2433 |
" |
|
2434 |
||
330 | 2435 |
"Created: / 15.4.1996 / 15:40:17 / cg" |
2436 |
"Modified: / 7.4.1998 / 19:08:42 / cg" |
|
1 | 2437 |
! |
2438 |
||
50 | 2439 |
readLocalVariableTableAttributeFor:aJavaMethod |
2440 |
|attribute_length local_variable_table_length local_variable_table| |
|
2441 |
||
128 | 2442 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
50 | 2443 |
|
128 | 2444 |
local_variable_table_length := inStream nextUnsignedShortMSB:msb. |
50 | 2445 |
local_variable_table_length ~~ 0 ifTrue:[ |
252 | 2446 |
local_variable_table := JavaLocalVariableTable new:local_variable_table_length. |
2447 |
1 to:local_variable_table_length do:[:i | |
|
2448 |
|start_pc length name_index sig_index slot name signature| |
|
50 | 2449 |
|
252 | 2450 |
start_pc := inStream nextUnsignedShortMSB:msb. |
2451 |
length := inStream nextUnsignedShortMSB:msb. |
|
2452 |
name_index := inStream nextUnsignedShortMSB:msb. |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
2453 |
name := self constantPoolAt:name_index. |
252 | 2454 |
sig_index := inStream nextUnsignedShortMSB:msb. |
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
2455 |
signature := self constantPoolAt:sig_index. |
252 | 2456 |
slot := inStream nextUnsignedShortMSB:msb. |
50 | 2457 |
|
2966 | 2458 |
local_variable_table at:i put:(JavaLocalVariableTableEntry new |
2459 |
startPC:start_pc |
|
252 | 2460 |
length:length |
2461 |
name:name |
|
2462 |
signature:signature |
|
2463 |
slot:slot) |
|
2464 |
]. |
|
50 | 2465 |
]. |
2466 |
||
61 | 2467 |
Verbose ifTrue:[Transcript showCR:'method has a localvariableTable']. |
50 | 2468 |
|
2469 |
aJavaMethod setLocalVariableTable:local_variable_table. |
|
2470 |
^ true |
|
2471 |
||
2472 |
" |
|
2473 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2474 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/java/lang/Boolean.class' |
|
2475 |
" |
|
2476 |
||
2477 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
2478 |
"Created: 15.4.1996 / 15:40:17 / cg" |
|
2479 |
! |
|
2480 |
||
3110
2c747ca6078d
[JavaClassReader optimization 2/3]: add methods at once instead of individually.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3106
diff
changeset
|
2481 |
readMethodFor:aJavaClass into: aMethodDictionary |
2151 | 2482 |
|m access_flags name_index name descriptor_index descriptor |
273 | 2483 |
tooManyArgs| |
1 | 2484 |
|
2485 |
"/ |
|
2486 |
"/ get a method |
|
2487 |
"/ |
|
128 | 2488 |
access_flags := inStream nextUnsignedShortMSB:msb. |
2489 |
name_index := inStream nextUnsignedShortMSB:msb. |
|
2151 | 2490 |
descriptor_index := inStream nextUnsignedShortMSB:msb. |
1 | 2491 |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
2492 |
name := self constantPoolAt:name_index. |
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
2493 |
descriptor := self constantPoolAt:descriptor_index. |
9 | 2494 |
|
357 | 2495 |
Verbose ifTrue:[ |
2496 |
Transcript show:'method name:'; showCR:name. |
|
2151 | 2497 |
Transcript show:'descriptor:'; showCR:descriptor. |
357 | 2498 |
]. |
9 | 2499 |
|
3110
2c747ca6078d
[JavaClassReader optimization 2/3]: add methods at once instead of individually.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3106
diff
changeset
|
2500 |
aJavaClass isJavaClass ifTrue:[ |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2501 |
(access_flags bitAnd:ACC_NATIVE) ~~ 0 ifTrue:[ |
612 | 2502 |
m := JavaNativeMethod new. |
2503 |
] ifFalse:[ |
|
2504 |
m := JavaMethodWithHandler new. |
|
2505 |
]. |
|
357 | 2506 |
m setAccessFlags:access_flags. |
3110
2c747ca6078d
[JavaClassReader optimization 2/3]: add methods at once instead of individually.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3106
diff
changeset
|
2507 |
m setJavaClass:aJavaClass. |
357 | 2508 |
tooManyArgs := false. |
3384
98eb8443f4f4
Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3324
diff
changeset
|
2509 |
[ |
98eb8443f4f4
Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3324
diff
changeset
|
2510 |
m setName:name descriptor:descriptor. |
98eb8443f4f4
Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3324
diff
changeset
|
2511 |
] on: ArgumentError do:[:ex | |
98eb8443f4f4
Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3324
diff
changeset
|
2512 |
Logger log: 'java method has too many arguments - will fail to execute' severity: Logger severityWARN facility: 'JVM'. |
357 | 2513 |
tooManyArgs := true. |
2514 |
ex proceed. |
|
2515 |
]. |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2516 |
|
357 | 2517 |
self readAttributesFor:m. |
2518 |
||
2519 |
tooManyArgs ifTrue:[ |
|
2520 |
m code:nil. |
|
2521 |
m byteCode:nil. |
|
2522 |
]. |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2523 |
|
423 | 2524 |
(m exceptionHandlerTable isNil) ifTrue:[ |
612 | 2525 |
m isNative ifFalse:[ |
2151 | 2526 |
m getExceptionTable isNil ifTrue:[ |
612 | 2527 |
m := JavaMethod fromMethod:m |
2528 |
] ifFalse:[ |
|
2529 |
m := JavaMethodWithException fromMethod:m |
|
2530 |
] |
|
423 | 2531 |
] |
468 | 2532 |
] ifFalse:[ |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2533 |
| newAccessFlags | |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2534 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2535 |
newAccessFlags := m accessFlags. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2536 |
newAccessFlags := newAccessFlags bitOr:ACX_HASHANDLER. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2537 |
m hasFinallyBasedOnExceptionTable ifTrue:[ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2538 |
newAccessFlags := newAccessFlags bitOr:ACX_HASFINALLY. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2539 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2540 |
m setAccessFlags:newAccessFlags. |
386 | 2541 |
]. |
3110
2c747ca6078d
[JavaClassReader optimization 2/3]: add methods at once instead of individually.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3106
diff
changeset
|
2542 |
aMethodDictionary at: (name , descriptor) asSymbol put: m. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2543 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2544 |
( m selector == #'finalize()V' ) ifTrue:[ |
3110
2c747ca6078d
[JavaClassReader optimization 2/3]: add methods at once instead of individually.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3106
diff
changeset
|
2545 |
( aJavaClass binaryName ~~ #'java/lang/Object' ) ifTrue:[ |
2c747ca6078d
[JavaClassReader optimization 2/3]: add methods at once instead of individually.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3106
diff
changeset
|
2546 |
aJavaClass setAccessFlags: (aJavaClass accessFlags bitOr:ACX_HASFINALIZE) |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2547 |
] |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2548 |
]. |
357 | 2549 |
] ifFalse:[ |
3290
76d4443744ed
JavaClass memory optimization (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3289
diff
changeset
|
2550 |
"/ Reading method for non-Java class |
3110
2c747ca6078d
[JavaClassReader optimization 2/3]: add methods at once instead of individually.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3106
diff
changeset
|
2551 |
self error: 'Not really supported'. |
2c747ca6078d
[JavaClassReader optimization 2/3]: add methods at once instead of individually.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3106
diff
changeset
|
2552 |
|
357 | 2553 |
m := Method new. |
2554 |
self readAttributesFor:m. |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2555 |
(access_flags bitTest:ACC_STATIC) ifTrue:[ |
3110
2c747ca6078d
[JavaClassReader optimization 2/3]: add methods at once instead of individually.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3106
diff
changeset
|
2556 |
self addSelector:name asSymbol withMethod:m toClass: aJavaClass class. |
357 | 2557 |
] ifFalse:[ |
3110
2c747ca6078d
[JavaClassReader optimization 2/3]: add methods at once instead of individually.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3106
diff
changeset
|
2558 |
self addSelector:name asSymbol withMethod:m toClass: aJavaClass. |
357 | 2559 |
] |
273 | 2560 |
]. |
1 | 2561 |
|
2562 |
" |
|
2563 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2564 |
" |
|
2565 |
||
3110
2c747ca6078d
[JavaClassReader optimization 2/3]: add methods at once instead of individually.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3106
diff
changeset
|
2566 |
"Created: / 21-05-2014 / 15:58:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3384
98eb8443f4f4
Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3324
diff
changeset
|
2567 |
"Modified: / 02-03-2015 / 14:09:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 2568 |
! |
2569 |
||
38 | 2570 |
readMethodsFor:aJavaClass |
3110
2c747ca6078d
[JavaClassReader optimization 2/3]: add methods at once instead of individually.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3106
diff
changeset
|
2571 |
| methodsCount methodDict | |
1 | 2572 |
|
2573 |
"/ |
|
2574 |
"/ get methods |
|
2575 |
"/ |
|
128 | 2576 |
methodsCount := inStream nextUnsignedShortMSB:msb. |
61 | 2577 |
Verbose ifTrue:[Transcript show:'methodsCount = '; showCR:methodsCount]. |
3110
2c747ca6078d
[JavaClassReader optimization 2/3]: add methods at once instead of individually.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3106
diff
changeset
|
2578 |
methodDict := MethodDictionary new: methodsCount. |
1 | 2579 |
|
2580 |
1 to:methodsCount do:[:i | |
|
348 | 2581 |
Verbose ifTrue:[Transcript show:'method: '; showCR:i]. |
3110
2c747ca6078d
[JavaClassReader optimization 2/3]: add methods at once instead of individually.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3106
diff
changeset
|
2582 |
self readMethodFor: aJavaClass into: methodDict. |
1 | 2583 |
]. |
3198
a4ddeef7c5e9
Class reading optimization [4/4]: defer cache flushing at class initialization time.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3195
diff
changeset
|
2584 |
"/ Set method dictionary bit do noy yet flush caches. Caches are flushed |
a4ddeef7c5e9
Class reading optimization [4/4]: defer cache flushing at class initialization time.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3195
diff
changeset
|
2585 |
"/ at the very last moment, when a class is actually initialized. This should |
a4ddeef7c5e9
Class reading optimization [4/4]: defer cache flushing at class initialization time.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3195
diff
changeset
|
2586 |
"/ be sufficent as an object cannot be sent a message unless a class is |
a4ddeef7c5e9
Class reading optimization [4/4]: defer cache flushing at class initialization time.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3195
diff
changeset
|
2587 |
"/ initialized first. This saves us a little bit of time when reading classes |
a4ddeef7c5e9
Class reading optimization [4/4]: defer cache flushing at class initialization time.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3195
diff
changeset
|
2588 |
"/ but cost time when initializing the class, so normally this is not much |
a4ddeef7c5e9
Class reading optimization [4/4]: defer cache flushing at class initialization time.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3195
diff
changeset
|
2589 |
"/ of a saving. However, this helps in cases Java class is only read into memory |
a4ddeef7c5e9
Class reading optimization [4/4]: defer cache flushing at class initialization time.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3195
diff
changeset
|
2590 |
"/ and never initialized - that's what JBrowser Workspace does. |
a4ddeef7c5e9
Class reading optimization [4/4]: defer cache flushing at class initialization time.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3195
diff
changeset
|
2591 |
"/ See JavaClass>>classInit. |
a4ddeef7c5e9
Class reading optimization [4/4]: defer cache flushing at class initialization time.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3195
diff
changeset
|
2592 |
aJavaClass setMethodDictionary: methodDict. |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2593 |
|
1 | 2594 |
" |
2595 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2596 |
" |
|
2597 |
||
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2598 |
"Created: / 15-04-1996 / 16:46:30 / cg" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2599 |
"Modified: / 08-05-1998 / 21:20:59 / cg" |
3198
a4ddeef7c5e9
Class reading optimization [4/4]: defer cache flushing at class initialization time.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3195
diff
changeset
|
2600 |
"Modified (comment): / 04-08-2014 / 17:04:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 2601 |
! ! |
2602 |
||
344 | 2603 |
!JavaClassReader methodsFor:'file reading - methods-ST'! |
2604 |
||
348 | 2605 |
readSTCodeAttributeFor:aSmalltalkMethod |
2606 |
|attribute_length max_stack max_locals code_length code |
|
2607 |
exception_table_length unknown1 unknown2| |
|
2608 |
||
2609 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2610 |
||
2611 |
Verbose ifTrue:[Transcript show:'attribute_length: 0x'; showCR:(attribute_length printStringRadix:16)]. |
|
2612 |
||
2613 |
max_stack := inStream nextUnsignedShortMSB:msb. |
|
2614 |
max_locals := inStream nextUnsignedShortMSB:msb. |
|
2615 |
||
2616 |
code_length := inStream nextUnsignedLongMSB:msb. |
|
2617 |
Verbose ifTrue:[Transcript show:'code_length: '; showCR:(code_length printStringRadix:16)]. |
|
2618 |
Verbose ifTrue:[Transcript show:'code at pos: '; showCR:inStream position]. |
|
2619 |
||
357 | 2620 |
code_length ~~ 0 ifTrue:[ |
2621 |
code := ByteArray new:code_length. |
|
2622 |
inStream nextBytes:code_length into:code startingAt:1. |
|
2623 |
]. |
|
2624 |
Verbose ifTrue:[Transcript show:'method code: '; showCR:code.]. |
|
348 | 2625 |
|
2626 |
exception_table_length := inStream nextUnsignedShortMSB:msb. |
|
2627 |
Verbose ifTrue:[Transcript show:'exception_table_length: '; showCR:(exception_table_length printStringRadix:16)]. |
|
2628 |
exception_table_length ~~ 0 ifTrue:[ |
|
2629 |
self error:'unexpected exceptionTable length'. |
|
2630 |
"/ skip it. |
|
2631 |
1 to:exception_table_length do:[:i | |
|
2632 |
"start_pc :=" inStream nextUnsignedShortMSB:msb. |
|
2633 |
"end_pc :=" inStream nextUnsignedShortMSB:msb. |
|
2634 |
"handler_pc :=" inStream nextUnsignedShortMSB:msb. |
|
2635 |
"catch_type :=" inStream nextUnsignedShortMSB:msb. |
|
2636 |
]. |
|
2637 |
]. |
|
2638 |
||
2966 | 2639 |
aSmalltalkMethod byteCode:code. |
357 | 2640 |
aSmalltalkMethod stackSize:max_stack . |
2966 | 2641 |
aSmalltalkMethod numberOfVars:max_locals. |
348 | 2642 |
|
2643 |
self readAttributesFor:aSmalltalkMethod. |
|
2644 |
^ true |
|
2645 |
||
357 | 2646 |
"Modified: / 16.5.1998 / 01:39:30 / cg" |
348 | 2647 |
! |
2648 |
||
344 | 2649 |
readSTLiteralsAttributeFor:aSmalltalkMethod |
348 | 2650 |
|attribute_length literal_table_length literal_table litIndex literal| |
2651 |
||
2652 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2653 |
||
2654 |
literal_table_length := inStream nextUnsignedShortMSB:msb. |
|
2655 |
literal_table_length ~~ 0 ifTrue:[ |
|
2656 |
literal_table := Array new:literal_table_length. |
|
2657 |
1 to:literal_table_length do:[:i | |
|
2658 |
litIndex := inStream nextUnsignedShortMSB:msb. |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
2659 |
literal := (self constantPoolAt:litIndex). |
348 | 2660 |
literal_table at:i put:literal. |
2661 |
]. |
|
2662 |
]. |
|
357 | 2663 |
Verbose ifTrue:[Transcript show:'literals: '; showCR:literal_table storeString.]. |
344 | 2664 |
|
2665 |
"Created: / 7.5.1998 / 11:52:28 / cg" |
|
357 | 2666 |
"Modified: / 16.5.1998 / 01:52:27 / cg" |
2667 |
! |
|
2668 |
||
2669 |
readSTMethodCategoryAttributeFor:aSmalltalkMethod |
|
2670 |
|attribute_length name_index name| |
|
2671 |
||
2672 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2673 |
||
2674 |
name_index := inStream nextUnsignedShortMSB:msb. |
|
3291
2cf782f380f2
JavaClass memory optimization (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3290
diff
changeset
|
2675 |
name := (self constantPoolAt:name_index). |
357 | 2676 |
|
2677 |
aSmalltalkMethod category:name. |
|
2678 |
||
348 | 2679 |
"Modified: / 8.5.1998 / 20:39:59 / cg" |
357 | 2680 |
"Created: / 16.5.1998 / 01:04:19 / cg" |
344 | 2681 |
! ! |
2682 |
||
2151 | 2683 |
!JavaClassReader methodsFor:'helpers'! |
2684 |
||
2428
392a2eba9c42
Cherry-picked JavaClassReader from rev 8762fc7137c6.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2396
diff
changeset
|
2685 |
addSelector: selector withMethod: method toClass: javaClass |
392a2eba9c42
Cherry-picked JavaClassReader from rev 8762fc7137c6.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2396
diff
changeset
|
2686 |
"Basically a primAddSelector:withMethod:. This indirection |
392a2eba9c42
Cherry-picked JavaClassReader from rev 8762fc7137c6.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2396
diff
changeset
|
2687 |
is required by Expecco (it uses custom class reader so |
392a2eba9c42
Cherry-picked JavaClassReader from rev 8762fc7137c6.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2396
diff
changeset
|
2688 |
which overrides this method" |
392a2eba9c42
Cherry-picked JavaClassReader from rev 8762fc7137c6.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2396
diff
changeset
|
2689 |
|
392a2eba9c42
Cherry-picked JavaClassReader from rev 8762fc7137c6.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2396
diff
changeset
|
2690 |
javaClass primAddSelector:selector withMethod: method |
392a2eba9c42
Cherry-picked JavaClassReader from rev 8762fc7137c6.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2396
diff
changeset
|
2691 |
|
392a2eba9c42
Cherry-picked JavaClassReader from rev 8762fc7137c6.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2396
diff
changeset
|
2692 |
"Created: / 26-02-2013 / 11:42:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
392a2eba9c42
Cherry-picked JavaClassReader from rev 8762fc7137c6.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2396
diff
changeset
|
2693 |
! |
392a2eba9c42
Cherry-picked JavaClassReader from rev 8762fc7137c6.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2396
diff
changeset
|
2694 |
|
2966 | 2695 |
loadSuperclassIdentifiedBy: aJavaClassRef ignoring: classesBeingLoaded |
2151 | 2696 |
"overriding method, here we expect something to be new JavaClassRef2" |
2966 | 2697 |
|
2841
6fa1bcf9c997
JavaClass>>#name vs. #binaryName refactoring
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2812
diff
changeset
|
2698 |
self assert: aJavaClassRef isJavaRef |
2151 | 2699 |
message: 'class identifier is not a java reference'. |
2841
6fa1bcf9c997
JavaClass>>#name vs. #binaryName refactoring
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2812
diff
changeset
|
2700 |
self assert: aJavaClassRef isJavaClassRef |
2151 | 2701 |
message: 'class identifier is not a java class reference'. |
2841
6fa1bcf9c997
JavaClass>>#name vs. #binaryName refactoring
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2812
diff
changeset
|
2702 |
(classesBeingLoaded includes: aJavaClassRef name) ifTrue: [ |
2966 | 2703 |
self |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2704 |
error: 'class we want to load is being loaded and that means something went wrong. tell mh' |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2705 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2706 |
"hint in case of bug - is parent of something set? surely jv will know more :)" "find out which classloader is used" |
2841
6fa1bcf9c997
JavaClass>>#name vs. #binaryName refactoring
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2812
diff
changeset
|
2707 |
^ JavaVM classForName: aJavaClassRef name definedBy: classLoader. |
2151 | 2708 |
|
2709 |
"Created: / 18-05-2011 / 14:55:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
2841
6fa1bcf9c997
JavaClass>>#name vs. #binaryName refactoring
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2812
diff
changeset
|
2710 |
"Modified: / 08-10-2013 / 22:57:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2151 | 2711 |
! |
2712 |
||
2966 | 2713 |
updateOwnerInCPItem: each |
2714 |
((each isJavaRef and: [ each isNewJavaRef ]) |
|
2715 |
or: [ each isJavaNameAndType and: [ each isNewJavaNameAndType ] ]) |
|
2151 | 2716 |
ifTrue: [ each owner: classBeingLoaded ]. |
2717 |
||
2718 |
"Created: / 12-05-2011 / 17:40:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
2719 |
! |
|
2720 |
||
2966 | 2721 |
updateOwnerInField: each |
2151 | 2722 |
|
2723 |
each setClass: classBeingLoaded. |
|
2724 |
||
2725 |
"Created: / 18-05-2011 / 13:57:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
2726 |
! ! |
|
2727 |
||
2728 |
!JavaClassReader methodsFor:'logging'! |
|
2729 |
||
2966 | 2730 |
info: message |
3384
98eb8443f4f4
Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3324
diff
changeset
|
2731 |
Verbose ifTrue: [ Logger log: message severity: Logger severityINFO facility: 'JVM' ]. |
2151 | 2732 |
|
2733 |
"Created: / 18-05-2011 / 15:06:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
3384
98eb8443f4f4
Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3324
diff
changeset
|
2734 |
"Modified: / 02-03-2015 / 14:10:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2151 | 2735 |
! ! |
2736 |
||
135 | 2737 |
!JavaClassReader class methodsFor:'documentation'! |
1 | 2738 |
|
2739 |
version |
|
3590 | 2740 |
^ '$Header$' |
2148 | 2741 |
! |
2742 |
||
2743 |
version_CVS |
|
3590 | 2744 |
^ '$Header$' |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2745 |
! |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2746 |
|
2151 | 2747 |
version_SVN |
3590 | 2748 |
^ '$Id$' |
1 | 2749 |
! ! |
2108 | 2750 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2151
diff
changeset
|
2751 |
|
2089 | 2752 |
JavaClassReader initialize! |