1
|
1 |
JavaUnresolvedConstant subclass:#JavaUnresolvedClassConstant
|
90
|
2 |
instanceVariableNames:'nameIndex fullName'
|
1
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'Java-Reader-Support'
|
|
6 |
!
|
|
7 |
|
|
8 |
|
67
|
9 |
!JavaUnresolvedClassConstant class methodsFor:'instance creation'!
|
1
|
10 |
|
54
|
11 |
fullName:nm
|
90
|
12 |
|ref|
|
|
13 |
|
|
14 |
ref := Java unresolvedClassRefFor:nm.
|
|
15 |
ref notNil ifTrue:[^ ref].
|
|
16 |
|
|
17 |
ref := self new fullName:nm.
|
|
18 |
Java rememberUnresolved:ref.
|
|
19 |
^ ref
|
54
|
20 |
!
|
|
21 |
|
90
|
22 |
pool:aPool poolIndex:slotIndex nameIndex:index
|
|
23 |
^ self new pool:aPool poolIndex:slotIndex nameIndex:index
|
21
|
24 |
! !
|
|
25 |
|
|
26 |
!JavaUnresolvedClassConstant methodsFor:'accessing'!
|
|
27 |
|
67
|
28 |
className
|
|
29 |
|s nm|
|
|
30 |
|
|
31 |
(fullName startsWith:$[) ifTrue:[
|
|
32 |
"/ a ref for newarray or new or checkCast
|
|
33 |
|
|
34 |
s := fullName readStream.
|
|
35 |
s next.
|
|
36 |
nm := JavaMethod retvalSpecFromStream:s.
|
|
37 |
^ nm
|
|
38 |
].
|
|
39 |
^ fullName
|
|
40 |
|
|
41 |
!
|
|
42 |
|
21
|
43 |
fullName
|
|
44 |
^ fullName
|
|
45 |
|
93
|
46 |
!
|
90
|
47 |
|
|
48 |
javaClass
|
|
49 |
|cls|
|
|
50 |
|
|
51 |
fullName isNil ifTrue:[
|
|
52 |
self halt.
|
|
53 |
].
|
|
54 |
cls := Java at:fullName.
|
|
55 |
cls notNil ifTrue:[^ cls].
|
|
56 |
|
|
57 |
(' *** late loading: ' , fullName) infoPrintCR.
|
|
58 |
^ JavaClassReader loadClass:fullName.
|
|
59 |
|
54
|
60 |
!
|
|
61 |
|
90
|
62 |
pool:aPool poolIndex:slotIndex nameIndex:name_index
|
|
63 |
constantPool := aPool.
|
|
64 |
constantPoolIndex := slotIndex.
|
|
65 |
nameIndex := name_index.
|
21
|
66 |
|
1
|
67 |
! !
|
|
68 |
|
41
|
69 |
!JavaUnresolvedClassConstant methodsFor:'printing & storing'!
|
|
70 |
|
|
71 |
displayString
|
52
|
72 |
fullName isNil ifTrue:[
|
83
|
73 |
^ 'UnresolvedClass(** nil **)'
|
52
|
74 |
].
|
83
|
75 |
^ 'UnresolvedClass(' , (fullName copy replaceAll:$/ by:$.) , ')'
|
41
|
76 |
! !
|
|
77 |
|
1
|
78 |
!JavaUnresolvedClassConstant methodsFor:'resolving'!
|
|
79 |
|
90
|
80 |
preResolve
|
|
81 |
|clsName cls nm s ref|
|
|
82 |
|
|
83 |
fullName isNil ifTrue:[
|
|
84 |
"/ first, resolve my name ...
|
|
85 |
|
|
86 |
clsName := constantPool at:nameIndex.
|
|
87 |
"/ DEBUGGING
|
|
88 |
clsName isString ifFalse:[
|
|
89 |
self halt:'oops - no class name string in const pool'.
|
|
90 |
].
|
|
91 |
|
|
92 |
fullName := clsName
|
|
93 |
].
|
|
94 |
|
|
95 |
"/ try to resolve the class
|
|
96 |
|
|
97 |
"/ 'resolve: ' print. fullName printCR.
|
50
|
98 |
|
|
99 |
cls := Java classNamed:fullName.
|
52
|
100 |
cls notNil ifTrue:[
|
90
|
101 |
"/ good - the class is already loaded.
|
|
102 |
|
|
103 |
constantPool at:constantPoolIndex put:cls.
|
|
104 |
^ cls
|
|
105 |
].
|
|
106 |
|
|
107 |
(fullName startsWith:$[) ifTrue:[
|
|
108 |
"/ a ref for newarray or new
|
|
109 |
|
|
110 |
nm := JavaMethod retvalSpecFromStream:(ReadStream on:fullName).
|
|
111 |
[nm endsWith:'[]'] whileTrue:[
|
|
112 |
nm := nm copyWithoutLast:2
|
|
113 |
].
|
|
114 |
|
|
115 |
cls := Java classNamed:nm.
|
|
116 |
cls notNil ifTrue:[
|
|
117 |
ref := JavaClassPointerRef class:cls nameandType:fullName.
|
|
118 |
constantPool at:constantPoolIndex put:ref.
|
|
119 |
^ ref
|
52
|
120 |
].
|
107
|
121 |
|
|
122 |
"/ look for specials like byte[], int[] etc.
|
|
123 |
"/ there are only a few of them - forgive me nameing them here ...
|
|
124 |
fullName = '[B' ifTrue:[ "/ byte[]
|
|
125 |
ref := JavaBuiltInClassPointerRef class:ByteArray nameandType:fullName.
|
|
126 |
constantPool at:constantPoolIndex put:ref.
|
|
127 |
^ ref
|
|
128 |
].
|
|
129 |
fullName = '[I' ifTrue:[ "/ int[]
|
|
130 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
131 |
constantPool at:constantPoolIndex put:ref.
|
|
132 |
^ ref
|
|
133 |
].
|
|
134 |
fullName = '[D' ifTrue:[ "/ double[]
|
|
135 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
136 |
constantPool at:constantPoolIndex put:ref.
|
|
137 |
^ ref
|
|
138 |
].
|
|
139 |
fullName = '[[D' ifTrue:[ "/ double[][]
|
|
140 |
ref := JavaBuiltInClassPointerRef class:DoubleArray nameandType:fullName.
|
|
141 |
constantPool at:constantPoolIndex put:ref.
|
|
142 |
^ ref
|
|
143 |
].
|
|
144 |
fullName = '[[I' ifTrue:[ "/ int[][]
|
|
145 |
ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
|
|
146 |
constantPool at:constantPoolIndex put:ref.
|
|
147 |
^ ref
|
|
148 |
].
|
|
149 |
(fullName startsWith:'[L') ifFalse:[
|
|
150 |
('JAVA: oops - unresolvable funny class: ' , fullName) errorPrintCR.
|
|
151 |
]
|
52
|
152 |
] ifFalse:[
|
90
|
153 |
nm := self className.
|
50
|
154 |
].
|
90
|
155 |
|
|
156 |
self rememberForResolveWith:nm.
|
|
157 |
^ self
|
|
158 |
|
|
159 |
"Created: 15.4.1996 / 15:51:42 / cg"
|
|
160 |
"Modified: 15.4.1996 / 16:26:05 / cg"
|
|
161 |
! !
|
|
162 |
|
67
|
163 |
!JavaUnresolvedClassConstant class methodsFor:'documentation'!
|
1
|
164 |
|
|
165 |
version
|
107
|
166 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaUnresolvedClassConstant.st,v 1.16 1996/07/02 16:40:03 cg Exp $'
|
1
|
167 |
! !
|