author | vranyj1 |
Mon, 03 Dec 2012 22:09:19 +0000 | |
branch | development |
changeset 1859 | 4d42d0099c74 |
parent 1818 | 2e5ed72e7dfd |
child 1864 | 60a8dc26c8c6 |
permissions | -rw-r--r-- |
877 | 1 |
" |
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 3 |
|
1155 | 4 |
New code and modifications done at SWING Research Group [1]: |
1152 | 5 |
|
877 | 6 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
7 |
SWING Research Group, Czech Technical University in Prague |
|
8 |
||
9 |
This software is furnished under a license and may be used |
|
10 |
only in accordance with the terms of that license and with the |
|
11 |
inclusion of the above copyright notice. This software may not |
|
12 |
be provided or otherwise made available to, or used by, any |
|
13 |
other person. No title to or ownership of the software is |
|
14 |
hereby transferred. |
|
15 |
||
1155 | 16 |
[1] Code written at SWING Research Group contains a signature |
17 |
of one of the above copright owners. For exact set of such code, |
|
18 |
see the differences between this version and version stx:libjava |
|
1152 | 19 |
as of 1.9.2010 |
877 | 20 |
" |
752 | 21 |
"{ Package: 'stx:libjava' }" |
22 |
||
23 |
JavaRef2 subclass:#JavaClassRef2 |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
24 |
instanceVariableNames:'nameIndex' |
752 | 25 |
classVariableNames:'' |
26 |
poolDictionaries:'' |
|
27 |
category:'Languages-Java-Reader-Support-new' |
|
28 |
! |
|
29 |
||
877 | 30 |
!JavaClassRef2 class methodsFor:'documentation'! |
31 |
||
32 |
copyright |
|
33 |
" |
|
34 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 35 |
|
1155 | 36 |
New code and modifications done at SWING Research Group [1]: |
1152 | 37 |
|
877 | 38 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
39 |
SWING Research Group, Czech Technical University in Prague |
|
40 |
||
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
47 |
||
1155 | 48 |
[1] Code written at SWING Research Group contains a signature |
49 |
of one of the above copright owners. For exact set of such code, |
|
50 |
see the differences between this version and version stx:libjava |
|
1152 | 51 |
as of 1.9.2010 |
877 | 52 |
|
53 |
" |
|
54 |
! ! |
|
752 | 55 |
|
56 |
!JavaClassRef2 class methodsFor:'instance creation'! |
|
57 |
||
771 | 58 |
in: aJavaConstantPool withNameAt: nameIndex |
59 |
^ self basicNew initializeIn: aJavaConstantPool withNameAt: nameIndex. |
|
752 | 60 |
|
771 | 61 |
"Created: / 10-05-2011 / 14:56:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
1711 | 62 |
"Modified (format): / 28-09-2012 / 23:01:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
758 | 63 |
! ! |
64 |
||
65 |
!JavaClassRef2 methodsFor:'accessing'! |
|
66 |
||
761 | 67 |
classLoader |
777 | 68 |
self owner ifNil: [ ^ nil ] ifNotNil: [ ^ self owner classLoader ]. |
761 | 69 |
|
70 |
"Created: / 11-04-2011 / 21:52:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
777 | 71 |
"Modified: / 12-05-2011 / 18:32:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
761 | 72 |
! |
73 |
||
1073
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1062
diff
changeset
|
74 |
displayString |
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1062
diff
changeset
|
75 |
^self name. |
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1062
diff
changeset
|
76 |
|
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1062
diff
changeset
|
77 |
"Created: / 01-11-2011 / 15:29:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1062
diff
changeset
|
78 |
! |
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1062
diff
changeset
|
79 |
|
1062
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
80 |
fullName |
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
81 |
|
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
82 |
^self javaClassName |
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
83 |
|
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
84 |
"Created: / 08-04-2011 / 13:48:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
85 |
"Modified: / 13-05-2011 / 09:59:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
86 |
"Created: / 30-10-2011 / 22:00:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
87 |
! |
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
88 |
|
809 | 89 |
javaClass |
90 |
||
1038 | 91 |
valueCache isNil ifTrue:[self resolve]. |
809 | 92 |
^valueCache |
93 |
||
94 |
"Created: / 22-05-2011 / 14:02:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
95 |
! |
|
96 |
||
758 | 97 |
javaClassName |
761 | 98 |
"return java class name as written in java programs e.g. java.util.String |
99 |
in case of array, return class name without square brackets" |
|
100 |
||
101 |
| tmp | |
|
102 |
||
814
68df82c46fb0
finally forced myself to refactor tests.. fieldRef tests are ok now.. methodRef to come..
hlopkmar
parents:
809
diff
changeset
|
103 |
tmp := self name copy. |
68df82c46fb0
finally forced myself to refactor tests.. fieldRef tests are ok now.. methodRef to come..
hlopkmar
parents:
809
diff
changeset
|
104 |
[ tmp startsWith: '[' ] whileTrue: [ tmp := tmp copyFrom: 2 ]. |
786 | 105 |
tmp := tmp replaceAll: $/ with: $.. |
785
7811d2e77ca6
aaaargh forgot to delete old code after fixing it.. and wondering why it's not working :)
hlopkmar
parents:
783
diff
changeset
|
106 |
(tmp startsWith: 'L') ifTrue: [ tmp := tmp copyFrom: 2 to: tmp size ]. |
7811d2e77ca6
aaaargh forgot to delete old code after fixing it.. and wondering why it's not working :)
hlopkmar
parents:
783
diff
changeset
|
107 |
(tmp endsWith: ';') ifTrue: [ tmp := tmp copyFrom: 1 to: tmp size - 1 ]. |
7811d2e77ca6
aaaargh forgot to delete old code after fixing it.. and wondering why it's not working :)
hlopkmar
parents:
783
diff
changeset
|
108 |
^ tmp. |
758 | 109 |
|
110 |
"Created: / 08-04-2011 / 18:30:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
814
68df82c46fb0
finally forced myself to refactor tests.. fieldRef tests are ok now.. methodRef to come..
hlopkmar
parents:
809
diff
changeset
|
111 |
"Modified: / 23-05-2011 / 15:30:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
758 | 112 |
! |
113 |
||
114 |
name |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
115 |
^constantPool at: nameIndex. |
758 | 116 |
|
117 |
"Created: / 08-04-2011 / 13:48:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
118 |
"Modified: / 13-05-2011 / 09:59:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
758 | 119 |
! ! |
120 |
||
121 |
!JavaClassRef2 methodsFor:'array support'! |
|
122 |
||
123 |
arrayDimensions |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
124 |
^ self name occurrencesOf: $[. |
758 | 125 |
|
126 |
"Created: / 08-04-2011 / 18:42:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
127 |
"Modified: / 13-05-2011 / 10:00:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
758 | 128 |
! |
129 |
||
130 |
isJavaArrayClassRef |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
131 |
^ self name startsWith: '['. |
758 | 132 |
|
133 |
"Created: / 08-04-2011 / 18:40:40 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
134 |
"Modified: / 13-05-2011 / 10:00:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 135 |
! ! |
136 |
||
137 |
!JavaClassRef2 methodsFor:'comparing'! |
|
138 |
||
758 | 139 |
= anotherJavaClassRef |
752 | 140 |
"superclass JavaRef2 says that I am responsible to implement this method" |
758 | 141 |
|
142 |
anotherJavaClassRef isJavaClassRef ifFalse: [ ^ false ]. |
|
143 |
^ self name = anotherJavaClassRef name. |
|
752 | 144 |
|
758 | 145 |
"Modified: / 08-04-2011 / 13:48:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 146 |
! |
147 |
||
148 |
hash |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
149 |
^ self name hash. |
752 | 150 |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
151 |
"Modified: / 13-05-2011 / 10:00:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 152 |
! ! |
153 |
||
154 |
!JavaClassRef2 methodsFor:'initialization'! |
|
155 |
||
771 | 156 |
initializeIn: aJavaConstantPool withNameAt: nameCPIndex |
157 |
nameIndex := nameCPIndex. |
|
158 |
constantPool := aJavaConstantPool. |
|
752 | 159 |
super initialize. |
160 |
||
771 | 161 |
"Modified: / 10-05-2011 / 14:57:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
162 |
! ! |
|
163 |
||
1062
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
164 |
!JavaClassRef2 methodsFor:'printing & storing'! |
915 | 165 |
|
1062
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
166 |
printOn:aStream |
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
167 |
"append a printed representation if the receiver to the argument, aStream" |
915 | 168 |
|
1062
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
169 |
super printOn:aStream. |
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
170 |
aStream nextPut:$(. |
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
171 |
self name printOn: aStream. |
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
172 |
aStream nextPut:$). |
771 | 173 |
|
1062
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1038
diff
changeset
|
174 |
"Modified: / 30-10-2011 / 21:59:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 175 |
! ! |
176 |
||
177 |
!JavaClassRef2 methodsFor:'private - resolving'! |
|
178 |
||
761 | 179 |
findResolvedStaticValue |
180 |
"Resolving static inner classes is not different from resolving any other class, it's only done in different circumstances" |
|
181 |
||
182 |
^ self findResolvedValue. |
|
183 |
||
184 |
"Created: / 28-04-2011 / 21:57:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
185 |
! |
|
186 |
||
752 | 187 |
findResolvedValue |
758 | 188 |
"Resolve reference and set valueCache." |
189 |
||
1035 | 190 |
self findResolvedValue: true |
758 | 191 |
|
192 |
"Modified: / 08-04-2011 / 17:39:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1035 | 193 |
"Modified: / 21-10-2011 / 10:58:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
912
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
194 |
! |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
195 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
196 |
findResolvedValue: doInit |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
197 |
"Resolve reference and set valueCache." |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
198 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
199 |
valueCache := JavaResolver uniqueInstance |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
200 |
resolveClassIndentifiedByRef: self init: doInit. |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
201 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
202 |
"Modified: / 08-04-2011 / 17:39:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
203 |
"Created: / 12-08-2011 / 22:19:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
758 | 204 |
! ! |
752 | 205 |
|
761 | 206 |
!JavaClassRef2 methodsFor:'queries'! |
207 |
||
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
915
diff
changeset
|
208 |
isJavaClassOrStringRef |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
915
diff
changeset
|
209 |
^ true. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
915
diff
changeset
|
210 |
|
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
915
diff
changeset
|
211 |
"Created: / 11-04-2011 / 19:10:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
915
diff
changeset
|
212 |
! |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
915
diff
changeset
|
213 |
|
761 | 214 |
isJavaClassRef |
215 |
^true. |
|
216 |
||
217 |
"Created: / 11-04-2011 / 19:10:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
218 |
! ! |
|
219 |
||
758 | 220 |
!JavaClassRef2 methodsFor:'resolving'! |
221 |
||
222 |
invalidateForClass: internalJavaClassName |
|
1372
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1155
diff
changeset
|
223 |
"Invalidates receiver iff it refers (even indirectly) |
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1155
diff
changeset
|
224 |
to a class ref that has been resolved to given class. |
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1155
diff
changeset
|
225 |
Returns true, if the receiver has been invalidated, |
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1155
diff
changeset
|
226 |
false otherwise" |
814
68df82c46fb0
finally forced myself to refactor tests.. fieldRef tests are ok now.. methodRef to come..
hlopkmar
parents:
809
diff
changeset
|
227 |
|
1372
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1155
diff
changeset
|
228 |
self name = internalJavaClassName ifTrue: [ |
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1155
diff
changeset
|
229 |
self invalidate. |
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1155
diff
changeset
|
230 |
^ true |
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1155
diff
changeset
|
231 |
]. |
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
232 |
^ false. |
758 | 233 |
|
814
68df82c46fb0
finally forced myself to refactor tests.. fieldRef tests are ok now.. methodRef to come..
hlopkmar
parents:
809
diff
changeset
|
234 |
"Modified: / 23-05-2011 / 15:21:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
1372
dea574a1b6b3
Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
1155
diff
changeset
|
235 |
"Modified (format): / 21-02-2012 / 10:21:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
912
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
236 |
! |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
237 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
238 |
resolve |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
239 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
240 |
^self resolve: true |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
241 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
242 |
"Created: / 08-04-2011 / 11:30:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
243 |
"Created: / 12-08-2011 / 22:18:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 244 |
! ! |
245 |
||
246 |
!JavaClassRef2 class methodsFor:'documentation'! |
|
247 |
||
248 |
version_SVN |
|
249 |
^ '$Id$' |
|
250 |
! ! |