author | hseigel |
Wed, 02 Mar 2016 23:48:41 +0000 | |
changeset 36397 | c487ced7231c |
parent 36041 | bfcede0994e5 |
permissions | -rw-r--r-- |
35424 | 1 |
/* |
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* @test |
|
26 |
* @summary Test that StringConcat is working for JDK >= 9 |
|
27 |
* @compile -source 6 -target 6 TestIndyStringConcat.java |
|
28 |
* @run main TestIndyStringConcat false |
|
29 |
* @clean TestIndyStringConcat* |
|
30 |
* @compile -source 7 -target 7 TestIndyStringConcat.java |
|
31 |
* @run main TestIndyStringConcat false |
|
32 |
* @clean TestIndyStringConcat* |
|
33 |
* @compile -source 8 -target 8 TestIndyStringConcat.java |
|
34 |
* @run main TestIndyStringConcat false |
|
35 |
* @clean TestIndyStringConcat* |
|
36 |
* @compile -XDstringConcat=inline -source 9 -target 9 TestIndyStringConcat.java |
|
37 |
* @run main TestIndyStringConcat false |
|
38 |
* @clean TestIndyStringConcat* |
|
39 |
* @compile -XDstringConcat=indy -source 9 -target 9 TestIndyStringConcat.java |
|
40 |
* @run main TestIndyStringConcat true |
|
41 |
* @clean TestIndyStringConcat* |
|
42 |
* @compile -XDstringConcat=indyWithConstants -source 9 -target 9 TestIndyStringConcat.java |
|
43 |
* @run main TestIndyStringConcat true |
|
44 |
*/ |
|
45 |
public class TestIndyStringConcat { |
|
46 |
||
47 |
private static class MyObject { |
|
48 |
public String toString() { |
|
49 |
throw new RuntimeException("Boyyaa"); |
|
50 |
} |
|
51 |
} |
|
52 |
||
53 |
class Inner { } |
|
54 |
||
55 |
public static void main(String[] args) { |
|
56 |
boolean useIndyConcat = Boolean.valueOf(args[0]); |
|
57 |
try { |
|
58 |
String s = "Foo" + new MyObject(); |
|
59 |
} catch (RuntimeException ex) { |
|
60 |
boolean indifiedStringConcat = false; |
|
61 |
ex.printStackTrace(); |
|
62 |
for (StackTraceElement e : ex.getStackTrace()) { |
|
36041
bfcede0994e5
8149835: StringConcatFactory should emit classes with the same package as the host class
shade
parents:
35424
diff
changeset
|
63 |
if (e.getClassName().contains("$$StringConcat") && |
35424 | 64 |
e.getMethodName().equals("concat")) { |
65 |
indifiedStringConcat = true; |
|
66 |
break; |
|
67 |
} |
|
68 |
} |
|
69 |
if (indifiedStringConcat != useIndyConcat) { |
|
70 |
throw new AssertionError(); |
|
71 |
} |
|
72 |
} |
|
73 |
} |
|
74 |
} |