test/langtools/tools/javac/warnings/Deprecation.java
author jlahoda
Wed, 07 Feb 2018 16:49:24 +0100
changeset 48776 107413b070b9
parent 47216 71c04702a3d5
permissions -rw-r--r--
8194764: javac incorrectly flags deprecated for removal imports Summary: Fixing source range for the Source.Feature.DEPRECATE_ON_IMPORT Reviewed-by: mcimadamore
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/
48776
107413b070b9 8194764: javac incorrectly flags deprecated for removal imports
jlahoda
parents: 47216
diff changeset
     3
 * @bug 4986256 6598104 8032211 8194764
27854
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
48776
107413b070b9 8194764: javac incorrectly flags deprecated for removal imports
jlahoda
parents: 47216
diff changeset
     6
 * @compile/ref=Deprecation.lintDeprecation.out  -Xlint:deprecation,-options -source 9 -XDrawDiagnostics Deprecation.java
27854
22b4bfc4e22f 8032211: Don't issue deprecation warnings on import statements
jlahoda
parents: 6150
diff changeset
     7
 * @compile/ref=Deprecation.lintDeprecation8.out -Xlint:deprecation,-options -source 8 -XDrawDiagnostics Deprecation.java
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
27854
22b4bfc4e22f 8032211: Don't issue deprecation warnings on import statements
jlahoda
parents: 6150
diff changeset
    10
import java.io.StringBufferInputStream;
22b4bfc4e22f 8032211: Don't issue deprecation warnings on import statements
jlahoda
parents: 6150
diff changeset
    11
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
@Deprecated
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
class Deprecation
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
}
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
// control: this class should generate warnings
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
class Deprecation2
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
    void m() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
        Object d = new Deprecation();
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
// tests: the warnings that would otherwise be generated should all be suppressed
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
@SuppressWarnings("deprecation")
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
class Deprecation3
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
    void m() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
        Object d = new Deprecation();
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
}
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
class Deprecation4
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
    @SuppressWarnings("deprecation")
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
    void m() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
        Object d = new Deprecation();
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
}
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
class Deprecation5
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
    void m() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
        @SuppressWarnings("deprecation")
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
            class Inner {
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
                void m() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
                    Object d = new Deprecation();
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
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
// this class should produce warnings because @SuppressWarnings should not be inherited
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
class Deprecation6 extends Deprecation3
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    void m() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
        Object d = new Deprecation();
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
}