Questions on documentation and hacking javac

Jonathan Gibbons jonathan.gibbons at oracle.com
Thu Mar 29 14:12:55 PDT 2012


The compiler does not need to load the Code attribute of methods
for classes that have already been compiled, and provides no support
for doing so.

If you want to look at .class files, I suggest you use a library such
as asm to do so.

-- Jon

On 03/29/2012 08:50 PM, Thiago Silva wrote:
> Hello,
>
> not sure if this is the best place to ask this kind of help, I hope
> someone can point me out in the right directions.
>
> I'm looking for any form of documentation on detailed stages of the
> compiler and its classes and overall structure, if such exists. For
> example, docs on the structures, their relationships and detailed
> stages notes. I've noticed the AST being constructed uses some Type
> classes hierarchy and Symbols hierarchy, involving environment objects
> and context objects (and Todos and tasks, and so on and so forth)....I
> can make some sense of them, but hasn't been so easy to get a good
> idea on how to make use of the available code and what are some of the
> requirements to use them. If there is no such docs, then perhaps, a
> few pointers.
>
> Mostly, with quite ease, I've been able to change the parser, added a
> few kinds of nodes to the ASTs and (with less confidence) I was able
> to resolve the identifiers, types and method signature consistency on
> my new syntax.
>
> Now, the actual problem: I need to create callgraphs from any A.x() to
> any B.y() given (supposedly, A and B are classes either existing on
> the classpath or are inputs to the the current compilation and should
> be present on the AST constructed). I've identified I should do this
> before the Flow stage.
>
> To build the callgraph, I certainly need to inspect method bodies
> looking for calls, and I will encounter a number of C.z() in between
> the graph whose class C were not passed as input to the compiler --
> therefore I should look for them in the classpath. In other words, if
> class A is an input to the compiler, I know I can inspect x's body
> through the AST; but if its not, I don't know if the compiler has the
> code in place to load the class and inspect the body of methods.
>
> I know the compiler can load extra class files, as it must resolve the
> types of identifiers and signatures of methods for variables and
> invocations occurring on the code being compiled (definitions which
> are not part of the current compilation units), but I can tell if
> there is code in place to inspect the methods in .class files.
> Unfortunately, I'm not very acquainted with what is at my disposal.
>
> Thank you in advance for any pointers,
> Thiago




More information about the compiler-dev mailing list