|
1 /** |
|
2 * @test /nodynamiccopyright/ |
|
3 * @bug 4986256 |
|
4 * @compile/ref=Unchecked.noLint.out -XDrawDiagnostics Unchecked.java |
|
5 * @compile/ref=Unchecked.lintUnchecked.out -Xlint:unchecked -XDrawDiagnostics Unchecked.java |
|
6 * @compile/ref=Unchecked.lintAll.out -Xlint:all,-path -XDrawDiagnostics Unchecked.java |
|
7 */ |
|
8 |
|
9 import java.util.ArrayList; |
|
10 import java.util.List; |
|
11 |
|
12 // control: this class should generate warnings |
|
13 class Unchecked |
|
14 { |
|
15 void m() { |
|
16 List l = new ArrayList<String>(); |
|
17 l.add("abc"); |
|
18 } |
|
19 } |
|
20 |
|
21 // tests: the warnings that would otherwise be generated should all be suppressed |
|
22 @SuppressWarnings("unchecked") |
|
23 class Unchecked2 |
|
24 { |
|
25 void m() { |
|
26 List l = new ArrayList<String>(); |
|
27 l.add("abc"); |
|
28 } |
|
29 } |
|
30 |
|
31 class Unchecked3 |
|
32 { |
|
33 @SuppressWarnings("unchecked") |
|
34 void m() { |
|
35 List l = new ArrayList<String>(); |
|
36 l.add("abc"); |
|
37 } |
|
38 } |
|
39 |
|
40 class Unchecked4 |
|
41 { |
|
42 void m() { |
|
43 @SuppressWarnings("unchecked") |
|
44 class Inner { |
|
45 void m() { |
|
46 List l = new ArrayList<String>(); |
|
47 l.add("abc"); |
|
48 } |
|
49 } |
|
50 } |
|
51 } |
|
52 |
|
53 // this class should produce warnings because @SuppressWarnings should not be inherited |
|
54 class Unchecked5 extends Unchecked2 |
|
55 { |
|
56 void m() { |
|
57 List l = new ArrayList<String>(); |
|
58 l.add("abc"); |
|
59 } |
|
60 } |