author | mcimadamore |
Tue, 14 Oct 2014 12:00:39 +0100 | |
changeset 27124 | 5b69a74c224e |
child 32337 | c9d3ab9f601c |
permissions | -rw-r--r-- |
27124
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
1 |
/* |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
4 |
* |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
10 |
* |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
15 |
* accompanied this code). |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
16 |
* |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
20 |
* |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
23 |
* questions. |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
24 |
*/ |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
25 |
|
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
26 |
/** |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
27 |
* @test |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
28 |
* @bug 8058199 |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
29 |
* @summary Code generation problem with javac skipping a checkcast instruction |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
30 |
*/ |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
31 |
public class T8058199 { |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
32 |
|
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
33 |
final static String SYNTHETIC_CAST_TYPE = "[Ljava.lang.String;"; |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
34 |
|
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
35 |
@SuppressWarnings("unchecked") |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
36 |
<Z> Z[] makeArr(Z z) { return (Z[])new Object[1]; } |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
37 |
|
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
38 |
<U> void check(U u) { } |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
39 |
|
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
40 |
void testMethod() { |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
41 |
test(() -> check(makeArr(""))); |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
42 |
} |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
43 |
|
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
44 |
void testNewDiamond() { |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
45 |
class Check<X> { |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
46 |
Check(X x) { } |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
47 |
} |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
48 |
test(()-> new Check<>(makeArr(""))); |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
49 |
} |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
50 |
|
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
51 |
void testNewGeneric() { |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
52 |
class Check { |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
53 |
<Z> Check(Z z) { } |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
54 |
} |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
55 |
test(()-> new Check(makeArr(""))); |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
56 |
} |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
57 |
|
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
58 |
private void test(Runnable r) { |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
59 |
try { |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
60 |
r.run(); |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
61 |
throw new AssertionError("Missing synthetic cast"); |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
62 |
} catch (ClassCastException cce) { |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
63 |
if (!cce.getMessage().contains(SYNTHETIC_CAST_TYPE)) { |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
64 |
throw new AssertionError("Bad type in synthetic cast", cce); |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
65 |
} |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
66 |
} |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
67 |
} |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
68 |
|
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
69 |
public static void main(String[] args) { |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
70 |
T8058199 test = new T8058199(); |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
71 |
test.testMethod(); |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
72 |
test.testNewDiamond(); |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
73 |
test.testNewGeneric(); |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
74 |
} |
5b69a74c224e
8058199: Code generation problem with javac skipping a checkcast instruction
mcimadamore
parents:
diff
changeset
|
75 |
} |