langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.java
author jjg
Tue, 15 Oct 2013 15:57:13 -0700
changeset 21041 99f5e5e97425
child 26532 aa84b6606229
permissions -rw-r--r--
8026564: import changes from type-annotations forest Reviewed-by: jjg Contributed-by: wdietl@gmail.com, steve.sides@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21041
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
     1
/*
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
     2
 * @test /nodynamiccopyright/
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
     3
 * @bug 8006733 8006775
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
     4
 * @summary Ensure behavior for nested types is correct.
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
     5
 * @author Werner Dietl
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
     6
 * @compile/fail/ref=CantAnnotateScoping.out -XDrawDiagnostics CantAnnotateScoping.java
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
     7
 */
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
     8
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
     9
import java.util.List;
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    10
import java.util.ArrayList;
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    11
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    12
import java.lang.annotation.*;
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    13
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    14
@Target({ElementType.TYPE_USE})
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    15
@interface TA {}
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    16
@Target({ElementType.TYPE_USE})
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    17
@interface TA2 {}
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    18
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    19
@Target({ElementType.FIELD})
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    20
@interface DA {}
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    21
@Target({ElementType.FIELD})
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    22
@interface DA2 {}
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    23
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    24
@Target({ElementType.TYPE_USE, ElementType.FIELD})
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    25
@interface DTA {}
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    26
@Target({ElementType.TYPE_USE, ElementType.FIELD})
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    27
@interface DTA2 {}
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    28
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    29
class Test {
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    30
    static class Outer {
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    31
        static class SInner {}
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    32
    }
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    33
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    34
    // Legal
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    35
    List<Outer. @TA SInner> li;
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    36
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    37
    // Illegal
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    38
    @TA Outer.SInner osi;
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    39
    // Illegal
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    40
    List<@TA Outer.SInner> aloi;
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    41
    // Illegal
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    42
    Object o1 = new @TA @DA @TA2 Outer.SInner();
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    43
    // Illegal
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    44
    Object o = new ArrayList<@TA @DA Outer.SInner>();
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    45
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    46
    // Illegal: @TA is only a type-use annotation
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    47
    @TA java.lang.Object f1;
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    48
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    49
    // Legal: @DA is only a declaration annotation
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    50
    @DA java.lang.Object f2;
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    51
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    52
    // Legal: @DTA is both a type-use and declaration annotation
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    53
    @DTA java.lang.Object f3;
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    54
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    55
    // Illegal: @TA and @TA2 are only type-use annotations
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    56
    @DTA @DA @TA @DA2 @TA2 java.lang.Object f4;
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    57
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    58
    // Illegal: Do we want one or two messages?
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    59
    // 1: @DA in invalid location
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    60
    // 2: Not finding class "lang"
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    61
    java. @DA lang.Object f5;
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    62
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    63
    // Illegal: Do we want one or two messages?
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    64
    // 1: @DA in invalid location
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    65
    // 2: Not finding class "XXX"
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    66
    java. @DA XXX.Object f6;
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    67
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    68
    // Illegal: Can't find class "lang".
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    69
    // Would a different error message be desirable?
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    70
    java. @TA lang.Object f7;
99f5e5e97425 8026564: import changes from type-annotations forest
jjg
parents:
diff changeset
    71
}