Tutorial :Parsing Java Class From Perl or Python



Question:

I want to get a .java file, recognize the first class in the file, and get information about annotations, methods and attributes from this class.

Is there any module in both languages that already does that? I could build up a simple regexp to do it also, but I don't known how to recognize in the regexp the braces indicating the end of the class/method.


Solution:1

If you load the java classes inside Jython you probably could use introspection to find the information you need.


Solution:2

Why are you trying this in perl/python rather than just using a javadoc-aware program that can pull out the info?


Solution:3

I would suggest Inline::Java for accessing Java class from Perl,Once you have that interface running, you can easily access methods and attributes from the class.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »