Name: dkC103137 Date: 07/10/2000
misc/putback/alltests/TestPep testMisk from testbase_ss fails under
Linux JDK1.3 Hotspot ( both client and server VM) and Solaris JDK1.3 Hotspot ( both client and
server VM). The test passes under Linux JDK1.3 classic VM, Linux JDK1.2.2 classic VM, Solaris
JDK1.2.2 (Hotspot
and classic VM).
The Java Language Specification reads:
3.10.5 String Literals
A string literal consists of zero or more characters enclosed in double quotes. Each character may
be represented by an escape sequence.
....
This example illustrates six points:
Literal strings within the same class (§8) in the same package (§7) represent references to
the same String object (§4.3.1).
Literal strings within different classes in the same package represent references to the same
String object.
Literal strings within different classes in different packages likewise represent references
to the same String object.
Strings computed by constant expressions (§15.27) are computed at compile time and then
treated as if they were literals.
Strings computed at run time are newly created and therefore distinct.
The result of explicitly interning a computed string is the same string as any pre-existing
literal string with the same contents.
....
------------------------------------- end of citation
-------------------------------------------------
Note that "Strings computed at run time are newly created and therefore distinct".
The testMisk creates string literal str1="java.lang.Thread" and then creates second string
java.lang.Class.forName(str1).getName().
The second string can not be created at compile time because it is not String literal nor constant
String expression . Then test compares these two strings using equality operator and expects false
as the result. But in Hotspot these two string are identical.
Please see output below
------------------------------------------ output --------------------------------------------------
[kdos@linux-11 TestPep]$ java -version
java version "1.3.0beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0beta-b09)
Java HotSpot(TM) Client VM (build 1.3.0beta-b07, mixed mode)
[kdos@linux-11 TestPep]$ java PepTest
0.39238507
0.66294914
0.13886654
Hello, coffee world!
Time now is Mon Jul 10 15:36:57 GMT+07:00 2000, ms: 963218217643
Properties:
java.version = 1.3.0beta
java.vendor = Sun Microsystems Inc.
java.vendor.url = http://java.sun.com/
java.home = /.automount/novo48/root/export/home1/jdk1.3/linux/jre
java.class.version = 47.0
java.class.path = .
os.name = Linux
os.version = 2.2.12-20
os.arch = i386
file.separator = /
path.separator = :
line.separator =
user.name = kdos
user.home = /home/kdos
user.dir = /home/kdos/bugs/TestPep
testIf: OK
testArray: OK
testBitOps: OK
testFor: OK
testDiv: OK
testTableSwitch: OK
testLookupSwitch: OK
testHiddenField: OK
checkRemainders: long double OK
checkMathFcts: OK
Primes less than 50: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47
Time for 100,000 iterations of while loop: int: 38 ms, long: 11 ms
testExc1(simple throw/catch): OK
testExc2(skip catch clauses): OK
testExc3(catch in inner): OK
testExc4(catch in outer): OK
testExc5(rethrow): OK
testExc6(throw accross call): OK
testExc7(throw accr. 2 calls): OK
testExc8(keep throwing; see if GC works): OK
testExc9(keep throwing accross fct; see if GC works): OK
loopExitContinueInExceptionHandler: OK
testStringHash: OK
testObjectHash: OK
testClone: OK
testObjectArray: OK
checkInstanceOf: OK
checkInterfaceInstanceOf: OK
testWaitNull: OK
testVarAndMethodNameClash: OK
testDeepStack: OK
testMisk:
******************************************
******************************************
Error(5): strings should not be identical!
******************************************
******************************************
testGC: OK
testFileOps: OK
Timing exception handling: 2 ms
Timing IO. write(1 byte): 10 ms, read(1 byte): 47 ms
Timing java.util.Date::toString: 48 ms
****** PepTest found an error ******
[kdos@linux-11 TestPep]$
-------------------------------------------------------------------------------------------------------------
======================================================================