src/JavaRuntimeConstantPoolTests.st
author vranyj1
Fri, 06 Jul 2012 20:58:09 +0000
branchjk_new_structure
changeset 1515 f4ebf5cf3f89
parent 1469 7ff01bef4a36
permissions -rw-r--r--
- JavaClassReaderTests class definition - JavaInterfaceMethodRefTests class definition - JavaClassRefTests class definition - JavaFieldRefTests class definition - JavaRuntimeConstantPoolTests class definition - JavaMethodRefTests class definition - JavaRefsAndConstantPoolTestCase class definition added: #isAbstract - JavaExceptionTests changed:7 methods - stx_libjava changed: #classNamesAndAttributes #extensionMethodNames #preRequisites - JavaByteCodeDisassemblerTests comment/format in: #testMultiBytePrintString - JavaMonitorsTests class definition changed: #test_releasing_01 #test_releasing_02 - extensions ...
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     1
"
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
     3
1155
vranyj1
parents: 1152
diff changeset
     4
 New code and modifications done at SWING Research Group [1]:
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
     5
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     6
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     7
                            SWING Research Group, Czech Technical University in Prague
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     8
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     9
 This software is furnished under a license and may be used
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    10
 only in accordance with the terms of that license and with the
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    11
 inclusion of the above copyright notice.   This software may not
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    12
 be provided or otherwise made available to, or used by, any
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    13
 other person.  No title to or ownership of the software is
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    14
 hereby transferred.
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    15
1155
vranyj1
parents: 1152
diff changeset
    16
 [1] Code written at SWING Research Group contains a signature
vranyj1
parents: 1152
diff changeset
    17
     of one of the above copright owners. For exact set of such code,
vranyj1
parents: 1152
diff changeset
    18
     see the differences between this version and version stx:libjava
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
    19
     as of 1.9.2010
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    20
"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    21
"{ Package: 'stx:libjava' }"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    22
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1469
diff changeset
    23
JavaRefsAndConstantPoolTestCase subclass:#JavaRuntimeConstantPoolTests
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    24
	instanceVariableNames:'constantPoolCacheBackup'
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    25
	classVariableNames:''
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    26
	poolDictionaries:''
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    27
	category:'Languages-Java-Tests-RuntimeConstantPool'
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    28
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    29
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    30
!JavaRuntimeConstantPoolTests class methodsFor:'documentation'!
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    31
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    32
copyright
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    33
"
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    34
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
    35
1155
vranyj1
parents: 1152
diff changeset
    36
 New code and modifications done at SWING Research Group [1]:
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
    37
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    38
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    39
                            SWING Research Group, Czech Technical University in Prague
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    40
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    41
 This software is furnished under a license and may be used
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    42
 only in accordance with the terms of that license and with the
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    43
 inclusion of the above copyright notice.   This software may not
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    44
 be provided or otherwise made available to, or used by, any
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    45
 other person.  No title to or ownership of the software is
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    46
 hereby transferred.
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    47
1155
vranyj1
parents: 1152
diff changeset
    48
 [1] Code written at SWING Research Group contains a signature
vranyj1
parents: 1152
diff changeset
    49
     of one of the above copright owners. For exact set of such code,
vranyj1
parents: 1152
diff changeset
    50
     see the differences between this version and version stx:libjava
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
    51
     as of 1.9.2010
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    52
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    53
"
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    54
! !
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    55
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    56
!JavaRuntimeConstantPoolTests methodsFor:'helpers'!
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    57
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    58
cleanUpCPCache
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    59
    "warning - counting with the fact that cp cache is backed up in setUp and restored in tearDown methods"
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    60
    JavaConstantPool allConstantPools: OrderedCollection new.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    61
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    62
    "Created: / 13-05-2011 / 09:42:04 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    63
! !
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    64
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    65
!JavaRuntimeConstantPoolTests methodsFor:'running'!
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    66
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    67
setUp
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    68
    super setUp.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    69
    constantPoolCacheBackup := JavaConstantPool allConstantPools.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    70
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    71
    "Created: / 13-05-2011 / 09:33:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    72
!
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    73
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    74
tearDown
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    75
super tearDown.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    76
    JavaConstantPool allConstantPools: constantPoolCacheBackup.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    77
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    78
    "Created: / 13-05-2011 / 09:33:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    79
! !
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    80
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
    81
!JavaRuntimeConstantPoolTests methodsFor:'tests'!
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
    82
1469
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
    83
_testConstantPoolCaching
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
    84
"will be enabled when caching and invalidation is implemented"
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    85
    | newConstantPool |
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    86
    JavaConstantPool allConstantPools: OrderedCollection new.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    87
    newConstantPool := self getPrettyBigConstantPool.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    88
    self 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    89
        assertTrue: (JavaConstantPool allConstantPools includes: newConstantPool).
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    90
1469
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
    91
    "Created: / 12-04-2012 / 10:16:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
    92
!
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
    93
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
    94
_testInvalidateForClass
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
    95
"will be enabled when caching and invalidation is implemented"
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
    96
    | cp |
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
    97
    self cleanUpCPCache.
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
    98
    cp := self getPrettyBigConstantPool.
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
    99
    cp do: [:each | each isJavaRef ifTrue: [ each resolve ] ].
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   100
    cp do: [:each | each isJavaRef ifTrue: [ self assertTrue: (each isResolved) ] ].
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   101
    JavaConstantPool invalidateReferencesToClass: 'Ljava/lang/Runnable;'.
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   102
    1 to: 13 do: [
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   103
        :index | 
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   104
        (cp at: index) isJavaRef ifTrue: [ self assertTrue: (cp at: index) isResolved ]
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   105
    ].
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   106
    14 to: 20 do: [
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   107
        :index | 
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   108
        (cp at: index) isJavaRef ifTrue: [
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   109
            self assertTrue: (cp at: index) isResolved not
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   110
        ]
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   111
    ].
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   112
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   113
    "Created: / 12-04-2012 / 10:16:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   114
!
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   115
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   116
testInvalidateAll
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   117
    | cp |
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   118
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   119
    cp := self getPrettyBigConstantPool.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   120
    cp do: [:each | each isJavaRef ifTrue: [each resolve]].
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   121
    cp 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   122
             do: [:each | each isJavaRef ifTrue: [ self assertTrue: (each isResolved) ] ].
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   123
             cp invalidateAll.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   124
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   125
    cp 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   126
                 do: [:each | each isJavaRef ifTrue: [ self assertTrue: (each isResolved not) ] ].
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   127
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   128
    "Created: / 08-04-2011 / 17:03:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   129
    "Modified: / 13-05-2011 / 09:48:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   130
! !
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   131
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   132
!JavaRuntimeConstantPoolTests class methodsFor:'documentation'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   133
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   134
version_SVN
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   135
    ^ '$Id$'
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   136
! !