test/tools/javac/typeAnnotations/newlocations/BasicTest.java

Thu, 04 Nov 2010 15:54:46 -0700

author
cl
date
Thu, 04 Nov 2010 15:54:46 -0700
changeset 720
5bb96781fb58
parent 554
9d9f26857129
child 722
4851ff2ffc10
permissions
-rw-r--r--

Added tag jdk7-b117 for changeset 2129a046f117

     2 /*
     3  * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5  *
     6  * This code is free software; you can redistribute it and/or modify it
     7  * under the terms of the GNU General Public License version 2 only, as
     8  * published by the Free Software Foundation.
     9  *
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    13  * version 2 for more details (a copy is included in the LICENSE file that
    14  * accompanied this code).
    15  *
    16  * You should have received a copy of the GNU General Public License version
    17  * 2 along with this work; if not, write to the Free Software Foundation,
    18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    19  *
    20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    21  * or visit www.oracle.com if you need additional information or have any
    22  * questions.
    23  */
    25 /*
    26  * @test
    27  * @bug 6843077
    28  * @summary random tests for new locations
    29  * @author Matt Papi
    30  * @compile -source 1.7 BasicTest.java
    31  */
    33 import java.util.*;
    34 import java.io.*;
    36 @interface A {}
    37 @interface B {}
    38 @interface C {}
    39 @interface D {}
    41 /**
    42  * Tests basic JSR 308 parser functionality. We don't really care about what
    43  * the parse tree looks like, just that these annotations can be parsed.
    44  */
    45 class BasicTest<T extends @A Object> extends @B LinkedList<T> implements @C List<T> {
    47     void test() {
    49         // Handle annotated class literals/cast types
    50         Class<?> c = @A String.class;
    51         Object o = (@A Object) "foo";
    53         // Handle annotated "new" expressions (except arrays; see ArrayTest)
    54         String s = new @A String("bar");
    56         boolean b = o instanceof @A Object;
    59         @A Map<@B List<@C String>, @D String> map =
    60             new @A HashMap<@B List<@C String>, @D String>();
    62         Class<? extends @A String> c2 = @A String.class;
    63     }
    65     // Handle receiver annotations
    66     // Handle annotations on a qualified identifier list
    67     void test2() @C @D throws @A IllegalArgumentException, @B IOException {
    69     }
    71     // Handle annotations on a varargs element type
    72     void test3(Object @A... objs) {
    74     }
    75 }

mercurial