1

正如我几天前在官方 Java 支持论坛上发布的那样,我想知道是否可以使用原始 javac 实现从自己的代码中解析 JCTree 符号。

http://forums.oracle.com/forums/thread.jspa?threadID=1774807&tstart=0

JCMethodInvocation object1 = (JCMethodInvocation) objectRef.ref;

解决 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);`
4

1 回答 1

0

我建议您研究 com.sun.tools.javac.main.JavaCompiler 如何进行符号解析。我认为它在#enterTrees(List) 里面

您也可能对http://bitbucket.org/amelentev/juast/和 projectlombok.org项目感兴趣

于 2010-10-30T22:22:50.713 回答