test/tools/apt/mirror/declaration/AnnoTypeDecl.java

Mon, 15 Dec 2008 16:55:33 -0800

author
xdono
date
Mon, 15 Dec 2008 16:55:33 -0800
changeset 174
fdfed22db054
parent 132
a54ef8459576
child 554
9d9f26857129
permissions
-rw-r--r--

6785258: Update copyright year
Summary: Update copyright for files that have been modified starting July 2008 to Dec 2008
Reviewed-by: katleman, ohair, tbell

     1 /*
     2  * Copyright 2004-2008 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  */
    25 /*
    26  * @test
    27  * @bug 4853450 5014539
    28  * @summary AnnotationTypeDeclaration tests
    29  * @library ../../lib
    30  * @compile -source 1.5 AnnoTypeDecl.java
    31  * @run main/othervm AnnoTypeDecl
    32  */
    35 import java.util.*;
    36 import com.sun.mirror.declaration.*;
    37 import com.sun.mirror.type.*;
    38 import com.sun.mirror.util.*;
    41 public class AnnoTypeDecl extends Tester {
    43     public static void main(String[] args) {
    44         (new AnnoTypeDecl()).run();
    45     }
    48     private AnnotationTypeDeclaration at;
    50     protected void init() {
    51         at = (AnnotationTypeDeclaration) env.getTypeDeclaration("AT");
    52     }
    55     // Declaration methods
    57     @Test(result="annotation type")
    58     Collection<String> accept() {
    59         final Collection<String> res = new ArrayList<String>();
    61         at.accept(new SimpleDeclarationVisitor() {
    62             public void visitTypeDeclaration(TypeDeclaration t) {
    63                 res.add("type");
    64             }
    65             public void visitClassDeclaration(ClassDeclaration c) {
    66                 res.add("class");
    67             }
    68             public void visitInterfaceDeclaration(InterfaceDeclaration i) {
    69                 res.add("interface");
    70             }
    71             public void visitAnnotationTypeDeclaration(
    72                                                 AnnotationTypeDeclaration a) {
    73                 res.add("annotation type");
    74             }
    75         });
    76         return res;
    77     }
    80     // AnnotationTypeDeclaration methods
    82     @Test(result={"s()"})
    83     Collection<AnnotationTypeElementDeclaration> getMethods() {
    84         return at.getMethods();
    85     }
    86 }
    89 // An annotation type to use for testing.
    91 @interface AT {
    92     String s();
    93 }

mercurial