1 /* 2 * Copyright (c) 2013, 2015, 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 8004822 27 * @author mnunez 28 * @summary Language model api test basics for repeating annotations 29 * @library /tools/javac/lib 30 * @library supportingAnnotations 31 * @modules java.compiler 32 * jdk.compiler 33 * @build JavacTestingAbstractProcessor ElementRepAnnoTester 34 * @compile -processor ElementRepAnnoTester -proc:only MixSingularAndUnofficialContainerBasicTest.java 35 */ 36 37 @ExpectedBase( 38 value = Foo.class, 39 getAnnotation = "@Foo(value=0)", 40 getAnnotationsByType = {"@Foo(value=0)"}, 41 getAllAnnotationMirrors = { 42 "@Foo(0)", 43 "@UnofficialContainer({@Foo(1), @Foo(2)})", 44 "ExpectedBase", 45 "ExpectedContainer" 46 }, 47 getAnnotationMirrors = { 48 "@Foo(0)", 49 "@UnofficialContainer({@Foo(1), @Foo(2)})", 50 "ExpectedBase", 51 "ExpectedContainer" 52 }) 53 @ExpectedContainer( 54 value = UnofficialContainer.class, 55 getAnnotation = "@UnofficialContainer(" 56 + "value=[@Foo(value=1), @Foo(value=2)])", 57 getAnnotationsByType = {"@UnofficialContainer(" 58 + "value=[@Foo(value=1), @Foo(value=2)])"}) 59 @Foo(value = 0) 60 @UnofficialContainer(value = {@Foo(value = 1), @Foo(value = 2)}) 61 class MixSingularAndUnofficialContainerBasicTest { 62 63 @ExpectedBase( 64 value = Foo.class, 65 getAnnotation = "@Foo(value=0)", 66 getAnnotationsByType = {"@Foo(value=0)"}, 67 getAllAnnotationMirrors = { 68 "@Foo(0)", 69 "@UnofficialContainer({@Foo(1), @Foo(2)})", 70 "ExpectedBase", 71 "ExpectedContainer" 72 }, 73 getAnnotationMirrors = { 74 "@Foo(0)", 75 "@UnofficialContainer({@Foo(1), @Foo(2)})", 76 "ExpectedBase", 77 "ExpectedContainer" 78 }) 79 @ExpectedContainer( 80 value = UnofficialContainer.class, 81 getAnnotation = "@UnofficialContainer(" 82 + "value=[@Foo(value=1), @Foo(value=2)])", 83 getAnnotationsByType = {"@UnofficialContainer(" 84 + "value=[@Foo(value=1), @Foo(value=2)])"}) 85 @Foo(value = 0) 86 @UnofficialContainer(value = {@Foo(value = 1), @Foo(value = 2)}) 87 int testField = 0; 88 89 @ExpectedBase( 90 value = Foo.class, 91 getAnnotation = "@Foo(value=0)", 92 getAnnotationsByType = {"@Foo(value=0)"}, 93 getAllAnnotationMirrors = { 94 "@Foo(0)", 95 "@UnofficialContainer({@Foo(1), @Foo(2)})", 96 "ExpectedBase", 97 "ExpectedContainer" 98 }, 99 getAnnotationMirrors = { 100 "@Foo(0)", 101 "@UnofficialContainer({@Foo(1), @Foo(2)})", 102 "ExpectedBase", 103 "ExpectedContainer" 104 }) 105 @ExpectedContainer( 106 value = UnofficialContainer.class, 107 getAnnotation = "@UnofficialContainer(" 108 + "value=[@Foo(value=1), @Foo(value=2)])", 109 getAnnotationsByType = {"@UnofficialContainer(" 110 + "value=[@Foo(value=1), @Foo(value=2)])"}) 111 @Foo(value = 0) 112 @UnofficialContainer(value = {@Foo(value = 1), @Foo(value = 2)}) 113 void testMethod() {} 114 } | 1 /* 2 * Copyright (c) 2013, 2016, 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 8004822 8163113 27 * @author mnunez 28 * @summary Language model api test basics for repeating annotations 29 * @library /tools/javac/lib 30 * @library supportingAnnotations 31 * @modules java.compiler 32 * jdk.compiler 33 * @build JavacTestingAbstractProcessor ElementRepAnnoTester 34 * @compile -processor ElementRepAnnoTester -proc:only MixSingularAndUnofficialContainerBasicTest.java 35 */ 36 37 @ExpectedBase( 38 value = Foo.class, 39 getAnnotation = "@Foo(value=0)", 40 getAnnotationsByType = {"@Foo(value=0)"}, 41 getAllAnnotationMirrors = { 42 "@Foo(0)", 43 "@UnofficialContainer({@Foo(1), @Foo(2)})", 44 "ExpectedBase", 45 "ExpectedContainer" 46 }, 47 getAnnotationMirrors = { 48 "@Foo(0)", 49 "@UnofficialContainer({@Foo(1), @Foo(2)})", 50 "ExpectedBase", 51 "ExpectedContainer" 52 }) 53 @ExpectedContainer( 54 value = UnofficialContainer.class, 55 getAnnotation = "@UnofficialContainer(" 56 + "value={@Foo(value=1), @Foo(value=2)})", 57 getAnnotationsByType = {"@UnofficialContainer(" 58 + "value={@Foo(value=1), @Foo(value=2)})"}) 59 @Foo(value = 0) 60 @UnofficialContainer(value = {@Foo(value = 1), @Foo(value = 2)}) 61 class MixSingularAndUnofficialContainerBasicTest { 62 63 @ExpectedBase( 64 value = Foo.class, 65 getAnnotation = "@Foo(value=0)", 66 getAnnotationsByType = {"@Foo(value=0)"}, 67 getAllAnnotationMirrors = { 68 "@Foo(0)", 69 "@UnofficialContainer({@Foo(1), @Foo(2)})", 70 "ExpectedBase", 71 "ExpectedContainer" 72 }, 73 getAnnotationMirrors = { 74 "@Foo(0)", 75 "@UnofficialContainer({@Foo(1), @Foo(2)})", 76 "ExpectedBase", 77 "ExpectedContainer" 78 }) 79 @ExpectedContainer( 80 value = UnofficialContainer.class, 81 getAnnotation = "@UnofficialContainer(" 82 + "value={@Foo(value=1), @Foo(value=2)})", 83 getAnnotationsByType = {"@UnofficialContainer(" 84 + "value={@Foo(value=1), @Foo(value=2)})"}) 85 @Foo(value = 0) 86 @UnofficialContainer(value = {@Foo(value = 1), @Foo(value = 2)}) 87 int testField = 0; 88 89 @ExpectedBase( 90 value = Foo.class, 91 getAnnotation = "@Foo(value=0)", 92 getAnnotationsByType = {"@Foo(value=0)"}, 93 getAllAnnotationMirrors = { 94 "@Foo(0)", 95 "@UnofficialContainer({@Foo(1), @Foo(2)})", 96 "ExpectedBase", 97 "ExpectedContainer" 98 }, 99 getAnnotationMirrors = { 100 "@Foo(0)", 101 "@UnofficialContainer({@Foo(1), @Foo(2)})", 102 "ExpectedBase", 103 "ExpectedContainer" 104 }) 105 @ExpectedContainer( 106 value = UnofficialContainer.class, 107 getAnnotation = "@UnofficialContainer(" 108 + "value={@Foo(value=1), @Foo(value=2)})", 109 getAnnotationsByType = {"@UnofficialContainer(" 110 + "value={@Foo(value=1), @Foo(value=2)})"}) 111 @Foo(value = 0) 112 @UnofficialContainer(value = {@Foo(value = 1), @Foo(value = 2)}) 113 void testMethod() {} 114 } |