提交 7c28152c 编写于 作者: S Sam Brannen

Introduce ClassUtils.isInnerClass() utility method

上级 b165475e
......@@ -22,7 +22,6 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Executable;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Parameter;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
......@@ -38,6 +37,7 @@ import kotlin.reflect.jvm.ReflectJvmMapping;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/**
* Helper class that encapsulates the specification of a method parameter, i.e. a {@link Method}
......@@ -519,8 +519,7 @@ public class MethodParameter {
Annotation[][] annotationArray = this.executable.getParameterAnnotations();
int index = this.parameterIndex;
if (this.executable instanceof Constructor &&
this.executable.getDeclaringClass().isMemberClass() &&
!Modifier.isStatic(this.executable.getDeclaringClass().getModifiers()) &&
ClassUtils.isInnerClass(this.executable.getDeclaringClass()) &&
annotationArray.length == this.executable.getParameterCount() - 1) {
// Bug in javac in JDK <9: annotation array excludes enclosing instance parameter
// for inner classes, so access it with the actual parameter index lowered by 1
......
......@@ -209,6 +209,14 @@ public abstract class ClassUtils {
}
}
/**
* Determine if the supplied class is an <em>inner class</em>.
* @return {@code true} if the supplied class is an inner class
*/
public static boolean isInnerClass(Class<?> clazz) {
return clazz != null && clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers());
}
/**
* Replacement for {@code Class.forName()} that also returns Class instances
* for primitives (e.g. "int") and array class names (e.g. "String[]").
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册