author | csahu |
Fri, 01 Apr 2016 13:51:29 +0530 | |
changeset 37227 | 8c40b5b4e525 |
child 37266 | e7fe9a7bd991 |
permissions | -rw-r--r-- |
37227
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
1 |
/* |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
4 |
* |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
8 |
* |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
13 |
* accompanied this code). |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
14 |
* |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
18 |
* |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
21 |
* questions. |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
22 |
*/ |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
23 |
|
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
24 |
import java.util.Arrays; |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
25 |
import jdk.test.lib.JDKToolLauncher; |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
26 |
import jdk.test.lib.OutputAnalyzer; |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
27 |
import jdk.test.lib.ProcessTools; |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
28 |
|
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
29 |
/* |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
30 |
* @test JstackThreadTest |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
31 |
* @bug 8151442 |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
32 |
* @summary jstack doesn't close quotation marks properly with threads' name greater than 1996 characters |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
33 |
* @library /testlibrary |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
34 |
* @build jdk.test.lib.* |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
35 |
* @run main JstackThreadTest |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
36 |
*/ |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
37 |
public class JstackThreadTest { |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
38 |
static class NamedThread extends Thread { |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
39 |
NamedThread(String name) { |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
40 |
setName(name); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
41 |
} |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
42 |
@Override |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
43 |
public void run() { |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
44 |
try { |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
45 |
Thread.sleep(2000); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
46 |
} catch(Exception e){ |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
47 |
e.printStackTrace(); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
48 |
} |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
49 |
} |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
50 |
} |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
51 |
|
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
52 |
public static void main(String[] args) throws Exception { |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
53 |
StringBuilder sb = new StringBuilder(); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
54 |
/*create a string more than 1996 character */ |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
55 |
for(int i = 0; i < 1998; i++){ |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
56 |
sb.append("a"); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
57 |
} |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
58 |
testWithName(sb.toString()); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
59 |
} |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
60 |
|
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
61 |
private static void testWithName(String name) throws Exception { |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
62 |
// Start a thread with a long thread name |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
63 |
NamedThread thread = new NamedThread(name); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
64 |
thread.start(); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
65 |
ProcessBuilder processBuilder = new ProcessBuilder(); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
66 |
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstack"); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
67 |
launcher.addToolArg("-l"); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
68 |
launcher.addToolArg(Long.toString(ProcessTools.getProcessId())); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
69 |
processBuilder.command(launcher.getCommand()); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
70 |
System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", "")); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
71 |
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
72 |
System.out.println(output.getOutput()); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
73 |
output.shouldContain("\""+ name + "\""); |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
74 |
} |
8c40b5b4e525
8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
csahu
parents:
diff
changeset
|
75 |
} |