test/tools/javac/annotations/typeAnnotations/referenceinfos/NewObjects.java

Tue, 12 Mar 2013 17:39:34 +0100

author
jfranck
date
Tue, 12 Mar 2013 17:39:34 +0100
changeset 1629
f427043f8c65
parent 1534
bec996065c45
child 1755
ddb4a2bfcd82
permissions
-rw-r--r--

7196531: Duplicate error messages on repeating annotations
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 2009, 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  */
    24 import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
    26 /*
    27  * @test
    28  * @summary Test population of reference info for new object creations
    29  * @compile -g Driver.java ReferenceInfoUtil.java NewObjects.java
    30  * @run main Driver NewObjects
    31  */
    32 public class NewObjects {
    34     @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
    35     public String returnObject() {
    36         return "Object returnObject() { return new @TA String(); }";
    37     }
    39     @TADescriptions({
    40         @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
    41         @TADescription(annotation = "TB", type = NEW,
    42                 genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
    43     })
    44     public String returnObjectGeneric() {
    45         return "Object returnObjectGeneric() { return new @TA ArrayList<@TB String>(); }";
    46     }
    48     @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
    49     public String initObject() {
    50         return "void initObject() { Object a =  new @TA String(); }";
    51     }
    53     @TADescriptions({
    54         @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
    55         @TADescription(annotation = "TB", type = NEW,
    56                 genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
    57         @TADescription(annotation = "TC", type = NEW,
    58                 genericLocation = { 3, 1 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
    59     })
    60     public String initObjectGeneric() {
    61         return "void initObjectGeneric() { Object a = new @TA HashMap<@TB String, @TC String>(); }";
    62     }
    64     @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
    65     public String eqtestObject() {
    66         return "void eqtestObject() { if (null == new @TA String()); }";
    67     }
    69     @TADescriptions({
    70         @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
    71         @TADescription(annotation = "TB", type = NEW,
    72                 genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
    73     })
    74     public String eqtestObjectGeneric() {
    75         return "void eqtestObjectGeneric() { if (null == new @TA ArrayList<@TB String >()); }";
    76     }
    78 }

mercurial