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

Tue, 28 Dec 2010 15:54:52 -0800

author
ohair
date
Tue, 28 Dec 2010 15:54:52 -0800
changeset 798
4868a36f6fd8
parent 722
4851ff2ffc10
permissions
-rw-r--r--

6962318: Update copyright year
Reviewed-by: xdono

jjg@309 1
jjg@309 2 /*
ohair@798 3 * Copyright (c) 2008, 2010, 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@722 30 * @compile/fail/ref=BasicTest.out -XDrawDiagnostics 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@722 41 //308: Test inverted to verify that type annotations can not be parsed yet.
jjg@722 42
jjg@309 43 /**
jjg@309 44 * Tests basic JSR 308 parser functionality. We don't really care about what
jjg@309 45 * the parse tree looks like, just that these annotations can be parsed.
jjg@309 46 */
jjg@309 47 class BasicTest<T extends @A Object> extends @B LinkedList<T> implements @C List<T> {
jjg@309 48
jjg@309 49 void test() {
jjg@309 50
jjg@309 51 // Handle annotated class literals/cast types
jjg@309 52 Class<?> c = @A String.class;
jjg@309 53 Object o = (@A Object) "foo";
jjg@309 54
jjg@309 55 // Handle annotated "new" expressions (except arrays; see ArrayTest)
jjg@309 56 String s = new @A String("bar");
jjg@309 57
jjg@309 58 boolean b = o instanceof @A Object;
jjg@309 59
jjg@309 60
jjg@309 61 @A Map<@B List<@C String>, @D String> map =
jjg@309 62 new @A HashMap<@B List<@C String>, @D String>();
jjg@309 63
jjg@309 64 Class<? extends @A String> c2 = @A String.class;
jjg@309 65 }
jjg@309 66
jjg@309 67 // Handle receiver annotations
jjg@309 68 // Handle annotations on a qualified identifier list
jjg@309 69 void test2() @C @D throws @A IllegalArgumentException, @B IOException {
jjg@309 70
jjg@309 71 }
jjg@309 72
jjg@309 73 // Handle annotations on a varargs element type
jjg@309 74 void test3(Object @A... objs) {
jjg@309 75
jjg@309 76 }
jjg@309 77 }

mercurial