Fields.java revision 2454:f434ca8aface
1168054Sflz/* 2168054Sflz * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. 3168266Sgabor * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4168266Sgabor * 5168266Sgabor * This code is free software; you can redistribute it and/or modify it 6168266Sgabor * under the terms of the GNU General Public License version 2 only, as 7168266Sgabor * published by the Free Software Foundation. 8168266Sgabor * 9168266Sgabor * This code is distributed in the hope that it will be useful, but WITHOUT 10168266Sgabor * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11168054Sflz * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12168054Sflz * version 2 for more details (a copy is included in the LICENSE file that 13168064Sflz * accompanied this code). 14168064Sflz * 15168064Sflz * You should have received a copy of the GNU General Public License version 16168064Sflz * 2 along with this work; if not, write to the Free Software Foundation, 17168064Sflz * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18168064Sflz * 19168064Sflz * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20168064Sflz * or visit www.oracle.com if you need additional information or have any 21168064Sflz * questions. 22168064Sflz */ 23168064Sflz 24168064Sflzimport static com.sun.tools.classfile.TypeAnnotation.TargetType.*; 25168064Sflz 26168064Sflz/* 27168054Sflz * @test 28168054Sflz * @bug 8042451 29168064Sflz * @summary Test population of reference info for field 30168054Sflz * @compile -g Driver.java ReferenceInfoUtil.java Fields.java 31168188Sgabor * @run main Driver Fields 32168357Syar */ 33168673Sjulianpublic class Fields { 34168188Sgabor // field types 35168263Sru @TADescription(annotation = "TA", type = FIELD) 36168194Simp public String fieldAsPrimitive() { 37168357Syar return "@TA int test;"; 38168188Sgabor } 39168188Sgabor 40168188Sgabor @TADescription(annotation = "TA", type = FIELD) 41168188Sgabor public String fieldAsObject() { 42168188Sgabor return "@TA Object test;"; 43168188Sgabor } 44168188Sgabor 45168202Sume @TADescription(annotation = "TA", type = FIELD) 46168188Sgabor @TADescription(annotation = "TB", type = FIELD, 47168188Sgabor genericLocation = { 3, 0 }) 48168202Sume @TADescription(annotation = "TC", type = FIELD, 49168188Sgabor genericLocation = { 3, 1 }) 50168127Sdwmalone @TADescription(annotation = "TD", type = FIELD, 51168054Sflz genericLocation = { 3, 1, 3, 0 }) 52168054Sflz public String fieldAsParametrized() { 53168054Sflz return "@TA Map<@TB String, @TC List<@TD String>> test;"; 54168054Sflz } 55168215Sache 56168149Simp @TADescription(annotation = "TA", type = FIELD) 57168149Simp @TADescription(annotation = "TB", type = FIELD, 58168179Sgabor genericLocation = { 0, 0 }) 59168083Sjkim @TADescription(annotation = "TC", type = FIELD, 60176001Santoine genericLocation = { 0, 0, 0, 0 }) 61168123Snetchild public String fieldAsArray() { 62188752Savg return "@TC String @TA [] @TB [] test;"; 63168080Smlaier } 64168195Sbenno 65168131Sbmah @TADescription(annotation = "TA", type = FIELD) 66168183Sgabor @TADescription(annotation = "TB", type = FIELD, 67168080Smlaier genericLocation = { 0, 0 }) 68168309Sbrian @TADescription(annotation = "TC", type = FIELD, 69168308Sbrian genericLocation = { 0, 0, 0, 0 }) 70168150Srwatson public String fieldAsArrayOld() { 71168149Simp return "@TC String test @TA [] @TB [];"; 72168150Srwatson } 73168263Sru 74180232Scokane @TADescriptions({}) 75168054Sflz public String fieldWithDeclarationAnnotatin() { 76168183Sgabor return "@Decl String test;"; 77168674Sjulian } 78168060Sdds 79168108Srafan @TADescriptions({}) 80168083Sjkim public String fieldWithNoTargetAnno() { 81168153Simp return "@A String test;"; 82168080Smlaier } 83168149Simp 84168127Sdwmalone // Smoke tests 85179207Sed @TADescription(annotation = "TA", type = FIELD) 86175201Sedwin public String interfaceFieldAsObject() { 87168263Sru return "interface %TEST_CLASS_NAME% { @TA String test = null; }"; 88168180Srwatson } 89168149Simp 90179830Seri @TADescription(annotation = "TA", type = FIELD) 91189932Sfabient public String abstractFieldAsObject() { 92168127Sdwmalone return "abstract class %TEST_CLASS_NAME% { @TA String test; }"; 93169252Sfjoe } 94168054Sflz 95168370Sgad @TADescription(annotation = "TA", type = FIELD) 96168631Sticso @TADescription(annotation = "TB", type = FIELD, 97200313Sgavin genericLocation = { 3, 0 }) 98168183Sgabor @TADescription(annotation = "TC", type = FIELD, 99168672Smav genericLocation = { 3, 1 }) 100168150Srwatson @TADescription(annotation = "TD", type = FIELD, 101168195Sbenno genericLocation = { 3, 1, 3, 0 }) 102168081Sle public String interfaceFieldAsParametrized() { 103168154Sgshapiro return "interface %TEST_CLASS_NAME% { @TA Map<@TB String, @TC List<@TD String>> test = null; }"; 104168127Sdwmalone } 105168144Simp 106179767Sivoras 107168308Sbrian @TADescription(annotation = "TA", type = FIELD) 108187937Sjamie @TADescription(annotation = "TB", type = FIELD, 109168183Sgabor genericLocation = { 3, 0 }) 110197776Sjh @TADescription(annotation = "TC", type = FIELD, 111192607Sjilles genericLocation = { 3, 1 }) 112168150Srwatson @TADescription(annotation = "TD", type = FIELD, 113169252Sfjoe genericLocation = { 3, 1, 3, 0 }) 114182017Sjhb public String staticFieldAsParametrized() { 115168153Simp return "static @TA Map<@TB String, @TC List<@TD String>> test;"; 116168083Sjkim } 117172389Skaiw 118168111Smatteo @TADescription(annotation = "RTAs", type = FIELD) 119168149Simp public String fieldAsPrimitiveRepeatableAnnotation() { 120168151Sphk return "@RTA @RTA int test;"; 121168149Simp } 122168673Sjulian 123172389Skaiw @TADescription(annotation = "RTAs", type = FIELD) 124168180Srwatson public String fieldAsObjectRepeatableAnnotation() { 125168535Skevlo return "@RTA @RTA Object test;"; 126200356Skib } 127168150Srwatson 128168081Sle @TADescription(annotation = "RTAs", type = FIELD) 129168180Srwatson @TADescription(annotation = "RTBs", type = FIELD, 130183643Slstewart genericLocation = { 3, 0 }) 131172984Slulf @TADescription(annotation = "RTCs", type = FIELD, 132180222Smarcel genericLocation = { 3, 1 }) 133192775Smarkm @TADescription(annotation = "RTDs", type = FIELD, 134168167Sphilip genericLocation = { 3, 1, 3, 0 }) 135168918Sbrueffer public String fieldAsParametrizedRepeatableAnnotation() { 136168142Srwatson return "@RTA @RTA Map<@RTB @RTB String, @RTC @RTC List<@RTD @RTD String>> test;"; 137168672Smav } 138168263Sru 139168143Smjacob @TADescription(annotation = "RTAs", type = FIELD) 140168080Smlaier @TADescription(annotation = "RTBs", type = FIELD, 141168149Simp genericLocation = { 0, 0 }) 142168130Sdelphij @TADescription(annotation = "RTCs", type = FIELD, 143198183Sneel genericLocation = { 0, 0, 0, 0 }) 144168123Snetchild public String fieldAsArrayRepeatableAnnotation() { 145168171Sphilip return "@RTC @RTC String @RTA @RTA [] @RTB @RTB [] test;"; 146194197Snork } 147193775Snp 148180227Snwhitehorn @TADescription(annotation = "RTAs", type = FIELD) 149168097Sle @TADescription(annotation = "RTBs", type = FIELD, 150176318Solli genericLocation = { 0, 0 }) 151168149Simp @TADescription(annotation = "RTCs", type = FIELD, 152168127Sdwmalone genericLocation = { 0, 0, 0, 0 }) 153168183Sgabor public String fieldAsArrayOldRepeatableAnnotation() { 154168111Smatteo return "@RTC @RTC String test @RTA @RTA [] @RTB @RTB [];"; 155168151Sphk } 156185052Spho 157168321Spjd // Smoke tests 158168183Sgabor @TADescription(annotation = "RTAs", type = FIELD) 159168101Sandre public String interfaceFieldAsObjectRepeatableAnnotation() { 160168108Srafan return "interface %TEST_CLASS_NAME% { @RTA @RTA String test = null; }"; 161168149Simp } 162168149Simp 163168149Simp @TADescription(annotation = "RTAs", type = FIELD) 164183282Srnoland public String abstractFieldAsObjectRepeatableAnnotation() { 165182009Sroberto return "abstract class %TEST_CLASS_NAME% { @RTA @RTA String test; }"; 166172343Srpaulo } 167168140Srwatson 168168118Srse @TADescription(annotation = "RTAs", type = FIELD) 169168263Sru @TADescription(annotation = "RTBs", type = FIELD, 170168140Srwatson genericLocation = { 3, 0 }) 171168080Smlaier @TADescription(annotation = "RTCs", type = FIELD, 172168149Simp genericLocation = { 3, 1 }) 173171026Sscf @TADescription(annotation = "RTDs", type = FIELD, 174168081Sle genericLocation = { 3, 1, 3, 0 }) 175168167Sphilip public String interfaceFieldAsParametrizedRepeatableAnnotation() { 176168149Simp return "interface %TEST_CLASS_NAME% { @RTA @RTA Map<@RTB @RTB String, @RTC @RTC List<@RTD @RTD String>> test = null; }"; 177168115Ssimon } 178168263Sru 179191822Ssnb 180180366Ssson @TADescription(annotation = "RTAs", type = FIELD) 181168198Sume @TADescription(annotation = "RTBs", type = FIELD, 182168150Srwatson genericLocation = { 3, 0 }) 183168149Simp @TADescription(annotation = "RTCs", type = FIELD, 184168080Smlaier genericLocation = { 3, 1 }) 185168631Sticso @TADescription(annotation = "RTDs", type = FIELD, 186182006Strasz genericLocation = { 3, 1, 3, 0 }) 187168180Srwatson public String staticFieldAsParametrizedRepeatableAnnotation() { 188193759Stuexen return "static @RTA @RTA Map<@RTB @RTB String, @RTC @RTC List<@RTD @RTD String>> test;"; 189168198Sume } 190180705Svanhu} 191184913Sversus