Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
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) ======================================================================
|