Wed, 26 Jan 2011 13:45:25 -0800
7013272: Automatically generate info about how compiler resource keys are used
Reviewed-by: mcimadamore
duke@1 | 1 | /** |
duke@1 | 2 | * @test /nodynamiccopyright/ |
duke@1 | 3 | * @bug 4216683 4346296 4656556 4785453 |
duke@1 | 4 | * @summary New rules for when deprecation messages are suppressed |
duke@1 | 5 | * @author gafter |
duke@1 | 6 | * |
jjg@611 | 7 | * @compile/ref=SuppressDeprecation.out -Xlint:deprecation -XDrawDiagnostics SuppressDeprecation.java |
duke@1 | 8 | */ |
duke@1 | 9 | |
duke@1 | 10 | /* Test for the contexts in which deprecations warnings should |
duke@1 | 11 | * (and should not) be given. They should be given when |
duke@1 | 12 | * o invoking a deprecated method from a non-deprecated one. |
duke@1 | 13 | * o new X() using a deprecated constructor |
duke@1 | 14 | * o super() to a deprecated constructor |
duke@1 | 15 | * o extending a deprecated class. |
duke@1 | 16 | * But deprecation messages are suppressed as follows: |
duke@1 | 17 | * o Never complain about code in the same outermost class as |
duke@1 | 18 | * the deprecated entity. |
duke@1 | 19 | * o Extending a deprecated class with a deprecated one is OK. |
duke@1 | 20 | * o Overriding a deprecated method with a deprecated one is OK. |
duke@1 | 21 | * o Code appearing in a deprecated class is OK. |
duke@1 | 22 | * |
duke@1 | 23 | */ |
duke@1 | 24 | |
duke@1 | 25 | class T { |
duke@1 | 26 | /** var. |
duke@1 | 27 | * @deprecated . */ |
duke@1 | 28 | int var; |
duke@1 | 29 | |
duke@1 | 30 | /** f. |
duke@1 | 31 | * @deprecated . */ |
duke@1 | 32 | void f() { |
duke@1 | 33 | } |
duke@1 | 34 | |
duke@1 | 35 | /** g. |
duke@1 | 36 | * @deprecated . */ |
duke@1 | 37 | void g() { |
duke@1 | 38 | f(); |
duke@1 | 39 | } |
duke@1 | 40 | |
duke@1 | 41 | void h() { |
duke@1 | 42 | f(); |
duke@1 | 43 | } |
duke@1 | 44 | |
duke@1 | 45 | /** T. |
duke@1 | 46 | * @deprecated . */ |
duke@1 | 47 | T() { |
duke@1 | 48 | } |
duke@1 | 49 | |
duke@1 | 50 | /** T. |
duke@1 | 51 | * @deprecated . */ |
duke@1 | 52 | T(int i) { |
duke@1 | 53 | this(); |
duke@1 | 54 | } |
duke@1 | 55 | |
duke@1 | 56 | T(float f) { |
duke@1 | 57 | this(); |
duke@1 | 58 | } |
duke@1 | 59 | |
duke@1 | 60 | void xyzzy() { |
duke@1 | 61 | new T(); |
duke@1 | 62 | new T(1.4f); |
duke@1 | 63 | } |
duke@1 | 64 | /** plugh. |
duke@1 | 65 | * @deprecated . */ |
duke@1 | 66 | void plugh() { |
duke@1 | 67 | new T(); |
duke@1 | 68 | new T(1.45f); |
duke@1 | 69 | } |
duke@1 | 70 | |
duke@1 | 71 | /** calcx.. |
duke@1 | 72 | * @deprecated . */ |
duke@1 | 73 | int calcx() { return 0; } |
duke@1 | 74 | } |
duke@1 | 75 | |
duke@1 | 76 | class U extends T { |
duke@1 | 77 | /** f. |
duke@1 | 78 | * @deprecated . */ |
duke@1 | 79 | void f() { |
duke@1 | 80 | } |
duke@1 | 81 | |
duke@1 | 82 | void g() { // error (1) |
duke@1 | 83 | super.g(); // error (2) |
duke@1 | 84 | var = 12; // error (3) |
duke@1 | 85 | } |
duke@1 | 86 | |
duke@1 | 87 | U() {} // error (4) |
duke@1 | 88 | |
duke@1 | 89 | U(int i) { |
duke@1 | 90 | super(i); // error (5) |
duke@1 | 91 | } |
duke@1 | 92 | |
duke@1 | 93 | U(float f) { |
duke@1 | 94 | super(1.3f); |
duke@1 | 95 | } |
duke@1 | 96 | } |
duke@1 | 97 | |
duke@1 | 98 | class V extends T {} // error (6) |
duke@1 | 99 | |
duke@1 | 100 | /** W. |
duke@1 | 101 | * @deprecated . */ |
duke@1 | 102 | class W extends T { // ok - inside deprecated class |
duke@1 | 103 | /** W. |
duke@1 | 104 | * @deprecated . */ |
duke@1 | 105 | static { |
duke@1 | 106 | new T(1.3f).g(); // ok - called from deprecated static block |
duke@1 | 107 | } |
duke@1 | 108 | |
duke@1 | 109 | /** W. |
duke@1 | 110 | * @deprecated . */ |
duke@1 | 111 | { |
duke@1 | 112 | new T(1.3f).g(); // ok - called from deprecated block |
duke@1 | 113 | } |
duke@1 | 114 | |
duke@1 | 115 | { |
duke@1 | 116 | new T(1.3f).g(); // ok - inside deprecated class |
duke@1 | 117 | } |
duke@1 | 118 | |
duke@1 | 119 | int x = calcx(); // ok - inside deprecated class |
duke@1 | 120 | |
duke@1 | 121 | /** y. |
duke@1 | 122 | * @deprecated . */ |
duke@1 | 123 | int y = calcx(); |
duke@1 | 124 | } |
duke@1 | 125 | |
duke@1 | 126 | /** X. |
duke@1 | 127 | * @deprecated . */ |
duke@1 | 128 | class X {} |
duke@1 | 129 | |
duke@1 | 130 | class Y extends X {} // ok - not overriding anything |
duke@1 | 131 | |
duke@1 | 132 | /** Z. |
duke@1 | 133 | * @deprecated . */ |
duke@1 | 134 | class Z extends X {} |