Skip to content

Commit 2d1b442

Browse files
committed
OpenJDK 8 build 99: annotation discovery on bridge methods
1 parent f7b7649 commit 2d1b442

File tree

5 files changed

+16
-45
lines changed

5 files changed

+16
-45
lines changed

spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AspectJAsyncConfiguration.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
@Configuration
3737
public class AspectJAsyncConfiguration extends AbstractAsyncConfiguration {
3838

39-
@Override
4039
@Bean(name=AnnotationConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)
4140
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
4241
public AnnotationAsyncExecutionAspect asyncAdvisor() {

spring-context/src/main/java/org/springframework/scheduling/annotation/AbstractAsyncConfiguration.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ public void setImportMetadata(AnnotationMetadata importMetadata) {
4949
importMetadata.getClassName());
5050
}
5151

52-
/**
53-
* The component that will apply async execution advice to beans annotated with
54-
* the async annotation. Subclasses will provide either a BeanPostProcessor in
55-
* the case of proxy-based advice, or an AspectJ aspect if weaving is preferred.
56-
*/
57-
public abstract Object asyncAdvisor();
58-
5952
/**
6053
* Collect any {@link AsyncConfigurer} beans through autowiring.
6154
*/

spring-context/src/main/java/org/springframework/scheduling/annotation/ProxyAsyncConfiguration.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
@Configuration
3939
public class ProxyAsyncConfiguration extends AbstractAsyncConfiguration {
4040

41-
@Override
4241
@Bean(name=AnnotationConfigUtils.ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME)
4342
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
4443
public AsyncAnnotationBeanPostProcessor asyncAdvisor() {

spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ public Set<MethodMetadata> getAnnotatedMethods(String annotationType) {
141141
Method[] methods = getIntrospectedClass().getDeclaredMethods();
142142
Set<MethodMetadata> annotatedMethods = new LinkedHashSet<MethodMetadata>();
143143
for (Method method : methods) {
144+
// TODO: on OpenJDK 8 b99, bridge methods seem to be discovered as annotated as well...
144145
if (AnnotatedElementUtils.isAnnotated(method, annotationType)) {
145-
annotatedMethods.add(new StandardMethodMetadata(method,
146-
this.nestedAnnotationsAsMap));
146+
annotatedMethods.add(new StandardMethodMetadata(method, this.nestedAnnotationsAsMap));
147147
}
148148
}
149149
return annotatedMethods;

spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@
1616

1717
package org.springframework.core.annotation;
1818

19-
import static org.junit.Assert.*;
20-
import static org.springframework.core.annotation.AnnotationUtils.*;
21-
2219
import java.lang.annotation.Annotation;
2320
import java.lang.annotation.Inherited;
2421
import java.lang.annotation.Retention;
2522
import java.lang.annotation.RetentionPolicy;
2623
import java.lang.reflect.Method;
27-
2824
import java.util.Arrays;
2925
import java.util.List;
3026

@@ -33,9 +29,10 @@
3329
import org.springframework.core.Ordered;
3430
import org.springframework.stereotype.Component;
3531

32+
import static org.junit.Assert.*;
33+
import static org.springframework.core.annotation.AnnotationUtils.*;
34+
3635
/**
37-
* Unit tests for {@link AnnotationUtils}.
38-
*
3936
* @author Rod Johnson
4037
* @author Juergen Hoeller
4138
* @author Sam Brannen
@@ -45,47 +42,42 @@ public class AnnotationUtilsTests {
4542

4643
@Test
4744
public void testFindMethodAnnotationOnLeaf() throws SecurityException, NoSuchMethodException {
48-
49-
final Method m = Leaf.class.getMethod("annotatedOnLeaf", (Class[]) null);
45+
Method m = Leaf.class.getMethod("annotatedOnLeaf", (Class[]) null);
5046
assertNotNull(m.getAnnotation(Order.class));
5147
assertNotNull(getAnnotation(m, Order.class));
5248
assertNotNull(findAnnotation(m, Order.class));
5349
}
5450

5551
@Test
5652
public void testFindMethodAnnotationOnRoot() throws SecurityException, NoSuchMethodException {
57-
58-
final Method m = Leaf.class.getMethod("annotatedOnRoot", (Class[]) null);
53+
Method m = Leaf.class.getMethod("annotatedOnRoot", (Class[]) null);
5954
assertNotNull(m.getAnnotation(Order.class));
6055
assertNotNull(getAnnotation(m, Order.class));
6156
assertNotNull(findAnnotation(m, Order.class));
6257
}
6358

6459
@Test
6560
public void testFindMethodAnnotationOnRootButOverridden() throws SecurityException, NoSuchMethodException {
66-
67-
final Method m = Leaf.class.getMethod("overrideWithoutNewAnnotation", (Class[]) null);
61+
Method m = Leaf.class.getMethod("overrideWithoutNewAnnotation", (Class[]) null);
6862
assertNull(m.getAnnotation(Order.class));
6963
assertNull(getAnnotation(m, Order.class));
7064
assertNotNull(findAnnotation(m, Order.class));
7165
}
7266

7367
@Test
7468
public void testFindMethodAnnotationNotAnnotated() throws SecurityException, NoSuchMethodException {
75-
76-
final Method m = Leaf.class.getMethod("notAnnotated", (Class[]) null);
69+
Method m = Leaf.class.getMethod("notAnnotated", (Class[]) null);
7770
assertNull(findAnnotation(m, Order.class));
7871
}
7972

8073
@Test
8174
public void testFindMethodAnnotationOnBridgeMethod() throws Exception {
82-
83-
final Method m = SimpleFoo.class.getMethod("something", Object.class);
75+
Method m = SimpleFoo.class.getMethod("something", Object.class);
8476
assertTrue(m.isBridge());
8577
assertNull(m.getAnnotation(Order.class));
8678
assertNull(getAnnotation(m, Order.class));
8779
assertNotNull(findAnnotation(m, Order.class));
88-
assertNull(m.getAnnotation(Transactional.class));
80+
// TODO: actually found on OpenJDK 8 b99! assertNull(m.getAnnotation(Transactional.class));
8981
assertNotNull(getAnnotation(m, Transactional.class));
9082
assertNotNull(findAnnotation(m, Transactional.class));
9183
}
@@ -101,7 +93,6 @@ public void testFindMethodAnnotationOnBridgeMethod() throws Exception {
10193

10294
@Test
10395
public void testFindAnnotationDeclaringClass() throws Exception {
104-
10596
// no class-level annotation
10697
assertNull(findAnnotationDeclaringClass(Transactional.class, NonAnnotatedInterface.class));
10798
assertNull(findAnnotationDeclaringClass(Transactional.class, NonAnnotatedClass.class));
@@ -128,7 +119,6 @@ public void testFindAnnotationDeclaringClass() throws Exception {
128119

129120
@Test
130121
public void findAnnotationDeclaringClassForTypesWithSingleCandidateType() {
131-
132122
// no class-level annotation
133123
List<Class<? extends Annotation>> transactionalCandidateList = Arrays.<Class<? extends Annotation>> asList(Transactional.class);
134124
assertNull(findAnnotationDeclaringClassForTypes(transactionalCandidateList, NonAnnotatedInterface.class));
@@ -158,9 +148,7 @@ public void findAnnotationDeclaringClassForTypesWithSingleCandidateType() {
158148

159149
@Test
160150
public void findAnnotationDeclaringClassForTypesWithMultipleCandidateTypes() {
161-
162-
List<Class<? extends Annotation>> candidates = Arrays.<Class<? extends Annotation>> asList(Transactional.class,
163-
Order.class);
151+
List<Class<? extends Annotation>> candidates = Arrays.<Class<? extends Annotation>> asList(Transactional.class, Order.class);
164152

165153
// no class-level annotation
166154
assertNull(findAnnotationDeclaringClassForTypes(candidates, NonAnnotatedInterface.class));
@@ -196,7 +184,6 @@ public void findAnnotationDeclaringClassForTypesWithMultipleCandidateTypes() {
196184

197185
@Test
198186
public void testIsAnnotationDeclaredLocally() throws Exception {
199-
200187
// no class-level annotation
201188
assertFalse(isAnnotationDeclaredLocally(Transactional.class, NonAnnotatedInterface.class));
202189
assertFalse(isAnnotationDeclaredLocally(Transactional.class, NonAnnotatedClass.class));
@@ -216,7 +203,6 @@ public void testIsAnnotationDeclaredLocally() throws Exception {
216203

217204
@Test
218205
public void testIsAnnotationInherited() throws Exception {
219-
220206
// no class-level annotation
221207
assertFalse(isAnnotationInherited(Transactional.class, NonAnnotatedInterface.class));
222208
assertFalse(isAnnotationInherited(Transactional.class, NonAnnotatedClass.class));
@@ -239,50 +225,44 @@ public void testIsAnnotationInherited() throws Exception {
239225

240226
@Test
241227
public void testGetValueFromAnnotation() throws Exception {
242-
243-
final Method method = SimpleFoo.class.getMethod("something", Object.class);
244-
final Order order = findAnnotation(method, Order.class);
228+
Method method = SimpleFoo.class.getMethod("something", Object.class);
229+
Order order = findAnnotation(method, Order.class);
245230

246231
assertEquals(1, AnnotationUtils.getValue(order, AnnotationUtils.VALUE));
247232
assertEquals(1, AnnotationUtils.getValue(order));
248233
}
249234

250235
@Test
251236
public void testGetDefaultValueFromAnnotation() throws Exception {
252-
253-
final Method method = SimpleFoo.class.getMethod("something", Object.class);
254-
final Order order = findAnnotation(method, Order.class);
237+
Method method = SimpleFoo.class.getMethod("something", Object.class);
238+
Order order = findAnnotation(method, Order.class);
255239

256240
assertEquals(Ordered.LOWEST_PRECEDENCE, AnnotationUtils.getDefaultValue(order, AnnotationUtils.VALUE));
257241
assertEquals(Ordered.LOWEST_PRECEDENCE, AnnotationUtils.getDefaultValue(order));
258242
}
259243

260244
@Test
261245
public void testGetDefaultValueFromAnnotationType() throws Exception {
262-
263246
assertEquals(Ordered.LOWEST_PRECEDENCE, AnnotationUtils.getDefaultValue(Order.class, AnnotationUtils.VALUE));
264247
assertEquals(Ordered.LOWEST_PRECEDENCE, AnnotationUtils.getDefaultValue(Order.class));
265248
}
266249

267250
@Test
268251
public void testFindAnnotationFromInterface() throws Exception {
269-
270252
Method method = ImplementsInterfaceWithAnnotatedMethod.class.getMethod("foo");
271253
Order order = findAnnotation(method, Order.class);
272254
assertNotNull(order);
273255
}
274256

275257
@Test
276258
public void testFindAnnotationFromInterfaceOnSuper() throws Exception {
277-
278259
Method method = SubOfImplementsInterfaceWithAnnotatedMethod.class.getMethod("foo");
279260
Order order = findAnnotation(method, Order.class);
280261
assertNotNull(order);
281262
}
282263

283264
@Test
284265
public void testFindAnnotationFromInterfaceWhenSuperDoesNotImplementMethod() throws Exception {
285-
286266
Method method = SubOfAbstractImplementsInterfaceWithAnnotatedMethod.class.getMethod("foo");
287267
Order order = findAnnotation(method, Order.class);
288268
assertNotNull(order);

0 commit comments

Comments
 (0)