752
|
1 |
"{ Package: 'stx:libjava' }"
|
|
2 |
|
773
|
3 |
AbstractJavaTestCase subclass:#JavaRuntimeConstantPoolTests
|
|
4 |
instanceVariableNames:''
|
752
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Languages-Java-Tests-RuntimeConstantPool'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
771
|
11 |
!JavaRuntimeConstantPoolTests methodsFor:'tests'!
|
|
12 |
|
|
13 |
testInvalidateAll
|
|
14 |
| newConstantPool tmpConstantPoolCache |
|
|
15 |
|
|
16 |
tmpConstantPoolCache := JavaConstantPool allConstantPools.
|
|
17 |
JavaConstantPool allConstantPools: OrderedCollection new.
|
|
18 |
newConstantPool := JavaConstantPool new: 8.
|
|
19 |
newConstantPool at: 1 put: 6.
|
|
20 |
newConstantPool at: 2 put: 'hello'.
|
|
21 |
newConstantPool at: 3 put: (self getClassRefFor: 'Ljava/lang/Object;').
|
|
22 |
newConstantPool at: 4
|
|
23 |
put: (JavaMethodRef2 in: nil
|
|
24 |
namedAndTyped: (self getName: '<init>' descriptor: '()V')
|
|
25 |
inClassIdentifiedByRef: (newConstantPool at: 3)).
|
|
26 |
newConstantPool at: 5 put: (self getClassRefFor:'Ljava/lang/String;').
|
|
27 |
newConstantPool at: 6
|
|
28 |
put: (JavaFieldRef2 in: nil
|
|
29 |
namedAndTyped: (self getName: 'value' descriptor: '[C')
|
|
30 |
inClassIdentifiedByRef: (newConstantPool at: 5)).
|
|
31 |
newConstantPool at: 7 put: (self getClassRefFor: 'Ljava/lang/Runnable;').
|
|
32 |
newConstantPool at: 8
|
|
33 |
put: (JavaInterfaceMethodRef2 in: nil
|
|
34 |
namedAndTyped: (self getName: 'run' descriptor: '()V')
|
|
35 |
inClassIdentifiedByRef: (newConstantPool at: 7)).
|
|
36 |
JavaConstantPool allConstantPools do:
|
|
37 |
[:each |
|
|
38 |
self
|
|
39 |
assertTrue: (JavaConstantPool allConstantPools includes: newConstantPool) ].
|
|
40 |
JavaConstantPool allConstantPools: tmpConstantPoolCache.
|
|
41 |
|
|
42 |
"Created: / 08-04-2011 / 17:03:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
43 |
"Modified: / 10-05-2011 / 16:58:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
44 |
!
|
|
45 |
|
|
46 |
testInvalidateForClass
|
|
47 |
| newConstantPool tmpConstantPoolCache |
|
|
48 |
|
|
49 |
"/backup cps
|
|
50 |
tmpConstantPoolCache := JavaConstantPool allConstantPools.
|
|
51 |
JavaConstantPool allConstantPools: OrderedCollection new.
|
|
52 |
newConstantPool := JavaConstantPool new: 8.
|
|
53 |
newConstantPool at: 1 put: 6.
|
|
54 |
newConstantPool at: 2 put: 'hello'.
|
|
55 |
newConstantPool at: 3
|
|
56 |
put: (self getClassRefFor:
|
|
57 |
'Lstx/libjava/tests/mocks/ImplementorOfPublicInterface;').
|
|
58 |
newConstantPool at: 4
|
|
59 |
put: (JavaMethodRef2 in: nil namedAndTyped: (self getName: 'publicMethod'
|
|
60 |
descriptor: '()Ljava/lang/String;')
|
|
61 |
inClassIdentifiedByRef: (newConstantPool at: 3)).
|
|
62 |
newConstantPool at: 5
|
|
63 |
put: (self getClassRefFor: 'Lstx/libjava/tests/mocks/PublicClass;').
|
|
64 |
newConstantPool at: 6
|
|
65 |
put: (JavaFieldRef2 in: nil namedAndTyped: (self getName:'publicField'
|
|
66 |
descriptor: 'Ljava/lang/String;')
|
|
67 |
inClassIdentifiedByRef: (newConstantPool at: 5)).
|
|
68 |
newConstantPool at: 7 put: (self getClassRefFor: 'Ljava/lang/Runnable;').
|
|
69 |
newConstantPool at: 8
|
|
70 |
put: (JavaInterfaceMethodRef2 in: nil
|
|
71 |
namedAndTyped: (self getName: 'run' descriptor: '()V')
|
|
72 |
inClassIdentifiedByRef: (newConstantPool at: 7)).
|
|
73 |
|
|
74 |
"/end of initialization part
|
|
75 |
|
|
76 |
newConstantPool do: [:each | each isJavaRef ifTrue: [ each resolve ] ].
|
|
77 |
|
|
78 |
"/end of resolving part
|
|
79 |
|
|
80 |
JavaConstantPool
|
|
81 |
invalidateReferencesToClass: 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
82 |
self assertTrue: (newConstantPool at: 3) isResolved.
|
|
83 |
self assertTrue: (newConstantPool at: 7) isResolved.
|
|
84 |
self assertTrue: (newConstantPool at: 5) isResolved not.
|
|
85 |
|
|
86 |
"/and put pack what was there before
|
|
87 |
|
|
88 |
JavaConstantPool allConstantPools: tmpConstantPoolCache.
|
|
89 |
|
|
90 |
"Created: / 08-04-2011 / 17:10:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
91 |
"Modified: / 10-05-2011 / 16:57:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
92 |
!
|
|
93 |
|
|
94 |
testNewCreatedCPIsInCache
|
|
95 |
|newConstantPool|
|
|
96 |
newConstantPool := JavaConstantPool new: 500.
|
|
97 |
self assertTrue: (JavaConstantPool allConstantPools includes: newConstantPool).
|
|
98 |
JavaConstantPool allConstantPools remove: newConstantPool.
|
|
99 |
|
|
100 |
"Created: / 08-04-2011 / 16:57:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
101 |
! !
|
|
102 |
|
752
|
103 |
!JavaRuntimeConstantPoolTests class methodsFor:'documentation'!
|
|
104 |
|
|
105 |
version_SVN
|
|
106 |
^ '$Id$'
|
|
107 |
! !
|