Results 1 to 5 of 5

Thread: How to get parameter names at runtime?

  1. #1
    Join Date
    Jul 2010
    Posts
    15

    Default How to get parameter names at runtime?

    Hi,
    I desperately need help on this. I've have been looking all over for a way to do this.
    I am trying to use a @Before advice to print the names and values of the actual arguments of method pointcuts.
    First I thought simply compiling the class files with the -g option will do the trick. That didn't work.
    Then I read in a post somewhere that using AspectJ load-time weaving will for sure do the trick. So I did the following for Tomcat 7:

    In my context.xml
    Code:
    ...
    
      <Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
    ...
    In my config.xml
    Code:
    ...
        <context:load-time-weaver weaver-class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver"/>
    ...
    But still when I call MethodSignature.getParameterNames() it returns null.

    So my question is:
    Is there a way to get the parameter names of a method from within an advice? If so how?

  2. #2
    Join Date
    Jul 2010
    Posts
    15

    Default

    Is LocalVariableTableParameterNameDiscoverer the solution?

  3. #3
    Join Date
    Jul 2010
    Posts
    15

    Default

    LocalVariableTableParameterNameDiscoverer doesn't seem to work either. Is there a solution to this that does not require annotating each and every single parameter on method pointcuts?
    HELLLLLLLLLLLLLLLLLLLLLLP!!!

  4. #4
    Join Date
    Jul 2010
    Posts
    15

    Default

    Can anybody help???

  5. #5
    Join Date
    Jul 2010
    Posts
    15

    Default

    Correction. LocalVariableTableParameterNameDiscoverer does indeed work. I think got caught out by proxies and/or interfaces classes when I tried to use it. However it requires files to be compiled with debug info which is less than desirable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •