AllLocations.java revision 3070:b3ed4ac7cd91
1/* 2 * Copyright (c) 2014, 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 */ 23 24/* 25 * @test 26 * @bug 8027262 27 * @summary Stress test for type annotatons 28 * @compile AllLocations.java 29 */ 30 31import java.util.function.Function; 32import java.lang.annotation.*; 33import static java.lang.annotation.RetentionPolicy.*; 34import static java.lang.annotation.ElementType.*; 35import java.io.*; 36import java.lang.ref.WeakReference; 37 38public class AllLocations { 39 40 public class ParamStream<T> extends FileOutputStream { 41 public ParamStream(File f) throws FileNotFoundException { super(f); } 42 } 43 44 public class Inner<S> { 45 public Inner() {} 46 public <@A T> Inner(@B Object o) {} 47 public <@C T> Object g(Inner<@D S> this, Object @E [] o) { 48 return new @F int @G [5]; 49 } 50 } 51 52 public <@H T extends @I Inner<@J ? extends @K String>> AllLocations(Object o) {} 53 54 public @L Object @M [] @N [] arr = new @O Object @P [5] @Q [5]; 55 56 public Inner<@R ? extends @S Inner<@T ? extends @U Integer>> inner; 57 58 public Function func(@V AllLocations this) { 59 try (final ParamStream<@W Integer @X []> fs = new ParamStream<@Y Integer @Z []>(new File("testfile"))) { 60 return @AA AllLocations.Inner<@AB String>::<@AC Integer>new; 61 } catch(@AD Exception ex) { 62 return null; 63 } 64 } 65 66 public <@AE T extends @AF Inner<@AG Integer @AH []>> Function func2() { 67 arr[0][0] = new @AI Inner((@AJ Object) arr[0]); 68 return Ext.f((@AK Object) arr[0]) instanceof @AL Inner @AM [] @AN [] ? 69 @AO @AP Ext::<@AQ @AR Integer> f : 70 @AS @AT Ext::<@AU @AV Integer> f; 71 } 72 73 public Object func3(Object @AW [] arr) { 74 Inner<@AX ? extends @AY Inner<@AZ ? extends @BA Integer>> loc; 75 if (arr[0] instanceof @BB Inner @BC [] @BD []) 76 return this.<Inner<@BE Integer @BF []>> func4(); 77 else 78 return new <@BG Inner<@BH Integer>> @BI Inner<@BJ Inner<@BK Integer>>(null); 79 } 80 81 public <@BL T extends @BO Inner<@BP Integer @BQ []>> 82 @BR Inner<@BS Inner<@BT String>> func4() { 83 return (@BU Inner<@BV Inner<@BW String>>) 84 new <@BX Inner<@BY Integer>> @BZ Inner<@CA Inner<@CB String>>(null) {}; 85 } 86 87 { Inner<@CC ? extends @CD Inner<@CE ? extends @CF Integer>> loc = 88 new @CG Inner<@CH Inner<@CI Integer>>() {}; 89 Ext.func(Ext.func(@CJ WeakReference::new)); 90 Ext.func(Ext.func(@CK Ext::<@CL Integer>f)); 91 Ext.func((@CM Object a) -> { @CN Object b = a; return b; }); 92 } 93 94} 95 96class Ext { 97 public static <@CO T> Object f(Object o) { 98 return null; 99 } 100 public static Function func(Function f) { return f; } 101} 102 103 104@Retention(RUNTIME) @Target({TYPE_USE}) @interface A { } 105@Retention(RUNTIME) @Target({TYPE_USE}) @interface B { } 106@Retention(RUNTIME) @Target({TYPE_USE}) @interface C { } 107@Retention(RUNTIME) @Target({TYPE_USE}) @interface D { } 108@Retention(RUNTIME) @Target({TYPE_USE}) @interface E { } 109@Retention(RUNTIME) @Target({TYPE_USE}) @interface F { } 110@Retention(RUNTIME) @Target({TYPE_USE}) @interface G { } 111@Retention(RUNTIME) @Target({TYPE_USE}) @interface H { } 112@Retention(RUNTIME) @Target({TYPE_USE}) @interface I { } 113@Retention(RUNTIME) @Target({TYPE_USE}) @interface J { } 114@Retention(RUNTIME) @Target({TYPE_USE}) @interface K { } 115@Retention(RUNTIME) @Target({TYPE_USE}) @interface L { } 116@Retention(RUNTIME) @Target({TYPE_USE}) @interface M { } 117@Retention(RUNTIME) @Target({TYPE_USE}) @interface N { } 118@Retention(RUNTIME) @Target({TYPE_USE}) @interface O { } 119@Retention(RUNTIME) @Target({TYPE_USE}) @interface P { } 120@Retention(RUNTIME) @Target({TYPE_USE}) @interface Q { } 121@Retention(RUNTIME) @Target({TYPE_USE}) @interface R { } 122@Retention(RUNTIME) @Target({TYPE_USE}) @interface S { } 123@Retention(RUNTIME) @Target({TYPE_USE}) @interface T { } 124@Retention(RUNTIME) @Target({TYPE_USE}) @interface U { } 125@Retention(RUNTIME) @Target({TYPE_USE}) @interface V { } 126@Retention(RUNTIME) @Target({TYPE_USE}) @interface W { } 127@Retention(RUNTIME) @Target({TYPE_USE}) @interface X { } 128@Retention(RUNTIME) @Target({TYPE_USE}) @interface Y { } 129@Retention(RUNTIME) @Target({TYPE_USE}) @interface Z { } 130@Retention(RUNTIME) @Target({TYPE_USE}) @interface AA { } 131@Retention(RUNTIME) @Target({TYPE_USE}) @interface AB { } 132@Retention(RUNTIME) @Target({TYPE_USE}) @interface AC { } 133@Retention(RUNTIME) @Target({TYPE_USE}) @interface AD { } 134@Retention(RUNTIME) @Target({TYPE_USE}) @interface AE { } 135@Retention(RUNTIME) @Target({TYPE_USE}) @interface AF { } 136@Retention(RUNTIME) @Target({TYPE_USE}) @interface AG { } 137@Retention(RUNTIME) @Target({TYPE_USE}) @interface AH { } 138@Retention(RUNTIME) @Target({TYPE_USE}) @interface AI { } 139@Retention(RUNTIME) @Target({TYPE_USE}) @interface AJ { } 140@Retention(RUNTIME) @Target({TYPE_USE}) @interface AK { } 141@Retention(RUNTIME) @Target({TYPE_USE}) @interface AL { } 142@Retention(RUNTIME) @Target({TYPE_USE}) @interface AM { } 143@Retention(RUNTIME) @Target({TYPE_USE}) @interface AN { } 144@Retention(RUNTIME) @Target({TYPE_USE}) @interface AO { } 145@Retention(RUNTIME) @Target({TYPE_USE}) @interface AP { } 146@Retention(RUNTIME) @Target({TYPE_USE}) @interface AQ { } 147@Retention(RUNTIME) @Target({TYPE_USE}) @interface AR { } 148@Retention(RUNTIME) @Target({TYPE_USE}) @interface AS { } 149@Retention(RUNTIME) @Target({TYPE_USE}) @interface AT { } 150@Retention(RUNTIME) @Target({TYPE_USE}) @interface AU { } 151@Retention(RUNTIME) @Target({TYPE_USE}) @interface AV { } 152@Retention(RUNTIME) @Target({TYPE_USE}) @interface AW { } 153@Retention(RUNTIME) @Target({TYPE_USE}) @interface AX { } 154@Retention(RUNTIME) @Target({TYPE_USE}) @interface AY { } 155@Retention(RUNTIME) @Target({TYPE_USE}) @interface AZ { } 156@Retention(RUNTIME) @Target({TYPE_USE}) @interface BA { } 157@Retention(RUNTIME) @Target({TYPE_USE}) @interface BB { } 158@Retention(RUNTIME) @Target({TYPE_USE}) @interface BC { } 159@Retention(RUNTIME) @Target({TYPE_USE}) @interface BD { } 160@Retention(RUNTIME) @Target({TYPE_USE}) @interface BE { } 161@Retention(RUNTIME) @Target({TYPE_USE}) @interface BF { } 162@Retention(RUNTIME) @Target({TYPE_USE}) @interface BG { } 163@Retention(RUNTIME) @Target({TYPE_USE}) @interface BH { } 164@Retention(RUNTIME) @Target({TYPE_USE}) @interface BI { } 165@Retention(RUNTIME) @Target({TYPE_USE}) @interface BJ { } 166@Retention(RUNTIME) @Target({TYPE_USE}) @interface BK { } 167@Retention(RUNTIME) @Target({TYPE_USE}) @interface BL { } 168@Retention(RUNTIME) @Target({TYPE_USE}) @interface BM { } 169@Retention(RUNTIME) @Target({TYPE_USE}) @interface BN { } 170@Retention(RUNTIME) @Target({TYPE_USE}) @interface BO { } 171@Retention(RUNTIME) @Target({TYPE_USE}) @interface BP { } 172@Retention(RUNTIME) @Target({TYPE_USE}) @interface BQ { } 173@Retention(RUNTIME) @Target({TYPE_USE}) @interface BR { } 174@Retention(RUNTIME) @Target({TYPE_USE}) @interface BS { } 175@Retention(RUNTIME) @Target({TYPE_USE}) @interface BT { } 176@Retention(RUNTIME) @Target({TYPE_USE}) @interface BU { } 177@Retention(RUNTIME) @Target({TYPE_USE}) @interface BV { } 178@Retention(RUNTIME) @Target({TYPE_USE}) @interface BW { } 179@Retention(RUNTIME) @Target({TYPE_USE}) @interface BX { } 180@Retention(RUNTIME) @Target({TYPE_USE}) @interface BY { } 181@Retention(RUNTIME) @Target({TYPE_USE}) @interface BZ { } 182@Retention(RUNTIME) @Target({TYPE_USE}) @interface CA { } 183@Retention(RUNTIME) @Target({TYPE_USE}) @interface CB { } 184@Retention(RUNTIME) @Target({TYPE_USE}) @interface CC { } 185@Retention(RUNTIME) @Target({TYPE_USE}) @interface CD { } 186@Retention(RUNTIME) @Target({TYPE_USE}) @interface CE { } 187@Retention(RUNTIME) @Target({TYPE_USE}) @interface CF { } 188@Retention(RUNTIME) @Target({TYPE_USE}) @interface CG { } 189@Retention(RUNTIME) @Target({TYPE_USE}) @interface CH { } 190@Retention(RUNTIME) @Target({TYPE_USE}) @interface CI { } 191@Retention(RUNTIME) @Target({TYPE_USE}) @interface CJ { } 192@Retention(RUNTIME) @Target({TYPE_USE}) @interface CK { } 193@Retention(RUNTIME) @Target({TYPE_USE}) @interface CL { } 194@Retention(RUNTIME) @Target({TYPE_USE}) @interface CM { } 195@Retention(RUNTIME) @Target({TYPE_USE}) @interface CN { } 196@Retention(RUNTIME) @Target({TYPE_USE}) @interface CO { } 197