Questions on documentation and hacking javac

Thiago Silva tbls at cin.ufpe.br
Thu Mar 29 12:50:04 PDT 2012


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