Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4894447

(reflect) Need To Access Parameter Objects in java.lang.Method

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P5
    • Resolution: Duplicate
    • Affects Version/s: 1.4.2
    • Fix Version/s: 8
    • Component/s: core-libs
    • Labels:

      Description



      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)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                darcy Joe Darcy
                Reporter:
                jleesunw Jon Lee (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: