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