5

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.

4
  • 4
    No, regex is not suited for this. Consider class Foo { String s = "not an @Annotation here"; }. Commented Jun 25, 2010 at 17:42
  • Ok, so I would have to use a grammar or an automata to do it. Is there any perl/python module that could help me do this sort of thing? Commented Jun 25, 2010 at 17:53
  • @Bart Actually you could regex to not consider thing in double quotes. The problem is with braces, once you can't really count how many opening and closing braces happened so far in a regex. Commented Jun 25, 2010 at 19:23
  • 1
    @Samuel, sure. Note that I didn't say one couldn't use regex. I said regex isn't suited for such a task. Commented Jun 25, 2010 at 19:29

3 Answers 3

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.