0

Is there any way I can find the methods in a ClassOrInterface Declaration?

I'm using javaparser to read in source code which but when I read in multiple classes I have the problem of trying to attach which methods are attached to which classes.

Does anyone have any ideas how I can resolve this? Is there any sort of

class1.getMethods();

which would return a list of MethodDeclaration's that are in that class? Alternatively is there a way that I a MethodDeclaration can return the name of the Class that it is in?

Steven
  • 93
  • 1
  • 11

1 Answers1

0

Don't know what exactly is your requirement but if you want to see a class's methods and variables including private one's, then see java Reflection

Sumit Jain
  • 87
  • 9
  • 1
    javaparser is a parser for java *source code*. Reflection won't help here. – BackSlash Oct 29 '14 at 10:57
  • 1
    The only way i know is this --> Class> c = Class.forName(args[0]); Method[] allMethods = c.getDeclaredMethods(); – Sumit Jain Oct 29 '14 at 11:01
  • @sumitjain That's it thank you ! Class> c = Class.forName(args[0]); Method[] allMethods = c.getDeclaredMethods(); returns it ! perfect thanks a lot! – Steven Oct 29 '14 at 11:09