test/langtools/tools/javac/warnings/Deprecation.java
author darcy
Fri, 02 Feb 2018 10:29:25 -0800
changeset 48723 6cb86bf0b51e
parent 47216 71c04702a3d5
child 48776 107413b070b9
permissions -rw-r--r--
8196623: Update JavaBaseTest.java to be version agnostic Reviewed-by: vromero
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/
27854
22b4bfc4e22f 8032211: Don't issue deprecation warnings on import statements
jlahoda
parents: 6150
diff changeset
     3
 * @bug 4986256 6598104 8032211
22b4bfc4e22f 8032211: Don't issue deprecation warnings on import statements
jlahoda
parents: 6150
diff changeset
     4
 * @compile/ref=Deprecation.noLint.out                                                 -XDrawDiagnostics Deprecation.java
22b4bfc4e22f 8032211: Don't issue deprecation warnings on import statements
jlahoda
parents: 6150
diff changeset
     5
 * @compile/ref=Deprecation.lintDeprecation.out  -Xlint:deprecation                    -XDrawDiagnostics Deprecation.java
22b4bfc4e22f 8032211: Don't issue deprecation warnings on import statements
jlahoda
parents: 6150
diff changeset
     6
 * @compile/ref=Deprecation.lintDeprecation8.out -Xlint:deprecation,-options -source 8 -XDrawDiagnostics Deprecation.java
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
27854
22b4bfc4e22f 8032211: Don't issue deprecation warnings on import statements
jlahoda
parents: 6150
diff changeset
     9
import java.io.StringBufferInputStream;
22b4bfc4e22f 8032211: Don't issue deprecation warnings on import statements
jlahoda
parents: 6150
diff changeset
    10
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
@Deprecated
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
class Deprecation
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
}
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
// control: this class should generate warnings
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
class Deprecation2
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
    void m() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
        Object d = new Deprecation();
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
}
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
// tests: the warnings that would otherwise be generated should all be suppressed
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
@SuppressWarnings("deprecation")
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
class Deprecation3
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
    void m() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
        Object d = new Deprecation();
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
}
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
class Deprecation4
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
    @SuppressWarnings("deprecation")
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
    void m() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
        Object d = new Deprecation();
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
}
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
class Deprecation5
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
    void m() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
        @SuppressWarnings("deprecation")
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
            class Inner {
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
                void m() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
                    Object d = new Deprecation();
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
}
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
// this class should produce warnings because @SuppressWarnings should not be inherited
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
class Deprecation6 extends Deprecation3
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    void m() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
        Object d = new Deprecation();
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
}