jjg@1521: /* jjg@1521: * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. jjg@1521: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@1521: * jjg@1521: * This code is free software; you can redistribute it and/or modify it jjg@1521: * under the terms of the GNU General Public License version 2 only, as jjg@1521: * published by the Free Software Foundation. jjg@1521: * jjg@1521: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@1521: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@1521: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@1521: * version 2 for more details (a copy is included in the LICENSE file that jjg@1521: * accompanied this code). jjg@1521: * jjg@1521: * You should have received a copy of the GNU General Public License version jjg@1521: * 2 along with this work; if not, write to the Free Software Foundation, jjg@1521: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@1521: * jjg@1521: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jjg@1521: * or visit www.oracle.com if you need additional information or have any jjg@1521: * questions. jjg@1521: */ jjg@1521: jjg@1521: import java.lang.annotation.*; jjg@1521: jjg@1521: /* jjg@1521: * @test jjg@1521: * @bug 8006775 jjg@1521: * @summary repeating type annotations are possible jjg@1521: * @author Werner Dietl jjg@1521: * @compile/fail/ref=RepeatingTypeAnnotations.out -XDrawDiagnostics RepeatingTypeAnnotations.java jjg@1521: */ jjg@1521: jjg@1521: class RepeatingTypeAnnotations { jjg@1521: // Fields jjg@1521: @RTA @RTA Object fr1 = null; jjg@1521: Object fr2 = new @RTA @RTA Object(); jjg@1521: // error jjg@1521: Object fs = new @TA @TA Object(); jjg@1521: // error jjg@1521: Object ft = new @TA @TA Object(); jjg@1521: Object fe = new @TA @TA Object(); jjg@1521: jjg@1521: // Local variables jjg@1521: Object foo() { jjg@1521: Object o = new @RTA @RTA Object(); jjg@1521: o = new @TA @RTA @RTA Object(); jjg@1521: o = new @RTA @TA @RTA Object(); jjg@1521: // error jjg@1521: o = new @RTA @TA @RTA @TA Object(); jjg@1521: // error jjg@1521: return new @TA @TA Object(); jjg@1521: } jjg@1521: jjg@1521: // Instance creation jjg@1521: Object bar() { jjg@1521: Object o = new @RTA @RTA MyList<@RTA @RTA Object>(); jjg@1521: o = new @TA @RTA MyList<@TA @RTA Object>(); jjg@1521: o = new @TA @RTA @RTA MyList<@RTA @TA @RTA Object>(); jjg@1521: // error jjg@1521: o = new @TA @TA MyList<@RTA @RTA Object>(); jjg@1521: // error jjg@1521: o = new @RTA @RTA MyList<@TA @TA Object>(); jjg@1521: // error jjg@1521: return new @TA @TA MyList<@RTA @RTA Object>(); jjg@1521: } jjg@1521: jjg@1521: // More tests jjg@1521: void oneArg() { jjg@1521: Object o = new @RTA @RTA Object(); jjg@1521: // error jjg@1521: o = new @TA @TA Object(); jjg@1521: o = new @RTA @TA @RTA Object(); jjg@1521: jjg@1521: o = new MyList<@RTA @RTA Object>(); jjg@1521: // error jjg@1521: o = new MyList<@TA @TA Object>(); jjg@1521: // error jjg@1521: o = new @TA @TA MyList<@TA @TA Object>(); jjg@1521: // error jjg@1521: this.<@TA @TA String>newList(); jjg@1521: jjg@1521: this.<@RTA @RTA MyList<@RTA @RTA String>>newList(); jjg@1521: // error jjg@1521: this.<@TA @TA MyList<@TA @TA String>>newList(); jjg@1521: jjg@1521: o = (@RTA @RTA MyList<@RTA @RTA Object>) o; jjg@1521: // error jjg@1521: o = (@TA @TA MyList<@TA @TA Object>) o; jjg@1521: jjg@1521: this.<@RTA @RTA String, @RTA @RTA Object>newMap(); jjg@1521: // error jjg@1521: this.<@TA @TA String, @TA @TA Object>newMap(); jjg@1521: jjg@1521: this.<@RTA @RTA String @RTA @RTA []>newList(); jjg@1521: // error jjg@1521: this.<@TA @TA String @TA @TA []>newList(); jjg@1521: jjg@1521: this.<@RTA @RTA String @RTA @RTA [] @RTA @RTA [], MyList<@RTA @RTA String> @RTA @RTA []>newMap(); jjg@1521: // error jjg@1521: this. @TA @TA []>newMap(); jjg@1521: } jjg@1521: jjg@1521: static void newList() { } jjg@1521: static void newMap() { } jjg@1521: } jjg@1521: jjg@1521: class MyList { } jjg@1521: jjg@1521: jjg@1521: @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) jjg@1521: @interface TA { } jjg@1521: jjg@1521: @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) jjg@1521: @interface TAs { jjg@1521: TA[] value(); jjg@1521: } jjg@1521: jjg@1521: @Repeatable(RTAs.class) jjg@1521: @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) jjg@1521: @interface RTA { } jjg@1521: jjg@1521: @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) jjg@1521: @interface RTAs { jjg@1521: RTA[] value(); jjg@1521: }