Skip to content

Commit 1bca2c0

Browse files
committed
LocalVariableTableParameterNameDiscoverer works for bridge methods as well
Issue: SPR-9429
1 parent 0c45f17 commit 1bca2c0

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

org.springframework.core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,12 +39,11 @@
3939
/**
4040
* Implementation of {@link ParameterNameDiscoverer} that uses the LocalVariableTable
4141
* information in the method attributes to discover parameter names. Returns
42-
* <code>null</code> if the class file was compiled without debug information.
42+
* {@code null} if the class file was compiled without debug information.
4343
*
44-
* <p>Uses ObjectWeb's ASM library for analyzing class files. Each discoverer
45-
* instance caches the ASM discovered information for each introspected Class, in a
46-
* thread-safe manner. It is recommended to reuse discoverer instances
47-
* as far as possible.
44+
* <p>Uses ObjectWeb's ASM library for analyzing class files. Each discoverer instance
45+
* caches the ASM discovered information for each introspected Class, in a thread-safe
46+
* manner. It is recommended to reuse ParameterNameDiscoverer instances as far as possible.
4847
*
4948
* @author Adrian Colyer
5049
* @author Costin Leau
@@ -64,15 +63,15 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD
6463

6564

6665
public String[] getParameterNames(Method method) {
67-
Class<?> declaringClass = method.getDeclaringClass();
66+
Method originalMethod = BridgeMethodResolver.findBridgedMethod(method);
67+
Class<?> declaringClass = originalMethod.getDeclaringClass();
6868
Map<Member, String[]> map = this.parameterNamesCache.get(declaringClass);
6969
if (map == null) {
70-
// initialize cache
7170
map = inspectClass(declaringClass);
7271
this.parameterNamesCache.put(declaringClass, map);
7372
}
7473
if (map != NO_DEBUG_INFO_MAP) {
75-
return map.get(method);
74+
return map.get(originalMethod);
7675
}
7776
return null;
7877
}
@@ -82,14 +81,12 @@ public String[] getParameterNames(Constructor ctor) {
8281
Class<?> declaringClass = ctor.getDeclaringClass();
8382
Map<Member, String[]> map = this.parameterNamesCache.get(declaringClass);
8483
if (map == null) {
85-
// initialize cache
8684
map = inspectClass(declaringClass);
8785
this.parameterNamesCache.put(declaringClass, map);
8886
}
8987
if (map != NO_DEBUG_INFO_MAP) {
9088
return map.get(ctor);
9189
}
92-
9390
return null;
9491
}
9592

0 commit comments

Comments
 (0)