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