JavaRuntimeConstantPoolTests.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 31 Jan 2013 12:22:15 +0000
branchdevelopment
changeset 2015 fbbdc7baf6f9
parent 1953 1e42ad3fc322
child 2069 75d40b7b986f
permissions -rw-r--r--
Added Native1 benchmark. A simple benchmark to measure performance of native method invocation.
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
1829
991172ecd928 refreshing tests
hlopkmar
parents: 1818
diff changeset
    94
_testInvalidateAll
991172ecd928 refreshing tests
hlopkmar
parents: 1818
diff changeset
    95
    | cp |
991172ecd928 refreshing tests
hlopkmar
parents: 1818
diff changeset
    96
    cp := self getPrettyBigConstantPool.
991172ecd928 refreshing tests
hlopkmar
parents: 1818
diff changeset
    97
    cp do: [:each | each isJavaRef ifTrue: [ each resolve ] ].
991172ecd928 refreshing tests
hlopkmar
parents: 1818
diff changeset
    98
    cp do: [:each | each isJavaRef ifTrue: [ self assertTrue: (each isResolved) ] ].
991172ecd928 refreshing tests
hlopkmar
parents: 1818
diff changeset
    99
    cp invalidateAll.
991172ecd928 refreshing tests
hlopkmar
parents: 1818
diff changeset
   100
    cp do: [:each | each isJavaRef ifTrue: [ self assertTrue: (each isResolved not) ] ].
991172ecd928 refreshing tests
hlopkmar
parents: 1818
diff changeset
   101
991172ecd928 refreshing tests
hlopkmar
parents: 1818
diff changeset
   102
    "Created: / 17-11-2012 / 21:44:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
991172ecd928 refreshing tests
hlopkmar
parents: 1818
diff changeset
   103
!
991172ecd928 refreshing tests
hlopkmar
parents: 1818
diff changeset
   104
1469
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   105
_testInvalidateForClass
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   106
"will be enabled when caching and invalidation is implemented"
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   107
    | cp |
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   108
    self cleanUpCPCache.
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   109
    cp := self getPrettyBigConstantPool.
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   110
    cp do: [:each | each isJavaRef ifTrue: [ each resolve ] ].
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   111
    cp do: [:each | each isJavaRef ifTrue: [ self assertTrue: (each isResolved) ] ].
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   112
    JavaConstantPool invalidateReferencesToClass: 'Ljava/lang/Runnable;'.
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   113
    1 to: 13 do: [
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   114
        :index | 
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   115
        (cp at: index) isJavaRef ifTrue: [ self assertTrue: (cp at: index) isResolved ]
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   116
    ].
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   117
    14 to: 20 do: [
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   118
        :index | 
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   119
        (cp at: index) isJavaRef ifTrue: [
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   120
            self assertTrue: (cp at: index) isResolved not
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   121
        ]
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   122
    ].
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   123
7ff01bef4a36 started tests cleanup
hlopkmar
parents: 1155
diff changeset
   124
    "Created: / 12-04-2012 / 10:16:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   125
! !
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   126
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   127
!JavaRuntimeConstantPoolTests class methodsFor:'documentation'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   128
1953
1e42ad3fc322 Added support Java>>addToClassPath: & Java>>addToSourcePath:. Removed JavaPathElement.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1835
diff changeset
   129
version_HG
1e42ad3fc322 Added support Java>>addToClassPath: & Java>>addToSourcePath:. Removed JavaPathElement.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1835
diff changeset
   130
1e42ad3fc322 Added support Java>>addToClassPath: & Java>>addToSourcePath:. Removed JavaPathElement.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1835
diff changeset
   131
    ^ '$Changeset: <not expanded> $'
1e42ad3fc322 Added support Java>>addToClassPath: & Java>>addToSourcePath:. Removed JavaPathElement.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1835
diff changeset
   132
!
1e42ad3fc322 Added support Java>>addToClassPath: & Java>>addToSourcePath:. Removed JavaPathElement.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1835
diff changeset
   133
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   134
version_SVN
1953
1e42ad3fc322 Added support Java>>addToClassPath: & Java>>addToSourcePath:. Removed JavaPathElement.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1835
diff changeset
   135
    ^ '§Id§'
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   136
! !