author | prr |
Mon, 12 May 2014 09:37:50 -0700 | |
changeset 24416 | d07ed422bdca |
parent 22529 | 4db9ba24613d |
child 24835 | be963975e2f7 |
permissions | -rw-r--r-- |
22525
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
1 |
/* |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
4 |
* |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
8 |
* |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
13 |
* accompanied this code). |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
14 |
* |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
18 |
* |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
21 |
* questions. |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
22 |
*/ |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
23 |
|
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
24 |
/* |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
25 |
* @test |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
26 |
* @bug 8028623 |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
27 |
* @summary Test hashing of extended characters in Serviceability Agent. |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
28 |
* @library /testlibrary |
22529
4db9ba24613d
8032466: serviceability/sa/jmap-hashcode/Test8028623.java fails with compilation errors
kevinw
parents:
22525
diff
changeset
|
29 |
* @compile -encoding utf8 Test8028623.java |
4db9ba24613d
8032466: serviceability/sa/jmap-hashcode/Test8028623.java fails with compilation errors
kevinw
parents:
22525
diff
changeset
|
30 |
* @run main Test8028623 |
22525
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
31 |
*/ |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
32 |
|
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
33 |
import com.oracle.java.testlibrary.JDKToolLauncher; |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
34 |
import com.oracle.java.testlibrary.OutputBuffer; |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
35 |
import com.oracle.java.testlibrary.ProcessTools; |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
36 |
|
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
37 |
import java.io.File; |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
38 |
|
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
39 |
public class Test8028623 { |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
40 |
|
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
41 |
public static int à = 1; |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
42 |
public static String dumpFile = "heap.out"; |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
43 |
|
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
44 |
public static void main (String[] args) { |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
45 |
|
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
46 |
System.out.println(Ã); |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
47 |
|
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
48 |
try { |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
49 |
int pid = ProcessTools.getProcessId(); |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
50 |
JDKToolLauncher jmap = JDKToolLauncher.create("jmap") |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
51 |
.addToolArg("-F") |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
52 |
.addToolArg("-dump:live,format=b,file=" + dumpFile) |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
53 |
.addToolArg(Integer.toString(pid)); |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
54 |
ProcessBuilder pb = new ProcessBuilder(jmap.getCommand()); |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
55 |
OutputBuffer output = ProcessTools.getOutput(pb); |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
56 |
Process p = pb.start(); |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
57 |
int e = p.waitFor(); |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
58 |
System.out.println("stdout:"); |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
59 |
System.out.println(output.getStdout()); |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
60 |
System.out.println("stderr:"); |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
61 |
System.out.println(output.getStderr()); |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
62 |
|
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
63 |
if (e != 0) { |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
64 |
throw new RuntimeException("jmap returns: " + e); |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
65 |
} |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
66 |
if (! new File(dumpFile).exists()) { |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
67 |
throw new RuntimeException("dump file NOT created: '" + dumpFile + "'"); |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
68 |
} |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
69 |
} catch (Throwable t) { |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
70 |
t.printStackTrace(); |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
71 |
throw new RuntimeException("Test failed with: " + t); |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
72 |
} |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
73 |
} |
7d87b35a87f2
8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff
changeset
|
74 |
} |