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

Tue, 12 Feb 2013 17:15:29 -0800

author
jjg
date
Tue, 12 Feb 2013 17:15:29 -0800
changeset 1563
bc456436c613
parent 1534
bec996065c45
child 2227
998b10c43157
permissions
-rw-r--r--

8008077: update reference impl for type-annotations
Reviewed-by: jjg
Contributed-by: wmdietl@cs.washington.edu

jjg@1521 1 /*
darcy@1534 2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
jjg@1521 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jjg@1521 4 *
jjg@1521 5 * This code is free software; you can redistribute it and/or modify it
jjg@1521 6 * under the terms of the GNU General Public License version 2 only, as
jjg@1521 7 * published by the Free Software Foundation.
jjg@1521 8 *
jjg@1521 9 * This code is distributed in the hope that it will be useful, but WITHOUT
jjg@1521 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jjg@1521 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jjg@1521 12 * version 2 for more details (a copy is included in the LICENSE file that
jjg@1521 13 * accompanied this code).
jjg@1521 14 *
jjg@1521 15 * You should have received a copy of the GNU General Public License version
jjg@1521 16 * 2 along with this work; if not, write to the Free Software Foundation,
jjg@1521 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jjg@1521 18 *
jjg@1521 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jjg@1521 20 * or visit www.oracle.com if you need additional information or have any
jjg@1521 21 * questions.
jjg@1521 22 */
jjg@1521 23
jjg@1521 24 import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
jjg@1521 25
jjg@1521 26 /*
jjg@1521 27 * @test
jjg@1521 28 * @summary Test population of reference info for class type parameters
jjg@1521 29 * @compile -g Driver.java ReferenceInfoUtil.java ClassTypeParam.java
jjg@1521 30 * @run main Driver ClassTypeParam
jjg@1521 31 */
jjg@1521 32 public class ClassTypeParam {
jjg@1521 33
jjg@1521 34 @TADescriptions({
jjg@1521 35 @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0),
jjg@1521 36 @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
jjg@1521 37 @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1),
jjg@1521 38 @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
jjg@1521 39 @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
jjg@1521 40 })
jjg@1521 41 public String regularClass() {
jjg@1521 42 return "class Test<@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> { }";
jjg@1521 43 }
jjg@1521 44
jjg@1521 45 @TADescriptions({
jjg@1521 46 @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0),
jjg@1521 47 @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
jjg@1521 48 @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1),
jjg@1521 49 @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
jjg@1521 50 })
jjg@1521 51 public String regularClass2() {
jjg@1521 52 return "class Test<@TA K extends @TB Date, @TC V extends @TE Cloneable> { }";
jjg@1521 53 }
jjg@1521 54
jjg@1521 55 @TADescriptions({
jjg@1521 56 @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
jjg@1521 57 @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
jjg@1521 58 @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
jjg@1521 59 @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
jjg@1521 60 @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
jjg@1521 61 })
jjg@1521 62 public String regularClassParameterized() {
jjg@1521 63 return "class Test<K extends @TA Map<String, @TB String>, V extends @TC List<@TD List<@TE Object>>> { }";
jjg@1521 64 }
jjg@1521 65
jjg@1521 66 @TADescriptions({
jjg@1521 67 @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
jjg@1521 68 @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
jjg@1521 69 @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
jjg@1521 70 @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
jjg@1521 71 @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
jjg@1521 72 @TADescription(annotation = "TF", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
jjg@1521 73 @TADescription(annotation = "TG", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
jjg@1521 74 })
jjg@1521 75 public String regularClassParameterized2() {
jjg@1521 76 return "class Test<K extends @TG Object & @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> { }";
jjg@1521 77 }
jjg@1521 78
jjg@1521 79 @TADescriptions({
jjg@1521 80 @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0),
jjg@1521 81 @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
jjg@1521 82 @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1),
jjg@1521 83 @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
jjg@1521 84 @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
jjg@1521 85 })
jjg@1521 86 public String abstractClass() {
jjg@1521 87 return "abstract class Test<@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> { }";
jjg@1521 88 }
jjg@1521 89
jjg@1521 90 @TADescriptions({
jjg@1521 91 @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
jjg@1521 92 @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
jjg@1521 93 @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
jjg@1521 94 @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
jjg@1521 95 @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
jjg@1521 96 @TADescription(annotation = "TF", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
jjg@1521 97 })
jjg@1521 98 public String abstractClassParameterized() {
jjg@1521 99 return "abstract class Test<K extends @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> { }";
jjg@1521 100 }
jjg@1521 101
jjg@1521 102 @TADescriptions({
jjg@1521 103 @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0),
jjg@1521 104 @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
jjg@1521 105 @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1),
jjg@1521 106 @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
jjg@1521 107 @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
jjg@1521 108 })
jjg@1521 109 public String regularInterface() {
jjg@1521 110 return "interface Test<@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> { }";
jjg@1521 111 }
jjg@1521 112
jjg@1521 113 @TADescriptions({
jjg@1521 114 @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
jjg@1521 115 @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
jjg@1521 116 @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
jjg@1521 117 @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
jjg@1521 118 @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
jjg@1521 119 })
jjg@1521 120 public String regularInterfaceParameterized() {
jjg@1521 121 return "interface Test<K extends @TA Map<String, @TB String>, V extends @TC List<@TD List<@TE Object>>> { }";
jjg@1521 122 }
jjg@1521 123
jjg@1521 124 @TADescriptions({
jjg@1521 125 @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
jjg@1521 126 @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
jjg@1521 127 @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
jjg@1521 128 @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
jjg@1521 129 @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
jjg@1521 130 @TADescription(annotation = "TF", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
jjg@1521 131 @TADescription(annotation = "TG", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
jjg@1521 132 })
jjg@1521 133 public String regularInterfaceParameterized2() {
jjg@1521 134 return "interface Test<K extends @TG Object & @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> { }";
jjg@1521 135 }
jjg@1521 136
jjg@1521 137 @TADescription(annotation = "TA", type = METHOD_RETURN)
jjg@1521 138 public String useInReturn1() {
jjg@1521 139 return "class Test<T> { @TA T m() { throw new RuntimeException(); } }";
jjg@1521 140 }
jjg@1521 141
jjg@1521 142 @TADescription(annotation = "TA", type = METHOD_RETURN, genericLocation = {3, 0})
jjg@1521 143 public String useInReturn2() {
jjg@1521 144 return "class Test<T> { Class<@TA T> m() { throw new RuntimeException(); } }";
jjg@1521 145 }
jjg@1521 146
jjg@1521 147 @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
jjg@1521 148 paramIndex = 0, genericLocation = {3, 0})
jjg@1521 149 public String useInParam1() {
jjg@1521 150 return "class Test<T> { void m(Class<@TA T> p) { throw new RuntimeException(); } }";
jjg@1521 151 }
jjg@1521 152
jjg@1521 153 @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
jjg@1521 154 paramIndex = 0, genericLocation = {3, 0})
jjg@1521 155 public String useInParam2() {
jjg@1521 156 return "class Test { void m(Class<@TA Object> p) { throw new RuntimeException(); } }";
jjg@1521 157 }
jjg@1521 158 }

mercurial