JDK-5082475 : (reflect) String[] java.lang.reflect.{Method,Constructor}.getParameterNames()
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 1.4.2,5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2004-08-04
  • Updated: 2013-08-14
  • Resolved: 2013-08-14
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
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.
14-08-2013

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
04-08-2004