< prev index next >

test/jdk/java/lang/annotation/TestConstructorParameterAnnotations.java

Print this page




 112             if (!Objects.equals(annotationString, expectedString)) {
 113                 System.err.println("Annotation mismatch on " + ctor +
 114                                    " on param " + param +
 115                                    "\n\tExpected:" + expectedString +
 116                                    "\n\tActual:  " + annotationString);
 117                 errors++;
 118             }
 119             i++;
 120         }
 121         return errors;
 122     }
 123 
 124     @ExpectedGetParameterAnnotations("[[]]")
 125     @ExpectedParameterAnnotations({"null"})
 126     public class NestedClass0 {
 127         public NestedClass0() {}
 128     }
 129 
 130     @ExpectedGetParameterAnnotations(
 131         "[[], " +
 132         "[@TestConstructorParameterAnnotations$MarkerAnnotation(value=1)]]")
 133     @ExpectedParameterAnnotations({
 134         "null",
 135         "@TestConstructorParameterAnnotations$MarkerAnnotation(value=1)"})
 136     public class NestedClass1 {
 137         public NestedClass1(@MarkerAnnotation(1) int parameter) {}
 138     }
 139 
 140     @ExpectedGetParameterAnnotations(
 141         "[[], " +
 142         "[@TestConstructorParameterAnnotations$MarkerAnnotation(value=2)], " +
 143         "[]]")
 144     @ExpectedParameterAnnotations({
 145         "null",
 146         "@TestConstructorParameterAnnotations$MarkerAnnotation(value=2)",
 147         "null"})
 148     public class NestedClass2 {
 149         public NestedClass2(@MarkerAnnotation(2) int parameter1,
 150                             int parameter2) {}
 151     }
 152 
 153     @ExpectedGetParameterAnnotations(
 154         "[[], " +
 155         "[@TestConstructorParameterAnnotations$MarkerAnnotation(value=3)], " +
 156         "[]]")
 157     @ExpectedParameterAnnotations({
 158         "null",
 159         "@TestConstructorParameterAnnotations$MarkerAnnotation(value=3)",
 160             "null"})
 161     public class NestedClass3 {
 162         public <P> NestedClass3(@MarkerAnnotation(3) P parameter1,
 163                                 int parameter2) {}
 164     }
 165 
 166     @ExpectedGetParameterAnnotations(
 167         "[[], " +
 168         "[@TestConstructorParameterAnnotations$MarkerAnnotation(value=4)], " +
 169         "[]]")
 170     @ExpectedParameterAnnotations({
 171         "null",
 172         "@TestConstructorParameterAnnotations$MarkerAnnotation(value=4)",
 173         "null"})
 174     public class NestedClass4 {
 175         public <P, Q> NestedClass4(@MarkerAnnotation(4) P parameter1,
 176                                    Q parameter2) {}
 177     }
 178 
 179     @ExpectedGetParameterAnnotations("[]")
 180     @ExpectedParameterAnnotations({"null"})
 181     public static class StaticNestedClass0 {
 182         public StaticNestedClass0() {}
 183     }
 184 
 185     @ExpectedGetParameterAnnotations(
 186         "[[@TestConstructorParameterAnnotations$MarkerAnnotation(value=1)]]")
 187     @ExpectedParameterAnnotations({
 188         "@TestConstructorParameterAnnotations$MarkerAnnotation(value=1)"})
 189     public static class StaticNestedClass1 {
 190         public StaticNestedClass1(@MarkerAnnotation(1) int parameter) {}
 191     }
 192 
 193     @ExpectedGetParameterAnnotations(
 194         "[[@TestConstructorParameterAnnotations$MarkerAnnotation(value=2)], " +
 195         "[]]")
 196     @ExpectedParameterAnnotations({
 197         "@TestConstructorParameterAnnotations$MarkerAnnotation(value=2)",
 198         "null"})
 199     public static class StaticNestedClass2 {
 200         public StaticNestedClass2(@MarkerAnnotation(2) int parameter1,
 201                             int parameter2) {}
 202     }
 203 
 204     @ExpectedGetParameterAnnotations(
 205         "[[@TestConstructorParameterAnnotations$MarkerAnnotation(value=3)], " +
 206         "[]]")
 207     @ExpectedParameterAnnotations({
 208         "@TestConstructorParameterAnnotations$MarkerAnnotation(value=3)",
 209         "null"})
 210     public static class StaticNestedClass3 {
 211         public <P> StaticNestedClass3(@MarkerAnnotation(3) P parameter1,
 212                                       int parameter2) {}
 213     }
 214 
 215     @ExpectedGetParameterAnnotations(
 216         "[[@TestConstructorParameterAnnotations$MarkerAnnotation(value=4)], " +
 217         "[]]")
 218     @ExpectedParameterAnnotations({
 219         "@TestConstructorParameterAnnotations$MarkerAnnotation(value=4)",
 220         "null"})
 221     public static class StaticNestedClass4 {
 222         public <P, Q> StaticNestedClass4(@MarkerAnnotation(4) P parameter1,
 223                                          Q parameter2) {}
 224     }
 225 
 226     @Target(ElementType.PARAMETER)
 227     @Retention(RetentionPolicy.RUNTIME)
 228     @interface MarkerAnnotation {
 229         int value();
 230     }
 231 
 232     /**
 233      * String form of expected value of calling
 234      * getParameterAnnotations on a constructor.
 235      */
 236     @Target(ElementType.TYPE)
 237     @Retention(RetentionPolicy.RUNTIME)
 238     @interface ExpectedGetParameterAnnotations {
 239         String value();


 112             if (!Objects.equals(annotationString, expectedString)) {
 113                 System.err.println("Annotation mismatch on " + ctor +
 114                                    " on param " + param +
 115                                    "\n\tExpected:" + expectedString +
 116                                    "\n\tActual:  " + annotationString);
 117                 errors++;
 118             }
 119             i++;
 120         }
 121         return errors;
 122     }
 123 
 124     @ExpectedGetParameterAnnotations("[[]]")
 125     @ExpectedParameterAnnotations({"null"})
 126     public class NestedClass0 {
 127         public NestedClass0() {}
 128     }
 129 
 130     @ExpectedGetParameterAnnotations(
 131         "[[], " +
 132         "[@TestConstructorParameterAnnotations$MarkerAnnotation(1)]]")
 133     @ExpectedParameterAnnotations({
 134         "null",
 135         "@TestConstructorParameterAnnotations$MarkerAnnotation(1)"})
 136     public class NestedClass1 {
 137         public NestedClass1(@MarkerAnnotation(1) int parameter) {}
 138     }
 139 
 140     @ExpectedGetParameterAnnotations(
 141         "[[], " +
 142         "[@TestConstructorParameterAnnotations$MarkerAnnotation(2)], " +
 143         "[]]")
 144     @ExpectedParameterAnnotations({
 145         "null",
 146         "@TestConstructorParameterAnnotations$MarkerAnnotation(2)",
 147         "null"})
 148     public class NestedClass2 {
 149         public NestedClass2(@MarkerAnnotation(2) int parameter1,
 150                             int parameter2) {}
 151     }
 152 
 153     @ExpectedGetParameterAnnotations(
 154         "[[], " +
 155         "[@TestConstructorParameterAnnotations$MarkerAnnotation(3)], " +
 156         "[]]")
 157     @ExpectedParameterAnnotations({
 158         "null",
 159         "@TestConstructorParameterAnnotations$MarkerAnnotation(3)",
 160             "null"})
 161     public class NestedClass3 {
 162         public <P> NestedClass3(@MarkerAnnotation(3) P parameter1,
 163                                 int parameter2) {}
 164     }
 165 
 166     @ExpectedGetParameterAnnotations(
 167         "[[], " +
 168         "[@TestConstructorParameterAnnotations$MarkerAnnotation(4)], " +
 169         "[]]")
 170     @ExpectedParameterAnnotations({
 171         "null",
 172         "@TestConstructorParameterAnnotations$MarkerAnnotation(4)",
 173         "null"})
 174     public class NestedClass4 {
 175         public <P, Q> NestedClass4(@MarkerAnnotation(4) P parameter1,
 176                                    Q parameter2) {}
 177     }
 178 
 179     @ExpectedGetParameterAnnotations("[]")
 180     @ExpectedParameterAnnotations({"null"})
 181     public static class StaticNestedClass0 {
 182         public StaticNestedClass0() {}
 183     }
 184 
 185     @ExpectedGetParameterAnnotations(
 186         "[[@TestConstructorParameterAnnotations$MarkerAnnotation(1)]]")
 187     @ExpectedParameterAnnotations({
 188         "@TestConstructorParameterAnnotations$MarkerAnnotation(1)"})
 189     public static class StaticNestedClass1 {
 190         public StaticNestedClass1(@MarkerAnnotation(1) int parameter) {}
 191     }
 192 
 193     @ExpectedGetParameterAnnotations(
 194         "[[@TestConstructorParameterAnnotations$MarkerAnnotation(2)], " +
 195         "[]]")
 196     @ExpectedParameterAnnotations({
 197         "@TestConstructorParameterAnnotations$MarkerAnnotation(2)",
 198         "null"})
 199     public static class StaticNestedClass2 {
 200         public StaticNestedClass2(@MarkerAnnotation(2) int parameter1,
 201                             int parameter2) {}
 202     }
 203 
 204     @ExpectedGetParameterAnnotations(
 205         "[[@TestConstructorParameterAnnotations$MarkerAnnotation(3)], " +
 206         "[]]")
 207     @ExpectedParameterAnnotations({
 208         "@TestConstructorParameterAnnotations$MarkerAnnotation(3)",
 209         "null"})
 210     public static class StaticNestedClass3 {
 211         public <P> StaticNestedClass3(@MarkerAnnotation(3) P parameter1,
 212                                       int parameter2) {}
 213     }
 214 
 215     @ExpectedGetParameterAnnotations(
 216         "[[@TestConstructorParameterAnnotations$MarkerAnnotation(4)], " +
 217         "[]]")
 218     @ExpectedParameterAnnotations({
 219         "@TestConstructorParameterAnnotations$MarkerAnnotation(4)",
 220         "null"})
 221     public static class StaticNestedClass4 {
 222         public <P, Q> StaticNestedClass4(@MarkerAnnotation(4) P parameter1,
 223                                          Q parameter2) {}
 224     }
 225 
 226     @Target(ElementType.PARAMETER)
 227     @Retention(RetentionPolicy.RUNTIME)
 228     @interface MarkerAnnotation {
 229         int value();
 230     }
 231 
 232     /**
 233      * String form of expected value of calling
 234      * getParameterAnnotations on a constructor.
 235      */
 236     @Target(ElementType.TYPE)
 237     @Retention(RetentionPolicy.RUNTIME)
 238     @interface ExpectedGetParameterAnnotations {
 239         String value();
< prev index next >