Summary
-------
Retrofit `java.lang.reflect.Parameter` to implement `java.lang.reflect.Member`.
Problem
-------
Unnecessarily board least-common supertype of `Parameter` and similar reflection modeling classes.
Solution
--------
Retrofit `java.lang.reflect.Parameter` to implement `java.lang.reflect.Member`, adding an implementing of the one missing method.
Specification
-------------
diff --git a/src/java.base/share/classes/java/lang/reflect/Parameter.java b/src/java.base/share/classes/java/lang/r
eflect/Parameter.java
index 780319585ab..7e7f7dd59f6 100644
--- a/src/java.base/share/classes/java/lang/reflect/Parameter.java
+++ b/src/java.base/share/classes/java/lang/reflect/Parameter.java
@@ -27,6 +27,7 @@ package java.lang.reflect;
import java.lang.annotation.*;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import java.util.Objects;
import sun.reflect.annotation.AnnotationSupport;
@@ -39,7 +40,7 @@ import sun.reflect.annotation.AnnotationSupport;
*
* @since 1.8
*/
-public final class Parameter implements AnnotatedElement {
+public final class Parameter implements AnnotatedElement, Member {
private final String name;
private final int modifiers;
@@ -148,6 +149,19 @@ public final class Parameter implements AnnotatedElement {
return executable;
}
+ /**
+ * {@return the class object of the {@code Executable} declaring
+ * this parameter}
+ * @implSpec
+ * The returned value is equal to {@code
+ * getDeclaringExecutable().getDeclaringClass()}.
+ * @since 19
+ */
+ @Override
+ public Class<?> getDeclaringClass() {
+ return executable.getDeclaringClass();
+ }
+
/**
* {@return the Java language {@linkplain Modifier modifiers} for
* the parameter represented by this object}