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

Tue, 25 May 2010 15:54:51 -0700

author
ohair
date
Tue, 25 May 2010 15:54:51 -0700
changeset 554
9d9f26857129
parent 309
664edca41e34
child 722
4851ff2ffc10
permissions
-rw-r--r--

6943119: Rebrand source copyright notices
Reviewed-by: darcy

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

mercurial