-
Enhancement
-
Resolution: Duplicate
-
P3
-
None
-
1.2.0
-
sparc
-
solaris_2.5.1
Name: sg39081 Date: 11/03/97
Since JDK 1.1, I'm a very active user of the reflection API.
I'm developing an interpreter, and must use the advanced
features of this API.
The new flag in "AccessibleObject" is convenient. I can now
access the field of another package (that I develop) without
having to declare the field as "public".
But things are more complicated with overloaded methods.
When a method is called, my interpreter needs to determine
the best match depending on the given parameters. My
problem is:
"Given a Class object, a method name and an array of Class
objects (deduced from the parameters), how to find the
Method object (public or not public) that is maximally
specific."
If the concerned method is public, I can use
Class.getMethods() to retrieve all the public methods and
then to determine the best match.
If the concerned method is not public, I would like to issue
an warning, or then use the flag in "AccessibleObject" to
turn on the accessibility.
In this case, I have to use Class.getDeclaredMethods(),
then to determine the best match, and I have to go through
the whole class hierarchy to make sure that the best match
is really the best. This is a difficult coding and many
developers will make bugs.
So I would like that JDK provides a method that returns
the Method object (public or not public) having a given
name, and that is maximally specific in regard to the
passed parameters classes. I believe that this feature will
be very useful.
(Review ID: 19565)
======================================================================
- duplicates
-
JDK-4102343 The getMethood() routine only works w/exact types - not w/subclassed types
-
- Closed
-