JDK-7007535 : (reflect) Please generalize Constructor and Method
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86
  • Submitted: 2010-12-16
  • Updated: 2017-05-16
  • Resolved: 2012-05-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b01Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
Please generalize Constructor and Method (using an interface or an abstract class).

Proposed name is CallableMember, but can be otherwise, of course.

Constructor and Method can be generalized without loss of compatibility and without
complex/expensive research, specification and testing process.

These are a lot of common (thus generalizable) methods of these two classes:
 * Class<?>[] getExceptionTypes()
 * Type[] getGenericExceptionTypes()
 * Class<?>[] getParameterTypes()
 * Type[] getGenericParameterTypes()
 * Annotation[][] getParameterAnnotations()
 * TypeVariable<? extends CallableMember>[] getTypeParameters()
   * would be overridden by Method to: TypeVariable<Method>[]
   * would be overridden by Constructor<?> to: TypeVariable<Constructor<?>>[]
 * boolean isSynthetic()
 * boolean isVarArgs()
 * String toGenericString()

(The generalization of getTypeParameters() can be left out, should it be considered
as not acceptable because of more specific overrides, or for some reasons.)

The generalizing abstract class or interface (CallableMember) should also
implement those interfaces, which are implemented by both Constructor and Method:
 * interface AnnotatedElement
 * interface GenericDeclaration
 * interface Member
 * (in case of abstract class:) AccessibleObject

Please comment on the idea.

Best regards,
Ivan G Shevchenko (assembling DOT signals AT yandex DOT ru)


JUSTIFICATION :
  Tools which use reflection information could profit from it.
An other reason for this RFE is the fact, that semantically, methods and constructors represent
related concepts, especially from the point of view of language syntax.

Comments
PUBLIC COMMENTS See http://hg.openjdk.java.net/jdk8/tl/jdk/rev/d083644bc615
2011-07-20

EVALUATION Will consider for a future release.
2011-05-09