@@ -100,14 +100,40 @@ public void findMethodAnnotationOnBridgeMethod() throws Exception {
100
100
// }
101
101
102
102
@ Test
103
- public void findAnnotationPrefersInterfacesOverLocalMetaAnnotations () {
103
+ public void findAnnotationFavorsInterfacesOverLocalMetaAnnotations () {
104
104
Component component = AnnotationUtils .findAnnotation (
105
- ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface .class , Component .class );
105
+ ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface .class , Component .class );
106
+ assertNotNull (component );
106
107
107
108
// By inspecting ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface, one
108
109
// might expect that "meta2" should be found; however, with the current
109
110
// implementation "meta1" will be found.
111
+ assertEquals ("meta1" , component .value ());
112
+ }
113
+
114
+ @ Test
115
+ public void findAnnotationFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations () {
116
+ Transactional transactional = AnnotationUtils .findAnnotation (SubSubClassWithInheritedAnnotation .class ,
117
+ Transactional .class );
118
+ assertNotNull (transactional );
119
+
120
+ // By inspecting SubSubClassWithInheritedAnnotation, one might expect that the
121
+ // readOnly flag should be true, since the immediate superclass is annotated with
122
+ // @Composed2; however, with the current implementation the readOnly flag will be
123
+ // false since @Transactional is declared as @Inherited.
124
+ assertFalse ("readOnly flag for SubSubClassWithInheritedAnnotation" , transactional .readOnly ());
125
+ }
126
+
127
+ @ Test
128
+ public void findAnnotationFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations () {
129
+ Component component = AnnotationUtils .findAnnotation (SubSubClassWithInheritedMetaAnnotation .class ,
130
+ Component .class );
110
131
assertNotNull (component );
132
+
133
+ // By inspecting SubSubClassWithInheritedMetaAnnotation, one might expect that
134
+ // "meta2" should be found, since the immediate superclass is annotated with
135
+ // @Meta2; however, with the current implementation "meta1" will be found since
136
+ // @Meta1 is declared as @Inherited.
111
137
assertEquals ("meta1" , component .value ());
112
138
}
113
139
@@ -350,14 +376,15 @@ public void getRepeatableFromMethod() throws Exception {
350
376
}
351
377
352
378
353
- @ Component (value = "meta1" )
379
+ @ Component (value = "meta1" )
354
380
@ Order
355
381
@ Retention (RetentionPolicy .RUNTIME )
382
+ @ Inherited
356
383
@interface Meta1 {
357
384
}
358
385
359
- @ Component (value = "meta2" )
360
- @ Transactional
386
+ @ Component (value = "meta2" )
387
+ @ Transactional ( readOnly = true )
361
388
@ Retention (RetentionPolicy .RUNTIME )
362
389
@interface Meta2 {
363
390
}
@@ -395,6 +422,28 @@ static interface InterfaceWithMetaAnnotation {
395
422
static class ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface implements InterfaceWithMetaAnnotation {
396
423
}
397
424
425
+ @ Meta1
426
+ static class ClassWithInheritedMetaAnnotation {
427
+ }
428
+
429
+ @ Meta2
430
+ static class SubClassWithInheritedMetaAnnotation extends ClassWithInheritedMetaAnnotation {
431
+ }
432
+
433
+ static class SubSubClassWithInheritedMetaAnnotation extends SubClassWithInheritedMetaAnnotation {
434
+ }
435
+
436
+ @ Transactional
437
+ static class ClassWithInheritedAnnotation {
438
+ }
439
+
440
+ @ Meta2
441
+ static class SubClassWithInheritedAnnotation extends ClassWithInheritedAnnotation {
442
+ }
443
+
444
+ static class SubSubClassWithInheritedAnnotation extends SubClassWithInheritedAnnotation {
445
+ }
446
+
398
447
@ MetaMeta
399
448
static class MetaMetaAnnotatedClass {
400
449
}
@@ -453,6 +502,8 @@ public void overrideWithoutNewAnnotation() {
453
502
@ Retention (RetentionPolicy .RUNTIME )
454
503
@ Inherited
455
504
@interface Transactional {
505
+
506
+ boolean readOnly () default false ;
456
507
}
457
508
458
509
public static abstract class Foo <T > {
0 commit comments