-
Enhancement
-
Resolution: Duplicate
-
P5
-
1.4.2
-
x86
-
linux
Name: jl125535 Date: 07/22/2003
A DESCRIPTION OF THE REQUEST :
Currently I can get the parameter Classes for a Method via Method.getParameterTypes(). What I can't get is the Objects for those parameters (which can then be introspected).
I can get field values from java.lang.reflect.Field.get() but there is no
way (that I know of) to do the same thing for parameter values of a
Method.
JUSTIFICATION :
Adding this capability will allow for much more useful logging.
I could pass an object instance that caused an exception to a logger
and it could introspect all the data members of the object _and_
all the parameters passed into the method that caused the exception.
This would allow me a better-than-average chance of recreating the
exception off-line.
This would be suitable to production environments where running with
method-callbacks or debugging turned on is inappropriate.
Clearly this information just exist in the JVM (or programs wouldn't
run!) but isn't currently exposed in an API.
EXPECTED VERSUS ACTUAL BEHAVIOR :
I would be very excited to see functionality added to java.lang.reflect.Method
that mirrored what's already available in Field:
public Object[] getParameters( Object obj )
throws IllegalArgumentException, IllegalAccessException;
Pass in the "current" or "active" object, just like in Field.get().
Each object returned represents a parameter object, which can then be
introspected for "painless" detailed logging.
(Incident Review ID: 182223)
======================================================================
- duplicates
-
JDK-8004729 Add java.lang.reflect.Parameter and related changes for parameter reflection
-
- Closed
-
- relates to
-
JDK-7154390 Add support for repeating annotations in j.l.r.AnnotatedElement
-
- Closed
-
-
JDK-7007535 (reflect) Please generalize Constructor and Method
-
- Closed
-
-
JDK-6962494 Update documentation on Executable.getParameterAnnotations()
-
- Closed
-