Fri, 10 Dec 2010 15:24:17 +0000
6199075: Unambiguous varargs method calls flagged as ambiguous
Summary: javac does not implement overload resolution w.r.t. varargs methods as described in the JLS
Reviewed-by: jjg
1 /**
2 * @test /nodynamiccopyright/
3 * @bug 4216683 4346296 4656556 4785453
4 * @summary New rules for when deprecation messages are suppressed
5 * @author gafter
6 *
7 * @compile/ref=SuppressDeprecation.out -Xlint:deprecation -XDrawDiagnostics SuppressDeprecation.java
8 */
10 /* Test for the contexts in which deprecations warnings should
11 * (and should not) be given. They should be given when
12 * o invoking a deprecated method from a non-deprecated one.
13 * o new X() using a deprecated constructor
14 * o super() to a deprecated constructor
15 * o extending a deprecated class.
16 * But deprecation messages are suppressed as follows:
17 * o Never complain about code in the same outermost class as
18 * the deprecated entity.
19 * o Extending a deprecated class with a deprecated one is OK.
20 * o Overriding a deprecated method with a deprecated one is OK.
21 * o Code appearing in a deprecated class is OK.
22 *
23 */
25 class T {
26 /** var.
27 * @deprecated . */
28 int var;
30 /** f.
31 * @deprecated . */
32 void f() {
33 }
35 /** g.
36 * @deprecated . */
37 void g() {
38 f();
39 }
41 void h() {
42 f();
43 }
45 /** T.
46 * @deprecated . */
47 T() {
48 }
50 /** T.
51 * @deprecated . */
52 T(int i) {
53 this();
54 }
56 T(float f) {
57 this();
58 }
60 void xyzzy() {
61 new T();
62 new T(1.4f);
63 }
64 /** plugh.
65 * @deprecated . */
66 void plugh() {
67 new T();
68 new T(1.45f);
69 }
71 /** calcx..
72 * @deprecated . */
73 int calcx() { return 0; }
74 }
76 class U extends T {
77 /** f.
78 * @deprecated . */
79 void f() {
80 }
82 void g() { // error (1)
83 super.g(); // error (2)
84 var = 12; // error (3)
85 }
87 U() {} // error (4)
89 U(int i) {
90 super(i); // error (5)
91 }
93 U(float f) {
94 super(1.3f);
95 }
96 }
98 class V extends T {} // error (6)
100 /** W.
101 * @deprecated . */
102 class W extends T { // ok - inside deprecated class
103 /** W.
104 * @deprecated . */
105 static {
106 new T(1.3f).g(); // ok - called from deprecated static block
107 }
109 /** W.
110 * @deprecated . */
111 {
112 new T(1.3f).g(); // ok - called from deprecated block
113 }
115 {
116 new T(1.3f).g(); // ok - inside deprecated class
117 }
119 int x = calcx(); // ok - inside deprecated class
121 /** y.
122 * @deprecated . */
123 int y = calcx();
124 }
126 /** X.
127 * @deprecated . */
128 class X {}
130 class Y extends X {} // ok - not overriding anything
132 /** Z.
133 * @deprecated . */
134 class Z extends X {}