author | sadayapalam |
Mon, 30 Mar 2015 17:09:14 +0530 | |
changeset 29776 | 984a79b71cfe |
parent 28144 | daec48e77612 |
permissions | -rw-r--r-- |
16331
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
1 |
/* |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
2 |
* @test /nodynamiccopyright/ |
29776
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
28144
diff
changeset
|
3 |
* @bug 6939780 7020044 8009459 8021338 8064365 8062373 |
16331
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
4 |
* |
29776
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
28144
diff
changeset
|
5 |
* @summary add a warning to detect diamond sites (including anonymous class instance creation at source >= 9) |
16331
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
6 |
* @author mcimadamore |
28142
32a6b1af81b1
8064365: Better support for finder capabilities in target-typing context
mcimadamore
parents:
19132
diff
changeset
|
7 |
* @compile/ref=T6939780_7.out -Xlint:-options -source 7 T6939780.java -XDrawDiagnostics -XDfind=diamond |
29776
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
28144
diff
changeset
|
8 |
* @compile/ref=T6939780_8.out -Xlint:-options -source 8 T6939780.java -XDrawDiagnostics -XDfind=diamond |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
28144
diff
changeset
|
9 |
* @compile/ref=T6939780_9.out -Xlint:-options -source 9 T6939780.java -XDrawDiagnostics -XDfind=diamond |
16331
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
10 |
* |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
11 |
*/ |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
12 |
|
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
13 |
class T6939780 { |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
14 |
|
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
15 |
static class Foo<X extends Number> { |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
16 |
Foo() {} |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
17 |
Foo(X x) {} |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
18 |
} |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
19 |
|
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
20 |
void testAssign() { |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
21 |
Foo<Number> f1 = new Foo<Number>(1); |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
22 |
Foo<?> f2 = new Foo<Number>(); |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
23 |
Foo<?> f3 = new Foo<Integer>(); |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
24 |
Foo<Number> f4 = new Foo<Number>(1) {}; |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
25 |
Foo<?> f5 = new Foo<Number>() {}; |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
26 |
Foo<?> f6 = new Foo<Integer>() {}; |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
27 |
} |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
28 |
|
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
29 |
void testMethod() { |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
30 |
gn(new Foo<Number>(1)); |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
31 |
gw(new Foo<Number>()); |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
32 |
gw(new Foo<Integer>()); |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
33 |
gn(new Foo<Number>(1) {}); |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
34 |
gw(new Foo<Number>() {}); |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
35 |
gw(new Foo<Integer>() {}); |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
36 |
} |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
37 |
|
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
38 |
void gw(Foo<?> fw) { } |
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
39 |
void gn(Foo<Number> fn) { } |
19132
e2349c075315
8021338: Diamond finder may mark a required type argument as unnecessary
jlahoda
parents:
16331
diff
changeset
|
40 |
|
e2349c075315
8021338: Diamond finder may mark a required type argument as unnecessary
jlahoda
parents:
16331
diff
changeset
|
41 |
static class Foo2<X> { |
e2349c075315
8021338: Diamond finder may mark a required type argument as unnecessary
jlahoda
parents:
16331
diff
changeset
|
42 |
X copy(X t) { |
e2349c075315
8021338: Diamond finder may mark a required type argument as unnecessary
jlahoda
parents:
16331
diff
changeset
|
43 |
return t; |
e2349c075315
8021338: Diamond finder may mark a required type argument as unnecessary
jlahoda
parents:
16331
diff
changeset
|
44 |
} |
e2349c075315
8021338: Diamond finder may mark a required type argument as unnecessary
jlahoda
parents:
16331
diff
changeset
|
45 |
} |
e2349c075315
8021338: Diamond finder may mark a required type argument as unnecessary
jlahoda
parents:
16331
diff
changeset
|
46 |
|
e2349c075315
8021338: Diamond finder may mark a required type argument as unnecessary
jlahoda
parents:
16331
diff
changeset
|
47 |
void testReciever() { |
e2349c075315
8021338: Diamond finder may mark a required type argument as unnecessary
jlahoda
parents:
16331
diff
changeset
|
48 |
Number s = new Foo2<Number>().copy(0); |
e2349c075315
8021338: Diamond finder may mark a required type argument as unnecessary
jlahoda
parents:
16331
diff
changeset
|
49 |
} |
e2349c075315
8021338: Diamond finder may mark a required type argument as unnecessary
jlahoda
parents:
16331
diff
changeset
|
50 |
|
16331
fafe9741fb7e
8009459: Wrong behavior of diamond finder with source level 7
mcimadamore
parents:
diff
changeset
|
51 |
} |