-
CSR
-
Resolution: Withdrawn
-
P4
-
None
-
binary
-
minimal
-
Changes to abstract or default modifiers in non-open sealed hierarchy has minimal compatibility risk.
-
Java API
-
SE
Summary
Remove the abstract
modifier on a few Executable
methods.
Problem
Some fields shared between Method
and Constructor
are now moved to Executable
. Thus, implementation methods are moved, and some previously abstract
methods are no longer abstract
.
Methods include getDeclaringClass
, getModifiers
, getParameterTypes
, getParameterCount
, getExceptionTypes
, and getParameterAnnotations
.
Solution
Remove the abstract
modifier on the methods listed above.
Specification
diff --git a/src/java.base/share/classes/java/lang/reflect/Executable.java b/src/java.base/share/classes/java/lang/reflect/Executable.java
index b808e052fb2..7416cf1d73e 100644
--- a/src/java.base/share/classes/java/lang/reflect/Executable.java
+++ b/src/java.base/share/classes/java/lang/reflect/Executable.java
@@ -196,7 +219,9 @@ String sharedToGenericString(int modifierMask, boolean isDefault) {
* Returns the {@code Class} object representing the class or interface
* that declares the executable represented by this object.
*/
- public abstract Class<?> getDeclaringClass();
+ public Class<?> getDeclaringClass() {
+ return clazz;
+ }
/**
* Returns the name of the executable represented by this object.
@@ -208,7 +233,9 @@ String sharedToGenericString(int modifierMask, boolean isDefault) {
* the executable represented by this object}
* @see #accessFlags
*/
- public abstract int getModifiers();
+ public int getModifiers() {
+ return modifiers;
+ }
/**
* {@return an unmodifiable set of the {@linkplain AccessFlag
@@ -266,7 +285,9 @@ public Set<AccessFlag> accessFlags() {
* represents
*/
@SuppressWarnings("doclint:reference") // cross-module links
- public abstract Class<?>[] getParameterTypes();
+ public Class<?>[] getParameterTypes() {
+ return parameterTypes.length == 0 ? parameterTypes : parameterTypes.clone();
+ }
/**
* Returns the number of formal parameters (whether explicitly
@@ -276,7 +297,9 @@ public Set<AccessFlag> accessFlags() {
* @return The number of formal parameters for the executable this
* object represents
*/
- public abstract int getParameterCount();
+ public int getParameterCount() {
+ return parameterTypes.length;
+ }
/**
* Returns an array of {@code Type} objects that represent the
@@ -507,7 +530,9 @@ byte[] getTypeAnnotationBytes() {
- @return the exception types declared as being thrown by the
- executable this object represents
*/
- public abstract Class<?>[]
getExceptionTypes();
+ public Class<?>[] getExceptionTypes() {
+ return exceptionTypes.length == 0 ? exceptionTypes : exceptionTypes.clone();
+ }
/**
* Returns an array of {@code Type} objects that represent the
@@ -598,10 +623,7 @@ public boolean isSynthetic() {
* the formal and implicit parameters, in declaration order, of
* the executable represented by this object
*/
- public abstract Annotation[][] getParameterAnnotations();
-
- Annotation[][] sharedGetParameterAnnotations(Class<?>[] parameterTypes,
- byte[] parameterAnnotations) {
+ public Annotation[][] getParameterAnnotations() {
int numParameters = parameterTypes.length;
if (parameterAnnotations == null)
return new Annotation[numParameters][0];
- csr of
-
JDK-8336275 Move common Method and Constructor fields to Executable
-
- Open
-