1

I want to get the parameter names of the method of an Interface which is outside the package.

Looks like LocalVariableTableParameterNameDiscoverer can get the parameter names of methods only for the local classes. It does not get the parameter names of methods for the interfaces outside the package.

Please help

  private LocalVariableTableParameterNameDiscoverer namer =new  LocalVariableTableParameterNameDiscoverer();


           Class currentClass = Class.forName("com.soa.process.bpel.runtime.script.ScriptedAlertReporter");
               methods=currentClass.getDeclaredMethods();
               for (int j = 0; j < methods.length; j++)
               { 

                       method=currentClass.getMethod(methods[j].getName(),methods[j].getParameterTypes()); 
                       parameterNames = namer.getParameterNames(method);
                       if(parameterNames!=null && parameterNames.length>0)
                       {

                       }
                }
Parag A
  • 443
  • 2
  • 8
  • 20

1 Answers1

0

It's nothing to do with whether the interface is outside of any package. LocalVariableTableParameterNameDiscoverer works by inspecting debug information generated by the Java compiler. Unfortunately this debug information does not include parameter names for interface methods.

Java 8 lets you access interface parameter names via reflection, or if you're stuck with an earlier Java version you can try Paranamer.

Community
  • 1
  • 1
dnault
  • 8,340
  • 1
  • 34
  • 53