MethodMetadata exposes method return type
Issue: SPR-13024
This commit is contained in:
@@ -39,7 +39,13 @@ public interface MethodMetadata extends AnnotatedTypeMetadata {
|
||||
/**
|
||||
* Return the fully-qualified name of the class that declares this method.
|
||||
*/
|
||||
public String getDeclaringClassName();
|
||||
String getDeclaringClassName();
|
||||
|
||||
/**
|
||||
* Return the fully-qualified name of this method's declared return type.
|
||||
* @since 4.2
|
||||
*/
|
||||
String getReturnTypeName();
|
||||
|
||||
/**
|
||||
* Return whether the underlying method is effectively abstract:
|
||||
|
||||
@@ -84,6 +84,11 @@ public class StandardMethodMetadata implements MethodMetadata {
|
||||
return this.introspectedMethod.getDeclaringClass().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReturnTypeName() {
|
||||
return this.introspectedMethod.getReturnType().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstract() {
|
||||
return Modifier.isAbstract(this.introspectedMethod.getModifiers());
|
||||
|
||||
@@ -76,7 +76,8 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito
|
||||
if ((access & Opcodes.ACC_BRIDGE) != 0) {
|
||||
return super.visitMethod(access, name, desc, signature, exceptions);
|
||||
}
|
||||
return new MethodMetadataReadingVisitor(name, access, getClassName(), this.classLoader, this.methodMetadataSet);
|
||||
return new MethodMetadataReadingVisitor(name, access, getClassName(),
|
||||
Type.getReturnType(desc).getClassName(), this.classLoader, this.methodMetadataSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -44,12 +44,14 @@ import org.springframework.util.MultiValueMap;
|
||||
*/
|
||||
public class MethodMetadataReadingVisitor extends MethodVisitor implements MethodMetadata {
|
||||
|
||||
protected final String name;
|
||||
protected final String methodName;
|
||||
|
||||
protected final int access;
|
||||
|
||||
protected final String declaringClassName;
|
||||
|
||||
protected final String returnTypeName;
|
||||
|
||||
protected final ClassLoader classLoader;
|
||||
|
||||
protected final Set<MethodMetadata> methodMetadataSet;
|
||||
@@ -58,13 +60,14 @@ public class MethodMetadataReadingVisitor extends MethodVisitor implements Metho
|
||||
new LinkedMultiValueMap<String, AnnotationAttributes>(4);
|
||||
|
||||
|
||||
public MethodMetadataReadingVisitor(String name, int access, String declaringClassName,
|
||||
ClassLoader classLoader, Set<MethodMetadata> methodMetadataSet) {
|
||||
public MethodMetadataReadingVisitor(String methodName, int access, String declaringClassName,
|
||||
String returnTypeName, ClassLoader classLoader, Set<MethodMetadata> methodMetadataSet) {
|
||||
|
||||
super(SpringAsmInfo.ASM_VERSION);
|
||||
this.name = name;
|
||||
this.methodName = methodName;
|
||||
this.access = access;
|
||||
this.declaringClassName = declaringClassName;
|
||||
this.returnTypeName = returnTypeName;
|
||||
this.classLoader = classLoader;
|
||||
this.methodMetadataSet = methodMetadataSet;
|
||||
}
|
||||
@@ -79,7 +82,7 @@ public class MethodMetadataReadingVisitor extends MethodVisitor implements Metho
|
||||
|
||||
@Override
|
||||
public String getMethodName() {
|
||||
return this.name;
|
||||
return this.methodName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,4 +147,9 @@ public class MethodMetadataReadingVisitor extends MethodVisitor implements Metho
|
||||
return this.declaringClassName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReturnTypeName() {
|
||||
return this.returnTypeName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user