AttrContext】的更多相关文章

info属性类型为AttrContext或AttrContextEnv.主要看AtrContext即可.定义了如下关键参数: /** Contains information specific to the attribute and enter * passes, to be used in place of the generic field in environments. * */ public class AttrContext { /** The scope of local sym…
在Annotate类中有个Annotator接口,定义如下: /** A client that has annotations to add registers an annotator, * the method it will use to add the annotation. There are no * parameters; any needed data should be captured by the * Annotator. */ public interface Anno…
1.符号sym是TYP02 举个例子,如下: package bazola; class Point { // ... } class Tree<A> { class AttrVisitor { // ... } } class PointTree extends Tree<Point> { public void test(){ // 会将PointTree.AttrVisitor更改为Tree<Point>.AttrVisitor PointTree.AttrVis…
之前写的文章: 关于作用域范围Scope Scope及相关的子类如下: 同时有些Scope还继承了Scope.ScopeListener类,如下: 1.StarImportScope及ImportScope 在JCCompilationUnit中定义了两个属性,其类型就是这两个类型: public ImportScope namedImportScope; public StarImportScope starImportScope; 但在初始化JCCompilationUnit语法节点时并不初…
此方法的实现如下: public void validate(JCTree tree, Env<AttrContext> env, boolean checkRaw) { Validator vr = new Validator(env,Check.this); vr.validateTree(tree, checkRaw, true); } 这个方法在Attr中有两处调用,如下: checkRaw为false表示不用检查是否为Raw类型.这样就不会出现这样的警告 ”找到原始类型: {0} 缺…
关于Env的源代码如下: /** A class for environments, instances of which are passed as * arguments to tree visitors. Environments refer to important ancestors * of the subtree that's currently visited, such as the enclosing method, * the enclosing class, or the…
方法的调用从Attr类的visitApply()方法进入,如下: /** Visitor method for method invocations. * NOTE: The method part of an application will have in its type field * the return type of the method, not the method's type itself! */ public void visitApply(JCMethodInvocat…
方法1:isInitializer() /** An environment is an "initializer" if it is a constructor or * an instance initializer. */ static boolean isInitializer(Env<AttrContext> env) { Symbol owner = env.info.scope.owner; return owner.isConstructor() || ow…
概述 JDK8升级,大部分问题可能在编译期就碰到了,但是有些时候比较蛋疼,编译期没有出现问题,但是在运行期就出了问题,比如今天要说的这个话题,所以大家再升级的时候还是要多测测再上线,当然JDK8给我们带来了不少红利,花点时间升级上来还是值得的. 问题描述 还是老规矩,先上demo,让大家直观地知道我们要说的问题. public class Test { static <T extends Number> T getObject() { return (T)Long.valueOf(1L); }…