1
|
1 |
ClassDescription subclass:#JavaClass
|
7
|
2 |
instanceVariableNames:'fullName accessFlags constantPool sourceFile'
|
1
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'Java-Classes'
|
|
6 |
!
|
|
7 |
|
|
8 |
|
|
9 |
!JavaClass class methodsFor:'instance creation'!
|
|
10 |
|
7
|
11 |
fullName:aString
|
|
12 |
^ self new setFullName:aString
|
|
13 |
|
|
14 |
"Created: 15.4.1996 / 15:52:55 / cg"
|
|
15 |
!
|
|
16 |
|
1
|
17 |
name:aString
|
7
|
18 |
self shouldNotImplement
|
1
|
19 |
|
|
20 |
"Created: 15.4.1996 / 15:52:55 / cg"
|
|
21 |
! !
|
|
22 |
|
5
|
23 |
!JavaClass methodsFor:'accessing'!
|
|
24 |
|
7
|
25 |
category
|
|
26 |
"java classes do not really hav a category;
|
|
27 |
simulate one by separating its name into individual components,
|
|
28 |
prepending 'java'"
|
|
29 |
|
|
30 |
|nameComponents|
|
|
31 |
|
|
32 |
nameComponents := fullName asCollectionOfSubstringsSeparatedBy:$/.
|
|
33 |
^ 'java-' , (nameComponents asStringWith:$/ from:1 to:(nameComponents size - 1))
|
|
34 |
!
|
|
35 |
|
5
|
36 |
constantPool
|
|
37 |
^ constantPool
|
7
|
38 |
!
|
|
39 |
|
|
40 |
fullName
|
|
41 |
^ fullName
|
8
|
42 |
!
|
|
43 |
|
|
44 |
name
|
|
45 |
^ fullName
|
5
|
46 |
! !
|
|
47 |
|
1
|
48 |
!JavaClass methodsFor:'printing & storing'!
|
|
49 |
|
|
50 |
displayString
|
|
51 |
^ self class name , '(' , name , ')'
|
|
52 |
|
|
53 |
"Created: 15.4.1996 / 16:02:48 / cg"
|
|
54 |
! !
|
|
55 |
|
|
56 |
!JavaClass methodsFor:'private accessing'!
|
|
57 |
|
5
|
58 |
addMethod:m name:name signature:signature
|
|
59 |
selectorArray isNil ifTrue:[
|
|
60 |
selectorArray := #().
|
|
61 |
methodArray := #()
|
|
62 |
].
|
|
63 |
selectorArray := selectorArray copyWith:name.
|
|
64 |
methodArray := methodArray copyWith:m
|
|
65 |
|
|
66 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
|
67 |
!
|
|
68 |
|
1
|
69 |
setAccessFlags:flags
|
3
|
70 |
accessFlags := flags.
|
1
|
71 |
|
|
72 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
5
|
73 |
!
|
|
74 |
|
|
75 |
setConstantPool:anArray
|
|
76 |
constantPool := anArray.
|
|
77 |
|
|
78 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
|
79 |
!
|
|
80 |
|
7
|
81 |
setFullName:aString
|
|
82 |
|nameComponents|
|
|
83 |
|
|
84 |
fullName := aString.
|
|
85 |
nameComponents := aString asCollectionOfSubstringsSeparatedBy:$/.
|
|
86 |
name := nameComponents last
|
|
87 |
|
|
88 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
|
89 |
!
|
|
90 |
|
5
|
91 |
setSourceFile:aFilename
|
|
92 |
sourceFile := aFilename.
|
|
93 |
|
|
94 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
1
|
95 |
! !
|
|
96 |
|
18
|
97 |
!JavaClass methodsFor:'queries'!
|
|
98 |
|
|
99 |
isFinal
|
|
100 |
^ (accessFlags bitAnd:16r0010) ~~ 0
|
|
101 |
!
|
|
102 |
|
|
103 |
isInterface
|
|
104 |
^ (accessFlags bitAnd:16r0200) ~~ 0
|
|
105 |
!
|
|
106 |
|
|
107 |
isPublic
|
|
108 |
^ (accessFlags bitAnd:16r0001) ~~ 0
|
|
109 |
|
|
110 |
|
|
111 |
! !
|
|
112 |
|
21
|
113 |
!JavaClass methodsFor:'resolving class refs'!
|
|
114 |
|
|
115 |
resolveClassRefs
|
|
116 |
|newClass const newConst|
|
|
117 |
|
|
118 |
(superclass isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
|
|
119 |
newClass := superclass resolve.
|
|
120 |
newClass isNil ifTrue:[
|
|
121 |
newClass := JavaClassReader loadClass:(superclass fullName).
|
|
122 |
].
|
|
123 |
newClass notNil ifTrue:[
|
|
124 |
superclass := newClass
|
|
125 |
]
|
|
126 |
].
|
|
127 |
|
|
128 |
1 to:constantPool size do:[:index |
|
|
129 |
const := constantPool at:index.
|
|
130 |
(const isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
|
|
131 |
"/ try to resolve
|
|
132 |
newConst := const resolve.
|
|
133 |
newConst isNil ifTrue:[
|
|
134 |
newConst := JavaClassReader loadClass:(const fullName).
|
|
135 |
].
|
|
136 |
newConst notNil ifTrue:[
|
|
137 |
constantPool at:index put:newConst
|
|
138 |
]
|
|
139 |
]
|
|
140 |
].
|
|
141 |
! !
|
|
142 |
|
1
|
143 |
!JavaClass class methodsFor:'documentation'!
|
|
144 |
|
|
145 |
version
|
21
|
146 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClass.st,v 1.7 1996/04/17 22:50:15 cg Exp $'
|
1
|
147 |
! !
|