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 8001457 8027477 27 * @author sogoel 28 * @summary Reflection api tests 29 * @modules jdk.compiler 30 * @build Helper 31 * @compile expectedFiles/ExpectedBase.java expectedFiles/ExpectedContainer.java 32 * @run main ReflectionTest 33 */ 34 import java.io.File; 35 import java.io.IOException; 36 import java.lang.annotation.Annotation; 37 import java.net.MalformedURLException; 38 import java.net.URL; 39 import java.net.URLClassLoader; 40 import java.util.ArrayList; 41 import java.util.Arrays; 42 import java.util.List; 43 44 import javax.tools.DiagnosticCollector; 45 import javax.tools.JavaFileObject; 46 466 String superClassContents = srcType.getTemplate() 467 .replace("#CN", SUPERCLASS).replace("#REPLACE", replaceVal); 468 469 // Contents for SubClass that extends SuperClass 470 anno = "@Foo(2)"; 471 replaceVal = expectedVals + "\n" + anno; 472 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 473 .replace("#CN", className).replace("#SN", SUPERCLASS) 474 .replace("#REPLACE", replaceVal); 475 476 contents = superClassContents + subClassContents; 477 srcFileObj = Helper.getFile(className, contents); 478 files = Arrays.asList(srcFileObj); 479 } 480 return files; 481 } 482 }, 483 BasicContainer_Legacy( 484 "@ExpectedBase(value = Foo.class, " 485 + "getAnnotationVal = \"NULL\"," 486 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 487 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 488 + "getDeclAnnoVal = \"NULL\", " + "getAnnosArgs = {}, " 489 + "getDeclAnnosArgs = {} )", 490 "@ExpectedContainer(value=FooContainer.class, " 491 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 492 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 493 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 494 + "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 495 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 496 + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"} )") { 497 498 @Override 499 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 500 String className) { 501 String anno = ""; 502 String replaceVal = ""; 503 String testSrc = ""; 504 String pkgInfoContents = ""; 505 String contents = ""; 506 507 JavaFileObject pkgFileObj = null; 508 JavaFileObject srcFileObj = null; 509 Iterable<? extends JavaFileObject> files = null; 510 511 String expectedVals = "\n" + getExpectedBase() + "\n" 512 + getExpectedContainer() + "\n"; 513 StringBuilder commonStmts = new StringBuilder(); 514 515 anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 516 commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal()) 566 567 @ExpectedBase 568 @ExpectedContainer 569 @FooContainer(value = {@Foo(1), @Foo(2)}) 570 class A {} 571 */ 572 replaceVal = expectedVals + anno; 573 testSrc = srcType.getTemplate().replace("#CN", className) 574 .replace("#REPLACE", replaceVal); 575 contents = commonStmts + testSrc; 576 srcFileObj = Helper.getFile(className, contents); 577 files = Arrays.asList(srcFileObj); 578 } 579 return files; 580 } 581 }, 582 SingleAndContainerOnSuper_Legacy( 583 "@ExpectedBase(value = Foo.class, " 584 + "getAnnotationVal = \"@Foo(value=0)\"," 585 + "getAnnotationsVals = {" 586 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 587 + "getDeclAnnosVals = {" 588 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 589 + "getDeclAnnoVal = \"@Foo(value=0)\", " 590 + "getAnnosArgs = {\"@Foo(value=0)\"}, " 591 + "getDeclAnnosArgs = {\"@Foo(value=0)\"} )", 592 "@ExpectedContainer(value=FooContainer.class, " 593 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 594 + "getAnnotationsVals = {" 595 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 596 + "getDeclAnnosVals = {" 597 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 598 + "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 599 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 600 + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"} )") { 601 602 @Override 603 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 604 String className) { 605 String anno = ""; 606 String replaceVal = ""; 607 String testSrc = ""; 608 String pkgInfoContents = ""; 609 String contents = ""; 610 611 JavaFileObject pkgFileObj = null; 612 JavaFileObject srcFileObj = null; 613 Iterable<? extends JavaFileObject> files = null; 614 615 String expectedVals = "\n" + getExpectedBase() + "\n" 616 + getExpectedContainer() + "\n"; 617 StringBuilder commonStmts = new StringBuilder(); 618 619 anno = Helper.ContentVars.BASEANNO.getVal() + 620 Helper.ContentVars.LEGACYCONTAINER.getVal(); 674 @ExpectedBase 675 @ExpectedContainer 676 @Foo(0) 677 @FooContainer(value = {@Foo(1), @Foo(2)}) 678 class A {} 679 */ 680 replaceVal = expectedVals + anno; 681 testSrc = srcType.getTemplate().replace("#CN", className) 682 .replace("#REPLACE", replaceVal); 683 contents = commonStmts + testSrc; 684 685 srcFileObj = Helper.getFile(className, contents); 686 files = Arrays.asList(srcFileObj); 687 } 688 return files; 689 } 690 }, 691 BasicContainer_Inherited_Legacy( 692 "@ExpectedBase(value = Foo.class, " 693 + "getAnnotationVal = \"NULL\"," 694 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 695 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, " 696 + "getDeclAnnoVal = \"NULL\", " 697 + "getAnnosArgs = {}, " 698 + "getDeclAnnosArgs = {} )", 699 "@ExpectedContainer(value=FooContainer.class, " 700 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 701 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 702 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, " 703 + "getDeclAnnoVal = \"NULL\", " 704 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 705 + "getDeclAnnosArgs = {} )") { 706 707 @Override 708 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 709 String className) { 710 String anno = ""; 711 String replaceVal = ""; 712 String contents = ""; 713 JavaFileObject srcFileObj = null; 714 Iterable<? extends JavaFileObject> files = null; 715 716 String expectedVals = "\n" + getExpectedBase() + "\n" 717 + getExpectedContainer() + "\n"; 718 StringBuilder commonStmts = getCommonStmts(false); 719 720 /* 721 Sample testSrc: 722 @Retention(RetentionPolicy.RUNTIME) 723 @Inherited 724 @interface Foo {int value() default Integer.MAX_VALUE;} 748 .replace("#REPLACE", replaceVal); 749 750 // Contents for SubClass that extends SuperClass 751 replaceVal = expectedVals; 752 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 753 .replace("#CN", className) 754 .replace("#SN", SUPERCLASS) 755 .replace("#REPLACE", replaceVal); 756 757 contents = superClassContents + subClassContents; 758 srcFileObj = Helper.getFile(className, contents); 759 files = Arrays.asList(srcFileObj); 760 } 761 return files; 762 } 763 }, 764 ContainerOnSuperSingleOnSub_Inherited_Legacy( 765 "@ExpectedBase(value=Foo.class, " 766 + "getAnnotationVal = \"@Foo(value=0)\", " 767 + "getAnnotationsVals = {" 768 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", \"@Foo(value=0)\"}, " 769 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 770 + "getDeclAnnoVal = \"@Foo(value=0)\"," 771 + "getAnnosArgs = {\"@Foo(value=0)\"}," 772 + "getDeclAnnosArgs = {\"@Foo(value=0)\"})", 773 "@ExpectedContainer(value=FooContainer.class, " 774 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 775 + "getAnnotationsVals = {" 776 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", \"@Foo(value=0)\"}, " 777 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 778 + "getDeclAnnoVal = \"NULL\"," 779 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 780 + "getDeclAnnosArgs = {})") { 781 782 @Override 783 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 784 String className) { 785 String anno = ""; 786 String replaceVal = ""; 787 String contents = ""; 788 JavaFileObject srcFileObj = null; 789 Iterable<? extends JavaFileObject> files = null; 790 791 String expectedVals = "\n" + getExpectedBase() + "\n" 792 + getExpectedContainer() + "\n"; 793 StringBuilder commonStmts = getCommonStmts(false); 794 795 /* 796 Sample testSrc: 797 @Retention(RetentionPolicy.RUNTIME) 798 @Inherited 799 @interface Foo {int value() default Integer.MAX_VALUE;} 827 anno = Helper.ContentVars.BASEANNO.getVal(); 828 replaceVal = expectedVals + "\n" + anno; 829 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 830 .replace("#CN", className) 831 .replace("#SN", SUPERCLASS) 832 .replace("#REPLACE", replaceVal); 833 834 contents = superClassContents + subClassContents; 835 srcFileObj = Helper.getFile(className, contents); 836 files = Arrays.asList(srcFileObj); 837 } 838 return files; 839 } 840 }, 841 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 842 // fail with ordering issues 843 ContainerAndSingleOnSuperSingleOnSub_Inherited_Legacy( 844 "@ExpectedBase(value=Foo.class, " 845 + "getAnnotationVal = \"@Foo(value=0)\", " 846 + "getAnnotationsVals = {" 847 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", \"@Foo(value=0)\"}, " 848 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 849 + "getDeclAnnoVal = \"@Foo(value=0)\"," 850 + "getAnnosArgs = {\"@Foo(value=0)\"}," 851 + "getDeclAnnosArgs = {\"@Foo(value=0)\"})", 852 "@ExpectedContainer(value=FooContainer.class, " 853 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 854 + "getAnnotationsVals = {" 855 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", \"@Foo(value=0)\"}, " 856 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 857 + "getDeclAnnoVal = \"NULL\"," 858 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 859 + "getDeclAnnosArgs = {})") { 860 861 @Override 862 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 863 String className) { 864 String anno = ""; 865 String replaceVal = ""; 866 String contents = ""; 867 JavaFileObject srcFileObj = null; 868 Iterable<? extends JavaFileObject> files = null; 869 870 String expectedVals = "\n" + getExpectedBase() + "\n" 871 + getExpectedContainer() + "\n"; 872 StringBuilder commonStmts = getCommonStmts(false); 873 874 /* 875 Sample testSrc: 876 @Retention(RetentionPolicy.RUNTIME) 877 @Inherited 878 @interface Foo {int value() default Integer.MAX_VALUE;} 906 // Contents for SubClass that extends SuperClass 907 anno = Helper.ContentVars.BASEANNO.getVal(); 908 replaceVal = expectedVals + "\n" + anno; 909 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 910 .replace("#CN", className).replace("#SN", SUPERCLASS) 911 .replace("#REPLACE", replaceVal); 912 913 contents = superClassContents + subClassContents; 914 srcFileObj = Helper.getFile(className, contents); 915 files = Arrays.asList(srcFileObj); 916 } 917 return files; 918 } 919 }, 920 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 921 // fail with ordering issues 922 SingleOnSuperContainerOnSub_Inherited_Legacy( 923 "@ExpectedBase(value=Foo.class, " 924 + "getAnnotationVal = \"@Foo(value=0)\", " 925 + "getAnnotationsVals = {" 926 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 927 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 928 + "getDeclAnnoVal = \"NULL\"," 929 + "getAnnosArgs = {\"@Foo(value=0)\"}," 930 + "getDeclAnnosArgs = {})", 931 "@ExpectedContainer(value=FooContainer.class, " 932 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 933 + "getAnnotationsVals = {" 934 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 935 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 936 + "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"," 937 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 938 + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"})") { 939 940 @Override 941 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 942 String className) { 943 String anno = ""; 944 String replaceVal = ""; 945 String contents = ""; 946 947 JavaFileObject srcFileObj = null; 948 Iterable<? extends JavaFileObject> files = null; 949 950 String expectedVals = "\n" + getExpectedBase() + "\n" 951 + getExpectedContainer() + "\n"; 952 StringBuilder commonStmts = getCommonStmts(false); 953 954 /* 955 Sample testSrc: 956 @Retention(RetentionPolicy.RUNTIME) 957 @Inherited 958 @interface Foo {int value() default Integer.MAX_VALUE;} 983 //Contents for SubClass that extends SuperClass 984 anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 985 replaceVal = expectedVals + "\n" + anno; 986 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 987 .replace("#CN", className).replace("#SN", SUPERCLASS) 988 .replace("#REPLACE", replaceVal); 989 990 contents = superClassContents + subClassContents; 991 srcFileObj = Helper.getFile(className, contents); 992 files = Arrays.asList(srcFileObj); 993 } 994 return files; 995 } 996 }, 997 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 998 // fail with ordering issues 999 SingleOnSuperContainerAndSingleOnSub_Inherited_Legacy( 1000 "@ExpectedBase(value=Foo.class, " 1001 + "getAnnotationVal = \"@Foo(value=3)\", " 1002 + "getAnnotationsVals = {" 1003 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", \"@Foo(value=3)\"}, " 1004 + "getDeclAnnosVals = {" 1005 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", \"@Foo(value=3)\"}," 1006 + "getDeclAnnoVal = \"@Foo(value=3)\"," 1007 + "getAnnosArgs = {\"@Foo(value=3)\"}," 1008 + "getDeclAnnosArgs = {\"@Foo(value=3)\"})", 1009 "@ExpectedContainer(value=FooContainer.class, " 1010 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 1011 + "getAnnotationsVals = {" 1012 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", \"@Foo(value=3)\"}, " 1013 + "getDeclAnnosVals = {" 1014 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", \"@Foo(value=3)\"}," 1015 + "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"," 1016 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1017 + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"})") { 1018 1019 @Override 1020 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1021 String className) { 1022 String anno = ""; 1023 String replaceVal = ""; 1024 String contents = ""; 1025 1026 JavaFileObject srcFileObj = null; 1027 Iterable<? extends JavaFileObject> files = null; 1028 1029 String expectedVals = "\n" + getExpectedBase() + "\n" 1030 + getExpectedContainer() + "\n"; 1031 StringBuilder commonStmts = getCommonStmts(false); 1032 1033 /* 1034 Sample testSrc: 1035 @Retention(RetentionPolicy.RUNTIME) 1036 @Inherited 1037 @interface Foo {int value() default Integer.MAX_VALUE;} 1060 .replace("#REPLACE", replaceVal); 1061 1062 //Contents for SubClass that extends SuperClass 1063 anno = Helper.ContentVars.LEGACYCONTAINER.getVal() 1064 + "@Foo(3)"; 1065 replaceVal = expectedVals + "\n" + anno; 1066 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1067 .replace("#CN", className).replace("#SN", SUPERCLASS) 1068 .replace("#REPLACE", replaceVal); 1069 1070 contents = superClassContents + subClassContents; 1071 srcFileObj = Helper.getFile(className, contents); 1072 files = Arrays.asList(srcFileObj); 1073 } 1074 return files; 1075 } 1076 }, 1077 BasicRepeatable( 1078 "@ExpectedBase(value=Foo.class, " 1079 + "getAnnotationVal = \"NULL\", " 1080 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\" }, " 1081 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1082 + "getDeclAnnoVal = \"NULL\"," 1083 + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}," 1084 + "getDeclAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"})", 1085 "@ExpectedContainer(value=FooContainer.class, " 1086 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"," 1087 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1088 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1089 + "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"," 1090 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1091 + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"} )") { 1092 1093 @Override 1094 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1095 String className) { 1096 String anno = ""; 1097 String replaceVal = ""; 1098 String testSrc = ""; 1099 String pkgInfoContents = ""; 1100 String contents = ""; 1101 1102 JavaFileObject pkgFileObj = null; 1103 JavaFileObject srcFileObj = null; 1104 Iterable<? extends JavaFileObject> files = null; 1105 1106 String expectedVals = "\n" + getExpectedBase() + "\n" 1107 + getExpectedContainer() + "\n"; 1108 StringBuilder commonStmts = new StringBuilder(); 1109 1110 anno = Helper.ContentVars.REPEATABLEANNO.getVal(); 1111 commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal()) 1162 1163 @ExpectedBase 1164 @ExpectedContainer 1165 @Foo(1) @Foo(2) 1166 class A { } 1167 */ 1168 replaceVal = expectedVals + anno; 1169 testSrc = srcType.getTemplate().replace("#CN", className) 1170 .replace("#REPLACE", replaceVal); 1171 contents = commonStmts + testSrc; 1172 srcFileObj = Helper.getFile(className, contents); 1173 files = Arrays.asList(srcFileObj); 1174 } 1175 return files; 1176 } 1177 }, 1178 BasicContainerRepeatable( 1179 "@ExpectedBase(value=Foo.class, " 1180 + "getAnnotationVal = \"NULL\", " 1181 + "getAnnotationsVals = {" 1182 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1183 + "getDeclAnnosVals = {" 1184 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1185 + "getDeclAnnoVal = \"NULL\"," 1186 + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}," 1187 + "getDeclAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"})", 1188 "@ExpectedContainer(value=FooContainer.class, " 1189 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"," 1190 + "getAnnotationsVals = {" 1191 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1192 + "getDeclAnnosVals = {" 1193 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1194 + "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"," 1195 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1196 + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"} )") { 1197 1198 @Override 1199 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1200 String className) { 1201 String anno = ""; 1202 String replaceVal = ""; 1203 String testSrc = ""; 1204 String pkgInfoContents = ""; 1205 String contents = ""; 1206 1207 JavaFileObject pkgFileObj = null; 1208 JavaFileObject srcFileObj = null; 1209 Iterable<? extends JavaFileObject> files = null; 1210 1211 String expectedVals = "\n" + getExpectedBase() + "\n" 1212 + getExpectedContainer() + "\n"; 1213 StringBuilder commonStmts = new StringBuilder(); 1214 1215 anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 1216 commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal()) 1266 } 1267 1268 @ExpectedBase 1269 @ExpectedContainer 1270 @FooContainer(value = {@Foo(1), @Foo(2)}) 1271 class A { } 1272 */ 1273 replaceVal = expectedVals + anno; 1274 testSrc = srcType.getTemplate().replace("#CN", className) 1275 .replace("#REPLACE", replaceVal); 1276 contents = commonStmts + testSrc; 1277 srcFileObj = Helper.getFile(className, contents); 1278 files = Arrays.asList(srcFileObj); 1279 } 1280 return files; 1281 } 1282 }, 1283 BasicContainerRepeatable_Inherited( 1284 "@ExpectedBase(value=Foo.class, " 1285 + "getAnnotationVal = \"NULL\", " 1286 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1287 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, " 1288 + "getDeclAnnoVal = \"NULL\", " 1289 + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}, " 1290 + "getDeclAnnosArgs = {})", 1291 "@ExpectedContainer(value=FooContainer.class, " 1292 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 1293 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1294 + "getDeclAnnosVals = { \"ExpectedBase\", \"ExpectedContainer\"}, " 1295 + "getDeclAnnoVal = \"NULL\", " 1296 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1297 + "getDeclAnnosArgs = {})") { 1298 1299 @Override 1300 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1301 String className) { 1302 String anno = ""; 1303 String replaceVal = ""; 1304 String contents = ""; 1305 JavaFileObject srcFileObj = null; 1306 Iterable<? extends JavaFileObject> files = null; 1307 1308 String expectedVals = "\n" + getExpectedBase() + "\n" 1309 + getExpectedContainer() + "\n"; 1310 StringBuilder commonStmts = getCommonStmts(true); 1311 /* 1312 Sample testSrc: 1313 @Retention(RetentionPolicy.RUNTIME) 1314 @Inherited 1315 @Repeatable(FooContainer.class) 1316 @interface Foo {int value() default Integer.MAX_VALUE;} 1339 .replace("#CN", SUPERCLASS) 1340 .replace("#REPLACE", replaceVal); 1341 1342 // Contents for SubClass that extends SuperClass 1343 replaceVal = expectedVals; 1344 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1345 .replace("#CN", className) 1346 .replace("#SN", SUPERCLASS) 1347 .replace("#REPLACE", replaceVal); 1348 1349 contents = superClassContents + subClassContents; 1350 srcFileObj = Helper.getFile(className, contents); 1351 files = Arrays.asList(srcFileObj); 1352 } 1353 return files; 1354 } 1355 }, 1356 RepeatableAnnoInherited( 1357 "@ExpectedBase(value=Foo.class, " 1358 + "getAnnotationVal = \"NULL\", " 1359 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1360 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, " 1361 + // ignores inherited annotations 1362 "getDeclAnnoVal = \"NULL\", " 1363 + // ignores inherited 1364 "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}, " 1365 + "getDeclAnnosArgs = {})", // ignores inherited 1366 "@ExpectedContainer(value=FooContainer.class, " 1367 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 1368 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1369 + "getDeclAnnosVals = { \"ExpectedBase\", \"ExpectedContainer\"}, " 1370 + // ignores inherited annotations 1371 "getDeclAnnoVal = \"NULL\", " 1372 + // ignores inherited 1373 "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1374 + "getDeclAnnosArgs = {})") { // ignores inherited 1375 1376 @Override 1377 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1378 String className) { 1379 String anno = ""; 1380 String replaceVal = ""; 1381 String contents = ""; 1382 JavaFileObject srcFileObj = null; 1383 Iterable<? extends JavaFileObject> files = null; 1384 1385 String expectedVals = "\n" + getExpectedBase() + "\n" 1386 + getExpectedContainer() + "\n"; 1387 StringBuilder commonStmts = getCommonStmts(true); 1388 /* 1389 Sample testSrc: 1390 @Retention(RetentionPolicy.RUNTIME) 1391 @Inherited 1392 @Repeatable(FooContainer.class) 1393 @interface Foo {int value() default Integer.MAX_VALUE;} 1419 // Contents for SubClass that extends SuperClass 1420 replaceVal = expectedVals; 1421 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1422 .replace("#CN", className) 1423 .replace("#SN", SUPERCLASS) 1424 .replace("#REPLACE", replaceVal); 1425 1426 contents = superClassContents + subClassContents; 1427 srcFileObj = Helper.getFile(className, contents); 1428 files = Arrays.asList(srcFileObj); 1429 } 1430 return files; 1431 } 1432 }, 1433 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1434 // fail with ordering issues 1435 SingleAnnoWithContainer( 1436 "@ExpectedBase(value=Foo.class, " 1437 + "getAnnotationVal = \"@Foo(value=0)\", " 1438 + "getAnnotationsVals = {" 1439 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1440 + "getDeclAnnosVals = {" 1441 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1442 + "getDeclAnnoVal = \"@Foo(value=0)\"," 1443 + "getAnnosArgs = {\"@Foo(value=0)\", \"@Foo(value=1)\", \"@Foo(value=2)\"}," 1444 + "getDeclAnnosArgs = {\"@Foo(value=0)\", \"@Foo(value=1)\",\"@Foo(value=2)\"})", 1445 "@ExpectedContainer(value=FooContainer.class, " 1446 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 1447 + "getAnnotationsVals = {" 1448 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1449 + "getDeclAnnosVals = {" 1450 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1451 + "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"," 1452 + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1453 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"})") { 1454 1455 @Override 1456 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1457 String className) { 1458 String anno = ""; 1459 String replaceVal = ""; 1460 String testSrc = ""; 1461 String pkgInfoContents = ""; 1462 String contents = ""; 1463 1464 JavaFileObject pkgFileObj = null; 1465 JavaFileObject srcFileObj = null; 1466 Iterable<? extends JavaFileObject> files = null; 1467 1468 String expectedVals = "\n" + getExpectedBase() + "\n" 1469 + getExpectedContainer() + "\n"; 1470 StringBuilder commonStmts = new StringBuilder(); 1471 1472 anno = Helper.ContentVars.BASEANNO.getVal() + " " 1473 + Helper.ContentVars.LEGACYCONTAINER.getVal(); 1607 // Contents for SubClass that extends SuperClass 1608 replaceVal = expectedVals + "\n" + "@Foo(1)"; 1609 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1610 .replace("#CN", className) 1611 .replace("#SN", SUPERCLASS) 1612 .replace("#REPLACE", replaceVal); 1613 1614 contents = superClassContents + subClassContents; 1615 srcFileObj = Helper.getFile(className, contents); 1616 files = Arrays.asList(srcFileObj); 1617 } 1618 return files; 1619 } 1620 }, 1621 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1622 // fail with ordering issues 1623 RepeatableOnSuperSingleOnSub_Inherited( 1624 "@ExpectedBase(value=Foo.class, " 1625 + "getAnnotationVal = \"@Foo(value=3)\", " 1626 + "getAnnotationsVals = {" 1627 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1628 + //override every annotation on superClass 1629 "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\"}, " 1630 + // ignores inherited annotations 1631 "getDeclAnnoVal = \"@Foo(value=3)\", " // ignores inherited 1632 + "getAnnosArgs = {\"@Foo(value=3)\"}, " 1633 + "getDeclAnnosArgs = { \"@Foo(value=3)\" })", // ignores inherited 1634 "@ExpectedContainer(value=FooContainer.class, " 1635 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 1636 + "getAnnotationsVals = {" 1637 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1638 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\"}, " 1639 + // ignores inherited annotations 1640 "getDeclAnnoVal = \"NULL\", " 1641 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1642 + "getDeclAnnosArgs = {}) // ignores inherited ") { 1643 1644 @Override 1645 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1646 String className) { 1647 String anno = ""; 1648 String replaceVal = ""; 1649 String contents = ""; 1650 JavaFileObject srcFileObj = null; 1651 Iterable<? extends JavaFileObject> files = null; 1652 1653 String expectedVals = "\n" + getExpectedBase() + "\n" 1654 + getExpectedContainer() + "\n"; 1655 StringBuilder commonStmts = getCommonStmts(true); 1656 1657 /* 1658 Sample testSrc: 1659 @Retention(RetentionPolicy.RUNTIME) 1660 @Inherited 1661 @Repeatable(FooContainer.class) 1687 //Contents for SubClass that extends SuperClass 1688 anno = "@Foo(3)"; 1689 replaceVal = expectedVals + "\n" + anno; 1690 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1691 .replace("#CN", className) 1692 .replace("#SN", SUPERCLASS) 1693 .replace("#REPLACE", replaceVal); 1694 contents = superClassContents + subClassContents; 1695 srcFileObj = Helper.getFile(className, contents); 1696 files = Arrays.asList(srcFileObj); 1697 } 1698 return files; 1699 } 1700 }, 1701 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1702 // fail with ordering issues 1703 SingleOnSuperRepeatableOnSub_Inherited( 1704 "@ExpectedBase(value=Foo.class, " 1705 + "getAnnotationVal = \"@Foo(value=0)\", " 1706 + "getAnnotationsVals = {" 1707 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1708 + //override every annotation on superClass 1709 "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1710 + // ignores inherited annotations 1711 "getDeclAnnoVal = \"NULL\","// ignores inherited 1712 + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}, " 1713 + "getDeclAnnosArgs = { \"@Foo(value=1)\", \"@Foo(value=2)\"})", 1714 "@ExpectedContainer(value=FooContainer.class, " 1715 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 1716 + "getAnnotationsVals = {" 1717 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1718 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1719 + // ignores inherited annotations 1720 "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", "// ignores inherited 1721 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1722 + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"})") { 1723 1724 @Override 1725 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1726 String className) { 1727 String anno = ""; 1728 String replaceVal = ""; 1729 String contents = ""; 1730 JavaFileObject srcFileObj = null; 1731 Iterable<? extends JavaFileObject> files = null; 1732 1733 String expectedVals = "\n" + getExpectedBase() + "\n" 1734 + getExpectedContainer() + "\n"; 1735 StringBuilder commonStmts = getCommonStmts(true); 1736 1737 /* 1738 Sample testSrc: 1739 @Retention(RetentionPolicy.RUNTIME) 1740 @Inherited 1741 @Repeatable(FooContainer.class) 1742 @interface Foo {int value() default Integer.MAX_VALUE;} 1768 anno = Helper.ContentVars.REPEATABLEANNO.getVal(); 1769 replaceVal = expectedVals + "\n" + anno; 1770 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1771 .replace("#CN", className) 1772 .replace("#SN", SUPERCLASS) 1773 .replace("#REPLACE", replaceVal); 1774 1775 contents = superClassContents + subClassContents; 1776 srcFileObj = Helper.getFile(className, contents); 1777 files = Arrays.asList(srcFileObj); 1778 } 1779 return files; 1780 } 1781 }, 1782 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1783 // fail with ordering issues 1784 ContainerOnSuperSingleOnSub_Inherited( 1785 "@ExpectedBase(value=Foo.class, " 1786 + "getAnnotationVal = \"@Foo(value=0)\", " 1787 + "getAnnotationsVals = {" 1788 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1789 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 1790 + "getDeclAnnoVal = \"@Foo(value=0)\"," 1791 + "getAnnosArgs = {\"@Foo(value=0)\"}," 1792 + "getDeclAnnosArgs = {\"@Foo(value=0)\"})", 1793 "@ExpectedContainer(value=FooContainer.class, " 1794 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 1795 + "getAnnotationsVals = {" 1796 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1797 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 1798 + "getDeclAnnoVal = \"NULL\"," 1799 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1800 + "getDeclAnnosArgs = {})") { 1801 1802 @Override 1803 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1804 String className) { 1805 String anno = ""; 1806 String replaceVal = ""; 1807 String contents = ""; 1808 JavaFileObject srcFileObj = null; 1809 Iterable<? extends JavaFileObject> files = null; 1810 1811 String expectedVals = "\n" + getExpectedBase() + "\n" 1812 + getExpectedContainer() + "\n"; 1813 StringBuilder commonStmts = getCommonStmts(true); 1814 1815 /* 1816 Sample testSrc: 1817 @Retention(RetentionPolicy.RUNTIME) 1818 @Inherited 1819 @Repeatable(FooContainer.class) 1846 anno = Helper.ContentVars.BASEANNO.getVal(); 1847 replaceVal = expectedVals + "\n" + anno; 1848 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1849 .replace("#CN", className) 1850 .replace("#SN", SUPERCLASS) 1851 .replace("#REPLACE", replaceVal); 1852 1853 contents = superClassContents + subClassContents; 1854 srcFileObj = Helper.getFile(className, contents); 1855 files = Arrays.asList(srcFileObj); 1856 } 1857 return files; 1858 } 1859 }, 1860 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1861 // fail with ordering issues 1862 SingleOnSuperContainerOnSub_Inherited( 1863 "@ExpectedBase(value=Foo.class, " 1864 + "getAnnotationVal = \"@Foo(value=0)\", " 1865 + "getAnnotationsVals = {" 1866 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1867 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1868 + "getDeclAnnoVal = \"NULL\"," 1869 + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}," 1870 + "getDeclAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"})", 1871 "@ExpectedContainer(value=FooContainer.class, " 1872 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 1873 + "getAnnotationsVals = {" 1874 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1875 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1876 + "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"," 1877 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1878 + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"})") { 1879 1880 @Override 1881 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1882 String className) { 1883 String anno = ""; 1884 String replaceVal = ""; 1885 String contents = ""; 1886 JavaFileObject srcFileObj = null; 1887 Iterable<? extends JavaFileObject> files = null; 1888 1889 String expectedVals = "\n" + getExpectedBase() + "\n" 1890 + getExpectedContainer() + "\n"; 1891 StringBuilder commonStmts = getCommonStmts(true); 1892 1893 /* 1894 Sample testSrc: 1895 @Retention(RetentionPolicy.RUNTIME) 1896 @Inherited 1897 @Repeatable(FooContainer.class) 1898 @interface Foo {int value() default Integer.MAX_VALUE;} 1924 anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 1925 replaceVal = expectedVals + "\n" + anno; 1926 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1927 .replace("#CN", className) 1928 .replace("#SN", SUPERCLASS) 1929 .replace("#REPLACE", replaceVal); 1930 1931 contents = superClassContents + subClassContents; 1932 srcFileObj = Helper.getFile(className, contents); 1933 files = Arrays.asList(srcFileObj); 1934 } 1935 return files; 1936 } 1937 }, 1938 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1939 // fail with ordering issues 1940 SingleOnSuperContainerAndSingleOnSub_Inherited( 1941 "@ExpectedBase(value=Foo.class, " 1942 + "getAnnotationVal = \"@Foo(value=3)\", " 1943 + "getAnnotationsVals = {" 1944 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", \"@Foo(value=3)\"}, " 1945 + "getDeclAnnosVals = {" 1946 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", \"@Foo(value=3)\"}," 1947 + "getDeclAnnoVal = \"@Foo(value=3)\"," 1948 + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\", \"@Foo(value=3)\"}," 1949 + "getDeclAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\", \"@Foo(value=3)\"})", 1950 "@ExpectedContainer(value=FooContainer.class, " 1951 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 1952 + "getAnnotationsVals = {" 1953 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", \"@Foo(value=3)\"}, " 1954 + "getDeclAnnosVals = {" 1955 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", \"@Foo(value=3)\"}," 1956 + "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"," 1957 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1958 + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"})") { 1959 1960 @Override 1961 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1962 String className) { 1963 String anno = ""; 1964 String replaceVal = ""; 1965 String contents = ""; 1966 JavaFileObject srcFileObj = null; 1967 Iterable<? extends JavaFileObject> files = null; 1968 String expectedVals = "\n" + getExpectedBase() + "\n" 1969 + getExpectedContainer() + "\n"; 1970 StringBuilder commonStmts = getCommonStmts(true); 1971 1972 /* 1973 Sample testSrc: 1974 @Retention(RetentionPolicy.RUNTIME) 1975 @Inherited 1976 @interface Foo {int value() default Integer.MAX_VALUE;} 1977 1978 @Retention(RetentionPolicy.RUNTIME) 2004 + "@Foo(3)"; 2005 replaceVal = expectedVals + "\n" + anno; 2006 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 2007 .replace("#CN", className) 2008 .replace("#SN", SUPERCLASS) 2009 .replace("#REPLACE", replaceVal); 2010 2011 contents = superClassContents + subClassContents; 2012 srcFileObj = Helper.getFile(className, contents); 2013 files = Arrays.asList(srcFileObj); 2014 } 2015 return files; 2016 } 2017 }, 2018 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 2019 // fail with ordering issues 2020 ContainerAndSingleOnSuperSingleOnSub_Inherited( 2021 "@ExpectedBase(value=Foo.class, " 2022 + "getAnnotationVal = \"@Foo(value=0)\", " 2023 + "getAnnotationsVals = {" 2024 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 2025 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 2026 + "getDeclAnnoVal = \"@Foo(value=0)\"," 2027 + "getAnnosArgs = {\"@Foo(value=0)\"}," 2028 + "getDeclAnnosArgs = {\"@Foo(value=0)\"})", 2029 "@ExpectedContainer(value=FooContainer.class, " 2030 + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 2031 + "getAnnotationsVals = {" 2032 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 2033 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 2034 + "getDeclAnnoVal = \"NULL\"," 2035 + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 2036 + "getDeclAnnosArgs = {})") { 2037 2038 @Override 2039 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 2040 String className) { 2041 String anno = ""; 2042 String replaceVal = ""; 2043 String contents = ""; 2044 JavaFileObject srcFileObj = null; 2045 Iterable<? extends JavaFileObject> files = null; 2046 2047 String expectedVals = "\n" + getExpectedBase() + "\n" 2048 + getExpectedContainer() + "\n"; 2049 StringBuilder commonStmts = getCommonStmts(true); 2050 2051 /* 2052 Sample testSrc: 2053 @Retention(RetentionPolicy.RUNTIME) 2054 @Inherited 2055 @Repeatable(FooContainer.class) | 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 8001457 8027477 8163113 27 * @author sogoel 28 * @summary Reflection api tests 29 * @modules jdk.compiler 30 * @build Helper 31 * @compile expectedFiles/ExpectedBase.java expectedFiles/ExpectedContainer.java 32 * @run main ReflectionTest 33 */ 34 import java.io.File; 35 import java.io.IOException; 36 import java.lang.annotation.Annotation; 37 import java.net.MalformedURLException; 38 import java.net.URL; 39 import java.net.URLClassLoader; 40 import java.util.ArrayList; 41 import java.util.Arrays; 42 import java.util.List; 43 44 import javax.tools.DiagnosticCollector; 45 import javax.tools.JavaFileObject; 46 466 String superClassContents = srcType.getTemplate() 467 .replace("#CN", SUPERCLASS).replace("#REPLACE", replaceVal); 468 469 // Contents for SubClass that extends SuperClass 470 anno = "@Foo(2)"; 471 replaceVal = expectedVals + "\n" + anno; 472 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 473 .replace("#CN", className).replace("#SN", SUPERCLASS) 474 .replace("#REPLACE", replaceVal); 475 476 contents = superClassContents + subClassContents; 477 srcFileObj = Helper.getFile(className, contents); 478 files = Arrays.asList(srcFileObj); 479 } 480 return files; 481 } 482 }, 483 BasicContainer_Legacy( 484 "@ExpectedBase(value = Foo.class, " 485 + "getAnnotationVal = \"NULL\"," 486 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 487 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 488 + "getDeclAnnoVal = \"NULL\", " + "getAnnosArgs = {}, " 489 + "getDeclAnnosArgs = {} )", 490 "@ExpectedContainer(value=FooContainer.class, " 491 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 492 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 493 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 494 + "getDeclAnnoVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 495 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 496 + "getDeclAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"} )") { 497 498 @Override 499 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 500 String className) { 501 String anno = ""; 502 String replaceVal = ""; 503 String testSrc = ""; 504 String pkgInfoContents = ""; 505 String contents = ""; 506 507 JavaFileObject pkgFileObj = null; 508 JavaFileObject srcFileObj = null; 509 Iterable<? extends JavaFileObject> files = null; 510 511 String expectedVals = "\n" + getExpectedBase() + "\n" 512 + getExpectedContainer() + "\n"; 513 StringBuilder commonStmts = new StringBuilder(); 514 515 anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 516 commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal()) 566 567 @ExpectedBase 568 @ExpectedContainer 569 @FooContainer(value = {@Foo(1), @Foo(2)}) 570 class A {} 571 */ 572 replaceVal = expectedVals + anno; 573 testSrc = srcType.getTemplate().replace("#CN", className) 574 .replace("#REPLACE", replaceVal); 575 contents = commonStmts + testSrc; 576 srcFileObj = Helper.getFile(className, contents); 577 files = Arrays.asList(srcFileObj); 578 } 579 return files; 580 } 581 }, 582 SingleAndContainerOnSuper_Legacy( 583 "@ExpectedBase(value = Foo.class, " 584 + "getAnnotationVal = \"@Foo(value=0)\"," 585 + "getAnnotationsVals = {" 586 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 587 + "getDeclAnnosVals = {" 588 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 589 + "getDeclAnnoVal = \"@Foo(value=0)\", " 590 + "getAnnosArgs = {\"@Foo(value=0)\"}, " 591 + "getDeclAnnosArgs = {\"@Foo(value=0)\"} )", 592 "@ExpectedContainer(value=FooContainer.class, " 593 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 594 + "getAnnotationsVals = {" 595 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 596 + "getDeclAnnosVals = {" 597 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 598 + "getDeclAnnoVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 599 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 600 + "getDeclAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"} )") { 601 602 @Override 603 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 604 String className) { 605 String anno = ""; 606 String replaceVal = ""; 607 String testSrc = ""; 608 String pkgInfoContents = ""; 609 String contents = ""; 610 611 JavaFileObject pkgFileObj = null; 612 JavaFileObject srcFileObj = null; 613 Iterable<? extends JavaFileObject> files = null; 614 615 String expectedVals = "\n" + getExpectedBase() + "\n" 616 + getExpectedContainer() + "\n"; 617 StringBuilder commonStmts = new StringBuilder(); 618 619 anno = Helper.ContentVars.BASEANNO.getVal() + 620 Helper.ContentVars.LEGACYCONTAINER.getVal(); 674 @ExpectedBase 675 @ExpectedContainer 676 @Foo(0) 677 @FooContainer(value = {@Foo(1), @Foo(2)}) 678 class A {} 679 */ 680 replaceVal = expectedVals + anno; 681 testSrc = srcType.getTemplate().replace("#CN", className) 682 .replace("#REPLACE", replaceVal); 683 contents = commonStmts + testSrc; 684 685 srcFileObj = Helper.getFile(className, contents); 686 files = Arrays.asList(srcFileObj); 687 } 688 return files; 689 } 690 }, 691 BasicContainer_Inherited_Legacy( 692 "@ExpectedBase(value = Foo.class, " 693 + "getAnnotationVal = \"NULL\"," 694 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 695 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, " 696 + "getDeclAnnoVal = \"NULL\", " 697 + "getAnnosArgs = {}, " 698 + "getDeclAnnosArgs = {} )", 699 "@ExpectedContainer(value=FooContainer.class, " 700 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 701 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 702 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, " 703 + "getDeclAnnoVal = \"NULL\", " 704 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 705 + "getDeclAnnosArgs = {} )") { 706 707 @Override 708 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 709 String className) { 710 String anno = ""; 711 String replaceVal = ""; 712 String contents = ""; 713 JavaFileObject srcFileObj = null; 714 Iterable<? extends JavaFileObject> files = null; 715 716 String expectedVals = "\n" + getExpectedBase() + "\n" 717 + getExpectedContainer() + "\n"; 718 StringBuilder commonStmts = getCommonStmts(false); 719 720 /* 721 Sample testSrc: 722 @Retention(RetentionPolicy.RUNTIME) 723 @Inherited 724 @interface Foo {int value() default Integer.MAX_VALUE;} 748 .replace("#REPLACE", replaceVal); 749 750 // Contents for SubClass that extends SuperClass 751 replaceVal = expectedVals; 752 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 753 .replace("#CN", className) 754 .replace("#SN", SUPERCLASS) 755 .replace("#REPLACE", replaceVal); 756 757 contents = superClassContents + subClassContents; 758 srcFileObj = Helper.getFile(className, contents); 759 files = Arrays.asList(srcFileObj); 760 } 761 return files; 762 } 763 }, 764 ContainerOnSuperSingleOnSub_Inherited_Legacy( 765 "@ExpectedBase(value=Foo.class, " 766 + "getAnnotationVal = \"@Foo(value=0)\", " 767 + "getAnnotationsVals = {" 768 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", \"@Foo(value=0)\"}, " 769 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 770 + "getDeclAnnoVal = \"@Foo(value=0)\"," 771 + "getAnnosArgs = {\"@Foo(value=0)\"}," 772 + "getDeclAnnosArgs = {\"@Foo(value=0)\"})", 773 "@ExpectedContainer(value=FooContainer.class, " 774 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 775 + "getAnnotationsVals = {" 776 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", \"@Foo(value=0)\"}, " 777 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 778 + "getDeclAnnoVal = \"NULL\"," 779 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 780 + "getDeclAnnosArgs = {})") { 781 782 @Override 783 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 784 String className) { 785 String anno = ""; 786 String replaceVal = ""; 787 String contents = ""; 788 JavaFileObject srcFileObj = null; 789 Iterable<? extends JavaFileObject> files = null; 790 791 String expectedVals = "\n" + getExpectedBase() + "\n" 792 + getExpectedContainer() + "\n"; 793 StringBuilder commonStmts = getCommonStmts(false); 794 795 /* 796 Sample testSrc: 797 @Retention(RetentionPolicy.RUNTIME) 798 @Inherited 799 @interface Foo {int value() default Integer.MAX_VALUE;} 827 anno = Helper.ContentVars.BASEANNO.getVal(); 828 replaceVal = expectedVals + "\n" + anno; 829 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 830 .replace("#CN", className) 831 .replace("#SN", SUPERCLASS) 832 .replace("#REPLACE", replaceVal); 833 834 contents = superClassContents + subClassContents; 835 srcFileObj = Helper.getFile(className, contents); 836 files = Arrays.asList(srcFileObj); 837 } 838 return files; 839 } 840 }, 841 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 842 // fail with ordering issues 843 ContainerAndSingleOnSuperSingleOnSub_Inherited_Legacy( 844 "@ExpectedBase(value=Foo.class, " 845 + "getAnnotationVal = \"@Foo(value=0)\", " 846 + "getAnnotationsVals = {" 847 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", \"@Foo(value=0)\"}, " 848 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 849 + "getDeclAnnoVal = \"@Foo(value=0)\"," 850 + "getAnnosArgs = {\"@Foo(value=0)\"}," 851 + "getDeclAnnosArgs = {\"@Foo(value=0)\"})", 852 "@ExpectedContainer(value=FooContainer.class, " 853 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 854 + "getAnnotationsVals = {" 855 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", \"@Foo(value=0)\"}, " 856 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 857 + "getDeclAnnoVal = \"NULL\"," 858 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 859 + "getDeclAnnosArgs = {})") { 860 861 @Override 862 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 863 String className) { 864 String anno = ""; 865 String replaceVal = ""; 866 String contents = ""; 867 JavaFileObject srcFileObj = null; 868 Iterable<? extends JavaFileObject> files = null; 869 870 String expectedVals = "\n" + getExpectedBase() + "\n" 871 + getExpectedContainer() + "\n"; 872 StringBuilder commonStmts = getCommonStmts(false); 873 874 /* 875 Sample testSrc: 876 @Retention(RetentionPolicy.RUNTIME) 877 @Inherited 878 @interface Foo {int value() default Integer.MAX_VALUE;} 906 // Contents for SubClass that extends SuperClass 907 anno = Helper.ContentVars.BASEANNO.getVal(); 908 replaceVal = expectedVals + "\n" + anno; 909 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 910 .replace("#CN", className).replace("#SN", SUPERCLASS) 911 .replace("#REPLACE", replaceVal); 912 913 contents = superClassContents + subClassContents; 914 srcFileObj = Helper.getFile(className, contents); 915 files = Arrays.asList(srcFileObj); 916 } 917 return files; 918 } 919 }, 920 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 921 // fail with ordering issues 922 SingleOnSuperContainerOnSub_Inherited_Legacy( 923 "@ExpectedBase(value=Foo.class, " 924 + "getAnnotationVal = \"@Foo(value=0)\", " 925 + "getAnnotationsVals = {" 926 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 927 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 928 + "getDeclAnnoVal = \"NULL\"," 929 + "getAnnosArgs = {\"@Foo(value=0)\"}," 930 + "getDeclAnnosArgs = {})", 931 "@ExpectedContainer(value=FooContainer.class, " 932 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 933 + "getAnnotationsVals = {" 934 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 935 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 936 + "getDeclAnnoVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"," 937 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 938 + "getDeclAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"})") { 939 940 @Override 941 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 942 String className) { 943 String anno = ""; 944 String replaceVal = ""; 945 String contents = ""; 946 947 JavaFileObject srcFileObj = null; 948 Iterable<? extends JavaFileObject> files = null; 949 950 String expectedVals = "\n" + getExpectedBase() + "\n" 951 + getExpectedContainer() + "\n"; 952 StringBuilder commonStmts = getCommonStmts(false); 953 954 /* 955 Sample testSrc: 956 @Retention(RetentionPolicy.RUNTIME) 957 @Inherited 958 @interface Foo {int value() default Integer.MAX_VALUE;} 983 //Contents for SubClass that extends SuperClass 984 anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 985 replaceVal = expectedVals + "\n" + anno; 986 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 987 .replace("#CN", className).replace("#SN", SUPERCLASS) 988 .replace("#REPLACE", replaceVal); 989 990 contents = superClassContents + subClassContents; 991 srcFileObj = Helper.getFile(className, contents); 992 files = Arrays.asList(srcFileObj); 993 } 994 return files; 995 } 996 }, 997 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 998 // fail with ordering issues 999 SingleOnSuperContainerAndSingleOnSub_Inherited_Legacy( 1000 "@ExpectedBase(value=Foo.class, " 1001 + "getAnnotationVal = \"@Foo(value=3)\", " 1002 + "getAnnotationsVals = {" 1003 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", \"@Foo(value=3)\"}, " 1004 + "getDeclAnnosVals = {" 1005 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", \"@Foo(value=3)\"}," 1006 + "getDeclAnnoVal = \"@Foo(value=3)\"," 1007 + "getAnnosArgs = {\"@Foo(value=3)\"}," 1008 + "getDeclAnnosArgs = {\"@Foo(value=3)\"})", 1009 "@ExpectedContainer(value=FooContainer.class, " 1010 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 1011 + "getAnnotationsVals = {" 1012 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", \"@Foo(value=3)\"}, " 1013 + "getDeclAnnosVals = {" 1014 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", \"@Foo(value=3)\"}," 1015 + "getDeclAnnoVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"," 1016 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1017 + "getDeclAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"})") { 1018 1019 @Override 1020 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1021 String className) { 1022 String anno = ""; 1023 String replaceVal = ""; 1024 String contents = ""; 1025 1026 JavaFileObject srcFileObj = null; 1027 Iterable<? extends JavaFileObject> files = null; 1028 1029 String expectedVals = "\n" + getExpectedBase() + "\n" 1030 + getExpectedContainer() + "\n"; 1031 StringBuilder commonStmts = getCommonStmts(false); 1032 1033 /* 1034 Sample testSrc: 1035 @Retention(RetentionPolicy.RUNTIME) 1036 @Inherited 1037 @interface Foo {int value() default Integer.MAX_VALUE;} 1060 .replace("#REPLACE", replaceVal); 1061 1062 //Contents for SubClass that extends SuperClass 1063 anno = Helper.ContentVars.LEGACYCONTAINER.getVal() 1064 + "@Foo(3)"; 1065 replaceVal = expectedVals + "\n" + anno; 1066 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1067 .replace("#CN", className).replace("#SN", SUPERCLASS) 1068 .replace("#REPLACE", replaceVal); 1069 1070 contents = superClassContents + subClassContents; 1071 srcFileObj = Helper.getFile(className, contents); 1072 files = Arrays.asList(srcFileObj); 1073 } 1074 return files; 1075 } 1076 }, 1077 BasicRepeatable( 1078 "@ExpectedBase(value=Foo.class, " 1079 + "getAnnotationVal = \"NULL\", " 1080 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\" }, " 1081 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1082 + "getDeclAnnoVal = \"NULL\"," 1083 + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}," 1084 + "getDeclAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"})", 1085 "@ExpectedContainer(value=FooContainer.class, " 1086 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"," 1087 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1088 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1089 + "getDeclAnnoVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"," 1090 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1091 + "getDeclAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"} )") { 1092 1093 @Override 1094 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1095 String className) { 1096 String anno = ""; 1097 String replaceVal = ""; 1098 String testSrc = ""; 1099 String pkgInfoContents = ""; 1100 String contents = ""; 1101 1102 JavaFileObject pkgFileObj = null; 1103 JavaFileObject srcFileObj = null; 1104 Iterable<? extends JavaFileObject> files = null; 1105 1106 String expectedVals = "\n" + getExpectedBase() + "\n" 1107 + getExpectedContainer() + "\n"; 1108 StringBuilder commonStmts = new StringBuilder(); 1109 1110 anno = Helper.ContentVars.REPEATABLEANNO.getVal(); 1111 commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal()) 1162 1163 @ExpectedBase 1164 @ExpectedContainer 1165 @Foo(1) @Foo(2) 1166 class A { } 1167 */ 1168 replaceVal = expectedVals + anno; 1169 testSrc = srcType.getTemplate().replace("#CN", className) 1170 .replace("#REPLACE", replaceVal); 1171 contents = commonStmts + testSrc; 1172 srcFileObj = Helper.getFile(className, contents); 1173 files = Arrays.asList(srcFileObj); 1174 } 1175 return files; 1176 } 1177 }, 1178 BasicContainerRepeatable( 1179 "@ExpectedBase(value=Foo.class, " 1180 + "getAnnotationVal = \"NULL\", " 1181 + "getAnnotationsVals = {" 1182 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1183 + "getDeclAnnosVals = {" 1184 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1185 + "getDeclAnnoVal = \"NULL\"," 1186 + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}," 1187 + "getDeclAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"})", 1188 "@ExpectedContainer(value=FooContainer.class, " 1189 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"," 1190 + "getAnnotationsVals = {" 1191 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1192 + "getDeclAnnosVals = {" 1193 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1194 + "getDeclAnnoVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"," 1195 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1196 + "getDeclAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"} )") { 1197 1198 @Override 1199 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1200 String className) { 1201 String anno = ""; 1202 String replaceVal = ""; 1203 String testSrc = ""; 1204 String pkgInfoContents = ""; 1205 String contents = ""; 1206 1207 JavaFileObject pkgFileObj = null; 1208 JavaFileObject srcFileObj = null; 1209 Iterable<? extends JavaFileObject> files = null; 1210 1211 String expectedVals = "\n" + getExpectedBase() + "\n" 1212 + getExpectedContainer() + "\n"; 1213 StringBuilder commonStmts = new StringBuilder(); 1214 1215 anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 1216 commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal()) 1266 } 1267 1268 @ExpectedBase 1269 @ExpectedContainer 1270 @FooContainer(value = {@Foo(1), @Foo(2)}) 1271 class A { } 1272 */ 1273 replaceVal = expectedVals + anno; 1274 testSrc = srcType.getTemplate().replace("#CN", className) 1275 .replace("#REPLACE", replaceVal); 1276 contents = commonStmts + testSrc; 1277 srcFileObj = Helper.getFile(className, contents); 1278 files = Arrays.asList(srcFileObj); 1279 } 1280 return files; 1281 } 1282 }, 1283 BasicContainerRepeatable_Inherited( 1284 "@ExpectedBase(value=Foo.class, " 1285 + "getAnnotationVal = \"NULL\", " 1286 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1287 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, " 1288 + "getDeclAnnoVal = \"NULL\", " 1289 + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}, " 1290 + "getDeclAnnosArgs = {})", 1291 "@ExpectedContainer(value=FooContainer.class, " 1292 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 1293 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1294 + "getDeclAnnosVals = { \"ExpectedBase\", \"ExpectedContainer\"}, " 1295 + "getDeclAnnoVal = \"NULL\", " 1296 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1297 + "getDeclAnnosArgs = {})") { 1298 1299 @Override 1300 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1301 String className) { 1302 String anno = ""; 1303 String replaceVal = ""; 1304 String contents = ""; 1305 JavaFileObject srcFileObj = null; 1306 Iterable<? extends JavaFileObject> files = null; 1307 1308 String expectedVals = "\n" + getExpectedBase() + "\n" 1309 + getExpectedContainer() + "\n"; 1310 StringBuilder commonStmts = getCommonStmts(true); 1311 /* 1312 Sample testSrc: 1313 @Retention(RetentionPolicy.RUNTIME) 1314 @Inherited 1315 @Repeatable(FooContainer.class) 1316 @interface Foo {int value() default Integer.MAX_VALUE;} 1339 .replace("#CN", SUPERCLASS) 1340 .replace("#REPLACE", replaceVal); 1341 1342 // Contents for SubClass that extends SuperClass 1343 replaceVal = expectedVals; 1344 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1345 .replace("#CN", className) 1346 .replace("#SN", SUPERCLASS) 1347 .replace("#REPLACE", replaceVal); 1348 1349 contents = superClassContents + subClassContents; 1350 srcFileObj = Helper.getFile(className, contents); 1351 files = Arrays.asList(srcFileObj); 1352 } 1353 return files; 1354 } 1355 }, 1356 RepeatableAnnoInherited( 1357 "@ExpectedBase(value=Foo.class, " 1358 + "getAnnotationVal = \"NULL\", " 1359 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1360 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, " 1361 + // ignores inherited annotations 1362 "getDeclAnnoVal = \"NULL\", " 1363 + // ignores inherited 1364 "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}, " 1365 + "getDeclAnnosArgs = {})", // ignores inherited 1366 "@ExpectedContainer(value=FooContainer.class, " 1367 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 1368 + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1369 + "getDeclAnnosVals = { \"ExpectedBase\", \"ExpectedContainer\"}, " 1370 + // ignores inherited annotations 1371 "getDeclAnnoVal = \"NULL\", " 1372 + // ignores inherited 1373 "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1374 + "getDeclAnnosArgs = {})") { // ignores inherited 1375 1376 @Override 1377 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1378 String className) { 1379 String anno = ""; 1380 String replaceVal = ""; 1381 String contents = ""; 1382 JavaFileObject srcFileObj = null; 1383 Iterable<? extends JavaFileObject> files = null; 1384 1385 String expectedVals = "\n" + getExpectedBase() + "\n" 1386 + getExpectedContainer() + "\n"; 1387 StringBuilder commonStmts = getCommonStmts(true); 1388 /* 1389 Sample testSrc: 1390 @Retention(RetentionPolicy.RUNTIME) 1391 @Inherited 1392 @Repeatable(FooContainer.class) 1393 @interface Foo {int value() default Integer.MAX_VALUE;} 1419 // Contents for SubClass that extends SuperClass 1420 replaceVal = expectedVals; 1421 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1422 .replace("#CN", className) 1423 .replace("#SN", SUPERCLASS) 1424 .replace("#REPLACE", replaceVal); 1425 1426 contents = superClassContents + subClassContents; 1427 srcFileObj = Helper.getFile(className, contents); 1428 files = Arrays.asList(srcFileObj); 1429 } 1430 return files; 1431 } 1432 }, 1433 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1434 // fail with ordering issues 1435 SingleAnnoWithContainer( 1436 "@ExpectedBase(value=Foo.class, " 1437 + "getAnnotationVal = \"@Foo(value=0)\", " 1438 + "getAnnotationsVals = {" 1439 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1440 + "getDeclAnnosVals = {" 1441 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1442 + "getDeclAnnoVal = \"@Foo(value=0)\"," 1443 + "getAnnosArgs = {\"@Foo(value=0)\", \"@Foo(value=1)\", \"@Foo(value=2)\"}," 1444 + "getDeclAnnosArgs = {\"@Foo(value=0)\", \"@Foo(value=1)\",\"@Foo(value=2)\"})", 1445 "@ExpectedContainer(value=FooContainer.class, " 1446 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 1447 + "getAnnotationsVals = {" 1448 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1449 + "getDeclAnnosVals = {" 1450 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1451 + "getDeclAnnoVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"," 1452 + "getDeclAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1453 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"})") { 1454 1455 @Override 1456 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1457 String className) { 1458 String anno = ""; 1459 String replaceVal = ""; 1460 String testSrc = ""; 1461 String pkgInfoContents = ""; 1462 String contents = ""; 1463 1464 JavaFileObject pkgFileObj = null; 1465 JavaFileObject srcFileObj = null; 1466 Iterable<? extends JavaFileObject> files = null; 1467 1468 String expectedVals = "\n" + getExpectedBase() + "\n" 1469 + getExpectedContainer() + "\n"; 1470 StringBuilder commonStmts = new StringBuilder(); 1471 1472 anno = Helper.ContentVars.BASEANNO.getVal() + " " 1473 + Helper.ContentVars.LEGACYCONTAINER.getVal(); 1607 // Contents for SubClass that extends SuperClass 1608 replaceVal = expectedVals + "\n" + "@Foo(1)"; 1609 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1610 .replace("#CN", className) 1611 .replace("#SN", SUPERCLASS) 1612 .replace("#REPLACE", replaceVal); 1613 1614 contents = superClassContents + subClassContents; 1615 srcFileObj = Helper.getFile(className, contents); 1616 files = Arrays.asList(srcFileObj); 1617 } 1618 return files; 1619 } 1620 }, 1621 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1622 // fail with ordering issues 1623 RepeatableOnSuperSingleOnSub_Inherited( 1624 "@ExpectedBase(value=Foo.class, " 1625 + "getAnnotationVal = \"@Foo(value=3)\", " 1626 + "getAnnotationsVals = {" 1627 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1628 + //override every annotation on superClass 1629 "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\"}, " 1630 + // ignores inherited annotations 1631 "getDeclAnnoVal = \"@Foo(value=3)\", " // ignores inherited 1632 + "getAnnosArgs = {\"@Foo(value=3)\"}, " 1633 + "getDeclAnnosArgs = { \"@Foo(value=3)\" })", // ignores inherited 1634 "@ExpectedContainer(value=FooContainer.class, " 1635 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 1636 + "getAnnotationsVals = {" 1637 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1638 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\"}, " 1639 + // ignores inherited annotations 1640 "getDeclAnnoVal = \"NULL\", " 1641 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1642 + "getDeclAnnosArgs = {}) // ignores inherited ") { 1643 1644 @Override 1645 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1646 String className) { 1647 String anno = ""; 1648 String replaceVal = ""; 1649 String contents = ""; 1650 JavaFileObject srcFileObj = null; 1651 Iterable<? extends JavaFileObject> files = null; 1652 1653 String expectedVals = "\n" + getExpectedBase() + "\n" 1654 + getExpectedContainer() + "\n"; 1655 StringBuilder commonStmts = getCommonStmts(true); 1656 1657 /* 1658 Sample testSrc: 1659 @Retention(RetentionPolicy.RUNTIME) 1660 @Inherited 1661 @Repeatable(FooContainer.class) 1687 //Contents for SubClass that extends SuperClass 1688 anno = "@Foo(3)"; 1689 replaceVal = expectedVals + "\n" + anno; 1690 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1691 .replace("#CN", className) 1692 .replace("#SN", SUPERCLASS) 1693 .replace("#REPLACE", replaceVal); 1694 contents = superClassContents + subClassContents; 1695 srcFileObj = Helper.getFile(className, contents); 1696 files = Arrays.asList(srcFileObj); 1697 } 1698 return files; 1699 } 1700 }, 1701 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1702 // fail with ordering issues 1703 SingleOnSuperRepeatableOnSub_Inherited( 1704 "@ExpectedBase(value=Foo.class, " 1705 + "getAnnotationVal = \"@Foo(value=0)\", " 1706 + "getAnnotationsVals = {" 1707 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1708 + //override every annotation on superClass 1709 "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1710 + // ignores inherited annotations 1711 "getDeclAnnoVal = \"NULL\","// ignores inherited 1712 + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}, " 1713 + "getDeclAnnosArgs = { \"@Foo(value=1)\", \"@Foo(value=2)\"})", 1714 "@ExpectedContainer(value=FooContainer.class, " 1715 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 1716 + "getAnnotationsVals = {" 1717 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1718 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1719 + // ignores inherited annotations 1720 "getDeclAnnoVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", "// ignores inherited 1721 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1722 + "getDeclAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"})") { 1723 1724 @Override 1725 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1726 String className) { 1727 String anno = ""; 1728 String replaceVal = ""; 1729 String contents = ""; 1730 JavaFileObject srcFileObj = null; 1731 Iterable<? extends JavaFileObject> files = null; 1732 1733 String expectedVals = "\n" + getExpectedBase() + "\n" 1734 + getExpectedContainer() + "\n"; 1735 StringBuilder commonStmts = getCommonStmts(true); 1736 1737 /* 1738 Sample testSrc: 1739 @Retention(RetentionPolicy.RUNTIME) 1740 @Inherited 1741 @Repeatable(FooContainer.class) 1742 @interface Foo {int value() default Integer.MAX_VALUE;} 1768 anno = Helper.ContentVars.REPEATABLEANNO.getVal(); 1769 replaceVal = expectedVals + "\n" + anno; 1770 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1771 .replace("#CN", className) 1772 .replace("#SN", SUPERCLASS) 1773 .replace("#REPLACE", replaceVal); 1774 1775 contents = superClassContents + subClassContents; 1776 srcFileObj = Helper.getFile(className, contents); 1777 files = Arrays.asList(srcFileObj); 1778 } 1779 return files; 1780 } 1781 }, 1782 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1783 // fail with ordering issues 1784 ContainerOnSuperSingleOnSub_Inherited( 1785 "@ExpectedBase(value=Foo.class, " 1786 + "getAnnotationVal = \"@Foo(value=0)\", " 1787 + "getAnnotationsVals = {" 1788 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1789 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 1790 + "getDeclAnnoVal = \"@Foo(value=0)\"," 1791 + "getAnnosArgs = {\"@Foo(value=0)\"}," 1792 + "getDeclAnnosArgs = {\"@Foo(value=0)\"})", 1793 "@ExpectedContainer(value=FooContainer.class, " 1794 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 1795 + "getAnnotationsVals = {" 1796 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1797 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 1798 + "getDeclAnnoVal = \"NULL\"," 1799 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1800 + "getDeclAnnosArgs = {})") { 1801 1802 @Override 1803 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1804 String className) { 1805 String anno = ""; 1806 String replaceVal = ""; 1807 String contents = ""; 1808 JavaFileObject srcFileObj = null; 1809 Iterable<? extends JavaFileObject> files = null; 1810 1811 String expectedVals = "\n" + getExpectedBase() + "\n" 1812 + getExpectedContainer() + "\n"; 1813 StringBuilder commonStmts = getCommonStmts(true); 1814 1815 /* 1816 Sample testSrc: 1817 @Retention(RetentionPolicy.RUNTIME) 1818 @Inherited 1819 @Repeatable(FooContainer.class) 1846 anno = Helper.ContentVars.BASEANNO.getVal(); 1847 replaceVal = expectedVals + "\n" + anno; 1848 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1849 .replace("#CN", className) 1850 .replace("#SN", SUPERCLASS) 1851 .replace("#REPLACE", replaceVal); 1852 1853 contents = superClassContents + subClassContents; 1854 srcFileObj = Helper.getFile(className, contents); 1855 files = Arrays.asList(srcFileObj); 1856 } 1857 return files; 1858 } 1859 }, 1860 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1861 // fail with ordering issues 1862 SingleOnSuperContainerOnSub_Inherited( 1863 "@ExpectedBase(value=Foo.class, " 1864 + "getAnnotationVal = \"@Foo(value=0)\", " 1865 + "getAnnotationsVals = {" 1866 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1867 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1868 + "getDeclAnnoVal = \"NULL\"," 1869 + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}," 1870 + "getDeclAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"})", 1871 "@ExpectedContainer(value=FooContainer.class, " 1872 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 1873 + "getAnnotationsVals = {" 1874 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 1875 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1876 + "getDeclAnnoVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"," 1877 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1878 + "getDeclAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"})") { 1879 1880 @Override 1881 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1882 String className) { 1883 String anno = ""; 1884 String replaceVal = ""; 1885 String contents = ""; 1886 JavaFileObject srcFileObj = null; 1887 Iterable<? extends JavaFileObject> files = null; 1888 1889 String expectedVals = "\n" + getExpectedBase() + "\n" 1890 + getExpectedContainer() + "\n"; 1891 StringBuilder commonStmts = getCommonStmts(true); 1892 1893 /* 1894 Sample testSrc: 1895 @Retention(RetentionPolicy.RUNTIME) 1896 @Inherited 1897 @Repeatable(FooContainer.class) 1898 @interface Foo {int value() default Integer.MAX_VALUE;} 1924 anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 1925 replaceVal = expectedVals + "\n" + anno; 1926 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1927 .replace("#CN", className) 1928 .replace("#SN", SUPERCLASS) 1929 .replace("#REPLACE", replaceVal); 1930 1931 contents = superClassContents + subClassContents; 1932 srcFileObj = Helper.getFile(className, contents); 1933 files = Arrays.asList(srcFileObj); 1934 } 1935 return files; 1936 } 1937 }, 1938 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1939 // fail with ordering issues 1940 SingleOnSuperContainerAndSingleOnSub_Inherited( 1941 "@ExpectedBase(value=Foo.class, " 1942 + "getAnnotationVal = \"@Foo(value=3)\", " 1943 + "getAnnotationsVals = {" 1944 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", \"@Foo(value=3)\"}, " 1945 + "getDeclAnnosVals = {" 1946 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", \"@Foo(value=3)\"}," 1947 + "getDeclAnnoVal = \"@Foo(value=3)\"," 1948 + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\", \"@Foo(value=3)\"}," 1949 + "getDeclAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\", \"@Foo(value=3)\"})", 1950 "@ExpectedContainer(value=FooContainer.class, " 1951 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 1952 + "getAnnotationsVals = {" 1953 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", \"@Foo(value=3)\"}, " 1954 + "getDeclAnnosVals = {" 1955 + "\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", \"@Foo(value=3)\"}," 1956 + "getDeclAnnoVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"," 1957 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 1958 + "getDeclAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"})") { 1959 1960 @Override 1961 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1962 String className) { 1963 String anno = ""; 1964 String replaceVal = ""; 1965 String contents = ""; 1966 JavaFileObject srcFileObj = null; 1967 Iterable<? extends JavaFileObject> files = null; 1968 String expectedVals = "\n" + getExpectedBase() + "\n" 1969 + getExpectedContainer() + "\n"; 1970 StringBuilder commonStmts = getCommonStmts(true); 1971 1972 /* 1973 Sample testSrc: 1974 @Retention(RetentionPolicy.RUNTIME) 1975 @Inherited 1976 @interface Foo {int value() default Integer.MAX_VALUE;} 1977 1978 @Retention(RetentionPolicy.RUNTIME) 2004 + "@Foo(3)"; 2005 replaceVal = expectedVals + "\n" + anno; 2006 String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 2007 .replace("#CN", className) 2008 .replace("#SN", SUPERCLASS) 2009 .replace("#REPLACE", replaceVal); 2010 2011 contents = superClassContents + subClassContents; 2012 srcFileObj = Helper.getFile(className, contents); 2013 files = Arrays.asList(srcFileObj); 2014 } 2015 return files; 2016 } 2017 }, 2018 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 2019 // fail with ordering issues 2020 ContainerAndSingleOnSuperSingleOnSub_Inherited( 2021 "@ExpectedBase(value=Foo.class, " 2022 + "getAnnotationVal = \"@Foo(value=0)\", " 2023 + "getAnnotationsVals = {" 2024 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 2025 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 2026 + "getDeclAnnoVal = \"@Foo(value=0)\"," 2027 + "getAnnosArgs = {\"@Foo(value=0)\"}," 2028 + "getDeclAnnosArgs = {\"@Foo(value=0)\"})", 2029 "@ExpectedContainer(value=FooContainer.class, " 2030 + "getAnnotationVal = \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\", " 2031 + "getAnnotationsVals = {" 2032 + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}, " 2033 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 2034 + "getDeclAnnoVal = \"NULL\"," 2035 + "getAnnosArgs = {\"@FooContainer(value={@Foo(value=1), @Foo(value=2)})\"}," 2036 + "getDeclAnnosArgs = {})") { 2037 2038 @Override 2039 public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 2040 String className) { 2041 String anno = ""; 2042 String replaceVal = ""; 2043 String contents = ""; 2044 JavaFileObject srcFileObj = null; 2045 Iterable<? extends JavaFileObject> files = null; 2046 2047 String expectedVals = "\n" + getExpectedBase() + "\n" 2048 + getExpectedContainer() + "\n"; 2049 StringBuilder commonStmts = getCommonStmts(true); 2050 2051 /* 2052 Sample testSrc: 2053 @Retention(RetentionPolicy.RUNTIME) 2054 @Inherited 2055 @Repeatable(FooContainer.class) |