United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-5082475 : (reflect) String[] java.lang.reflect.{Method,Constructor}.getParameterNames()

Details
Type:
Enhancement
Submit Date:
2004-08-04
Status:
Closed
Updated Date:
2013-08-14
Project Name:
JDK
Resolved Date:
2013-08-14
Component:
core-libs
OS:
generic,windows_xp
Sub-Component:
java.lang:reflect
CPU:
x86,generic
Priority:
P4
Resolution:
Duplicate
Affected Versions:
1.4.2,5.0
Fixed Versions:

Related Reports
Duplicate:
Duplicate:
Relates:
Relates:

Sub Tasks

Description
Name: js151677			Date: 08/04/2004


A DESCRIPTION OF THE REQUEST :
Hi,

Until now, the reflection of Java make a great work for the programs that need to call the functions. BUT .. doesn't do so much for the humans that need to read the profile of a method during the execution : The names of the arguments of a method, even if they can be included in the class file with a -g option during the compilation, cannot be accessed via the reflection mecanism.

I am requesting the add of the functions :
String[] getParameterNames() in the class java.lang.reflect.Method
String[] getParameterNames() in the class java.lang.reflect.Constructor

JUSTIFICATION :
This function will help all the programmers of any bean builder or custom IDE.

For example, me :
I am programming a tool to let the user design some specific programs graphically. Actually, my program is limited to display the classes of the arguments of a method and the user have to guess what each argument is for since I have no easy way to obtain their names.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The expected behavior for the 2 functions in java.lang.reflect.Method and class java.lang.reflect.Constructor is the same :

This function will return a null pointer if there is no information about the names in the class where the Method is and will return a array of String if the names are there.

ACTUAL -
No way to obtain the names of the argument of a method or a constructor by reflection.

CUSTOMER SUBMITTED WORKAROUND :
Doing manually a read of the bytecode of the class.

Not every programmer can afford to lose time to do it since it require to read and understand all the low level structure of a class file and been able to unterpret its bytecode.
(Incident Review ID: 295670) 
======================================================================

                                    

Comments
This functionality was added to the platform under JDK-8004729.
Closing as a duplicate.
                                     
2013-08-14
EVALUATION

Not for Tiger.

-- iag@sfbay 2004-08-04

Will consider for a future release.  The names of parameters are available at build time using apt.

###@###.### 2004-08-10
                                     
2004-08-04



Hardware and Software, Engineered to Work Together