< prev index next >

test/langtools/tools/javac/records/RecordCompilationTests.java

Print this page

 103 import static java.lang.annotation.ElementType.*;
 104 import static org.testng.Assert.assertEquals;
 105 
 106 /** Records are the first feature which sports automatic injection of (declarative and type) annotations : from a
 107  *  given record component to one or more record members, if applicable.
 108  *  This implies that the record's implementation can be stressed with the presence of annotation processors. Which is
 109  *  something the implementator could easily skip. For this reason this test is executed twice, once without the
 110  *  presence of any annotation processor and one with a simple annotation processor (which does not annotation processing
 111  *  at all) just to force at least a round of annotation processing.
 112  *
 113  *  Tests needing special compilation options need to store current options, set its customs options by invoking method
 114  *  `setCompileOptions` and then reset the previous compilation options for other tests. To see an example of this check
 115  *  method: testAnnos()
 116  */
 117 
 118 @Test
 119 public class RecordCompilationTests extends CompilationTestCase {
 120     private static String[] OPTIONS_WITH_AP = {"-processor", SimplestAP.class.getName()};
 121 
 122     private static final List<String> BAD_COMPONENT_NAMES = List.of(
 123             "clone", "finalize", "getClass", "hashCode",
 124             "notify", "notifyAll", "toString", "wait");
 125 
 126     /* simplest annotation processor just to force a round of annotation processing for all tests
 127      */
 128     @SupportedAnnotationTypes("*")
 129     public static class SimplestAP extends AbstractProcessor {
 130         @Override
 131         public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
 132             return true;
 133         }
 134     }
 135 
 136     boolean useAP;
 137 
 138     public RecordCompilationTests() {
 139         useAP = System.getProperty("useAP", "false").equals("true");
 140         setDefaultFilename("R.java");
 141         if (useAP) {
 142             setCompileOptions(OPTIONS_WITH_AP);
 143         }

 103 import static java.lang.annotation.ElementType.*;
 104 import static org.testng.Assert.assertEquals;
 105 
 106 /** Records are the first feature which sports automatic injection of (declarative and type) annotations : from a
 107  *  given record component to one or more record members, if applicable.
 108  *  This implies that the record's implementation can be stressed with the presence of annotation processors. Which is
 109  *  something the implementator could easily skip. For this reason this test is executed twice, once without the
 110  *  presence of any annotation processor and one with a simple annotation processor (which does not annotation processing
 111  *  at all) just to force at least a round of annotation processing.
 112  *
 113  *  Tests needing special compilation options need to store current options, set its customs options by invoking method
 114  *  `setCompileOptions` and then reset the previous compilation options for other tests. To see an example of this check
 115  *  method: testAnnos()
 116  */
 117 
 118 @Test
 119 public class RecordCompilationTests extends CompilationTestCase {
 120     private static String[] OPTIONS_WITH_AP = {"-processor", SimplestAP.class.getName()};
 121 
 122     private static final List<String> BAD_COMPONENT_NAMES = List.of(
 123             "clone", "finalize", "getClass", "hashCode", "isValueObject",
 124             "notify", "notifyAll", "toString", "wait");
 125 
 126     /* simplest annotation processor just to force a round of annotation processing for all tests
 127      */
 128     @SupportedAnnotationTypes("*")
 129     public static class SimplestAP extends AbstractProcessor {
 130         @Override
 131         public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
 132             return true;
 133         }
 134     }
 135 
 136     boolean useAP;
 137 
 138     public RecordCompilationTests() {
 139         useAP = System.getProperty("useAP", "false").equals("true");
 140         setDefaultFilename("R.java");
 141         if (useAP) {
 142             setCompileOptions(OPTIONS_WITH_AP);
 143         }
< prev index next >