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

changeset 0
959103a6100f
child 2525
2eb010b6cb22
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,110 @@
     1.4 +/*
     1.5 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + */
    1.26 +
    1.27 +/*
    1.28 + * @test
    1.29 + * @bug 8026791
    1.30 + * @summary Test population of reference info for constructor results
    1.31 + * @compile -g Driver.java ReferenceInfoUtil.java Constructors.java
    1.32 + * @run main Driver Constructors
    1.33 + */
    1.34 +
    1.35 +import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
    1.36 +
    1.37 +public class Constructors {
    1.38 +
    1.39 +    @TADescriptions({
    1.40 +        @TADescription(annotation = "TA", type = METHOD_RETURN),
    1.41 +        @TADescription(annotation = "TB", type = METHOD_RETURN),
    1.42 +        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
    1.43 +    })
    1.44 +    public String regularClass() {
    1.45 +        return "class Test { @TA Test() {}" +
    1.46 +                           " @TB Test(@TC int b) {} }";
    1.47 +    }
    1.48 +
    1.49 +    @TADescriptions({
    1.50 +        @TADescription(annotation = "TA", type = METHOD_RETURN, genericLocation = {1, 0}),
    1.51 +        @TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0}),
    1.52 +        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
    1.53 +    })
    1.54 +    @TestClass("Test$Inner")
    1.55 +    public String innerClass() {
    1.56 +        return "class Test { class Inner {" +
    1.57 +               " @TA Inner() {}" +
    1.58 +               " @TB Inner(@TC int b) {}" +
    1.59 +               " } }";
    1.60 +    }
    1.61 +
    1.62 +    @TADescriptions({
    1.63 +        @TADescription(annotation = "TA", type = METHOD_RECEIVER),
    1.64 +        @TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0}),
    1.65 +        @TADescription(annotation = "TC", type = METHOD_RECEIVER),
    1.66 +        @TADescription(annotation = "TD", type = METHOD_RETURN, genericLocation = {1, 0}),
    1.67 +        @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
    1.68 +    })
    1.69 +    @TestClass("Test$Inner")
    1.70 +    public String innerClass2() {
    1.71 +        return "class Test { class Inner {" +
    1.72 +               " @TB Inner(@TA Test Test.this) {}" +
    1.73 +               " @TD Inner(@TC Test Test.this, @TE int b) {}" +
    1.74 +               " } }";
    1.75 +    }
    1.76 +
    1.77 +    @TADescriptions({
    1.78 +        @TADescription(annotation = "TA", type = METHOD_RECEIVER),
    1.79 +        @TADescription(annotation = "TB", type = METHOD_RECEIVER, genericLocation = {1, 0}),
    1.80 +        @TADescription(annotation = "TC", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0}),
    1.81 +        @TADescription(annotation = "TD", type = METHOD_RECEIVER, genericLocation = {1, 0}),
    1.82 +        @TADescription(annotation = "TE", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0}),
    1.83 +        @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
    1.84 +    })
    1.85 +    @TestClass("Outer$Middle$Inner")
    1.86 +    public String innerClass3() {
    1.87 +        return "class Outer { class Middle { class Inner {" +
    1.88 +               " @TC Inner(@TA Outer. @TB Middle Middle.this) {}" +
    1.89 +               " @TE Inner(@TD Middle Outer.Middle.this, @TF int b) {}" +
    1.90 +               " } } }";
    1.91 +    }
    1.92 +
    1.93 +    @TADescriptions({
    1.94 +        @TADescription(annotation = "TA", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
    1.95 +                typeIndex = 0, offset = 4),
    1.96 +        @TADescription(annotation = "TB", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
    1.97 +                typeIndex = 0, offset = 0)
    1.98 +    })
    1.99 +    public String generic1() {
   1.100 +        return "class Test { <T> Test(int i) { new <@TA T>Test(); }" +
   1.101 +                           " <T> Test() { <@TB String>this(0); } }";
   1.102 +    }
   1.103 +
   1.104 +    @TADescriptions({
   1.105 +        @TADescription(annotation = "TA", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
   1.106 +                typeIndex = 0, offset = 0)
   1.107 +    })
   1.108 +    public String generic2() {
   1.109 +        return "class Super { <T> Super(int i) { } } " +
   1.110 +                "class Test extends Super { <T> Test() { <@TA String>super(0); } }";
   1.111 +    }
   1.112 +
   1.113 +}

mercurial