Accessing Java API information with Python

I’m looking for a very simple way, from Python, to get information about Java classes:

  • name of the class
  • what it extends and implements
  • methods with returns types and parameters
  • attributes with type information

Basically all of the information you’d need to generate a javadoc.

Is there an existing Python library that can get me this information either for a .java or .class file, doesn’t matter. I’d probably even be okay with something that gets this information from a javadoc.

I know there is javaclass library but that is overkill for what I’m looking for.

Just want to make sure something doesn’t already exist like this before I implement my own.

Answer

If your Python code does not make much use of C based libraries you could run the code in Jython which is Python run on the Java VM.

Otherwise you could write a small Java/jython executable that gets the information and writes it to stdout to be read by a CPython program calling it.

Leave a Reply

Your email address will not be published. Required fields are marked *