Javac AST Symbol Resolving for JavacTask.parse()
As I posted on the official Java suppo开发者_如何学JAVArt forum several days ago, I want to know, if JCTree Symbols can be resolved from own code with the original javac implementation.
http://forums.oracle.com/forums/thread.jspa?threadID=1774807&tstart=0
JCMethodInvocation object1 = (JCMethodInvocation) objectRef.ref;
Resolve resolve = Resolve.instance(javacTaskImpl.getContext());
ListBuffer<Type> argtypeListBuffer = new ListBuffer<Type>();
AttrContext attrContext = new AttrContext();
Env<AttrContext> env = new Env<AttrContext>((JCTree) objectRef.ref, attrContext);
System.out.println(type);
System.out.println(type.tsym);
resolve.resolveInternalMethod(object1.pos(), env, type, name, argtypeListBuffer.toList(), null);`
I recommend you to investigate how com.sun.tools.javac.main.JavaCompiler do symbol resolving. I think it is inside #enterTrees(List)
Also you may be interested in projects http://bitbucket.org/amelentev/juast/ and projectlombok.org
精彩评论