langtools/test/tools/javac/typeAnnotations/newlocations/Expressions.java
changeset 7083 f6bd6c4fcf54
parent 7070 4fd2b103e010
parent 7082 b36c199d8de8
child 7084 ea14efe08312
equal deleted inserted replaced
7070:4fd2b103e010 7083:f6bd6c4fcf54
     1 /*
       
     2  * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 /*
       
    25  * @test
       
    26  * @bug 6843077
       
    27  * @summary new type annotation location: expressions
       
    28  * @author Mahmood Ali
       
    29  * @compile -source 1.7 Expressions.java
       
    30  */
       
    31 class Expressions {
       
    32   void instanceOf() {
       
    33     Object o = null;
       
    34     boolean a = o instanceof @A String;
       
    35     boolean b = o instanceof @B(0) String;
       
    36   }
       
    37 
       
    38   void instanceOfArray() {
       
    39     Object o = null;
       
    40     boolean a1 = o instanceof @A String [];
       
    41     boolean a2 = o instanceof @B(0) String [];
       
    42 
       
    43     boolean b1 = o instanceof String @A [];
       
    44     boolean b2 = o instanceof String @B(0) [];
       
    45   }
       
    46 
       
    47   void objectCreation() {
       
    48     new @A String();
       
    49     new @B(0) String();
       
    50   }
       
    51 
       
    52   void objectCreationArray() {
       
    53     Object a1 = new @A String [] [] { };
       
    54     Object a2 = new @A String [1] [];
       
    55     Object a3 = new @A String [1] [2];
       
    56 
       
    57     Object b1 = new @A String @B(0) [] [] { };
       
    58     Object b2 = new @A String @B(0) [1] [];
       
    59     Object b3 = new @A String @B(0) [1] [2];
       
    60 
       
    61     Object c1 = new @A String []  @B(0) [] { };
       
    62     Object c2 = new @A String [1] @B(0) [];
       
    63     Object c3 = new @A String [1] @B(0) [2];
       
    64 
       
    65     Object d1 = new @A String @B(0) []  @B(0) [] { };
       
    66     Object d2 = new @A String @B(0) [1] @B(0) [];
       
    67     Object d3 = new @A String @B(0) [1] @B(0) [2];
       
    68 
       
    69     Object rand = new @A String @B(value = 0) [1] @B(value = 0) [2];
       
    70 
       
    71   }
       
    72 }
       
    73 
       
    74 @interface A { }
       
    75 @interface B { int value(); }