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 symbols.
*/
public Scope scope = null;
/** The number of enclosing `static' modifiers.
*/
public int staticLevel = 0;
/** Is this an environment for a this(...) or super(...) call?
*/
public boolean isSelfCall = false;
/** Are we evaluating the selector of a `super' or type name?
*/
public boolean selectSuper = false;
/** Are arguments to current function applications boxed into an array for varargs?
*/
public boolean varArgs = false;
/** A list of type variables that are all-quantifed in current context.
*/
public List<Type> typeVars = List.nil();
/** A record of the lint/SuppressWarnings currently in effect
*/
public Lint lint;
/** The variable whose initializer is being attributed
* useful for detecting self-references in variable initializers
*/
public Symbol enclVar = null;
// ...
}
获取这个AtrContext的对象可调用dup()方法,如下:
/** Duplicate this context, replacing scope field and copying all others.
*/
public AttrContext dup(Scope scope) {
AttrContext info = new AttrContext();
info.scope = scope;
info.staticLevel = staticLevel;
info.isSelfCall = isSelfCall;
info.selectSuper = selectSuper;
info.varArgs = varArgs;
info.typeVars = typeVars;
info.lint = lint;
info.enclVar = enclVar;
return info;
}
调用的地方如下截图。

另外一个dup()方法代码如下:
/** Duplicate this context, copying all fields.
*/
public AttrContext dup() {
return dup(scope);
}
调用的地方如下截图。

1、staticLevel属性

只有变量、方法或者静态块时才会对staticLevel进行加1操作,对于静态类时不对此值进行操作。
不能在静态或者非静态方法或者静态/非静态块中出现static修饰的变量与类,如:
Object o = new Object(){
// The field b cannot be declared static in a non-static inner type,
// unless initialized with a constant expression
static int b = 2;
};
class InnerD{
// The member type InnerE cannot be declared static;
// static types can only be declared in static or top level types
static class InnerE{}
}
static{
static int a = 1;
static class InnerA{}
}
public void methodA(){
static int a = 1;
static class InnerA{}
}
2、selectSuper属性
英文注释:Are we evaluating the selector of a `super' or type name?
举例如下:
public class TestScope {
class A{
public void t() throws CloneNotSupportedException{
TestScope.super.clone();
}
}
}
当在Attr类的visitSelect中对TestScope.super进行标记时,则这个属性会设置为true
3、typeVars属性
这个属性写入的地方如下:

读取值的地方如下:

AttrContext的更多相关文章
- Annotate类
在Annotate类中有个Annotator接口,定义如下: /** A client that has annotations to add registers an annotator, * th ...
- Attr.checkId()方法
1.符号sym是TYP02 举个例子,如下: package bazola; class Point { // ... } class Tree<A> { class AttrVisito ...
- Scope及其子类介绍
之前写的文章: 关于作用域范围Scope Scope及相关的子类如下: 同时有些Scope还继承了Scope.ScopeListener类,如下: 1.StarImportScope及ImportSc ...
- Check类的validate方法解读
此方法的实现如下: public void validate(JCTree tree, Env<AttrContext> env, boolean checkRaw) { Validato ...
- Javac之Environment
关于Env的源代码如下: /** A class for environments, instances of which are passed as * arguments to tree visi ...
- Javac之关于方法的调用1
方法的调用从Attr类的visitApply()方法进入,如下: /** Visitor method for method invocations. * NOTE: The method part ...
- javac的Resolve类解读
方法1:isInitializer() /** An environment is an "initializer" if it is a constructor or * an ...
- JDK8在泛型类型推导上的变化
概述 JDK8升级,大部分问题可能在编译期就碰到了,但是有些时候比较蛋疼,编译期没有出现问题,但是在运行期就出了问题,比如今天要说的这个话题,所以大家再升级的时候还是要多测测再上线,当然JDK8给我们 ...
随机推荐
- authentication 和 authorization
单词 词性 解释 authentication n. 认证 authentic adj. 真实的 authorization n. 授权 authorise vt. 授权 authentication ...
- JS数组去重算法实现
之前一段时间一直在准备面试, 因而博客太久没更新: 现在基本知识点都复习完毕, 接下来就分享下 面试的一些常见问题: 去正规的互联网公司笔试.面试有很大的概率会碰到 使用javascript实现数组去 ...
- (并查集)小希的迷宫 --HDU -- 1272
链接: http://acm.hdu.edu.cn/showproblem.php?pid=1272 http://acm.hust.edu.cn/vjudge/contest/view.action ...
- android免root hook框架legend
一.前言 Android中hook框架已经非常多了,最优秀的当属Xposed和Substrate了,这两个框架我在之前的文章都详细介绍过了,不了解的同学,可以转战这里:http://www.wjdia ...
- Windows / Windows Phone 8.1 预留应用名称及应用上传
最近比较懒好久没有来这里跟大家聊了,WP 8.1 的 preview 发布已经有一阵子了,并且商店支持 8.1 应用也有一段时间了.我就把这篇 8.1 的应用商店预留提交作为 8.1 的一个开始吧. ...
- CSS2.1SPEC:视觉格式化模型之包含块
原汁原味的才是最有味道的,在阅读CSS标准时对这一点的体会更加深刻了,阅读文档后的一大感觉就是很多看上去理所应当的样式表现也都有了对应的支持机制.本文首先从包含块写起,一方面总结标准中相应的阐述,并且 ...
- 将tomcat添加到服务中
转载自:http://blog.csdn.net/zjd934784273/article/details/47701011(windows) :http://www.cnblogs.com/ilah ...
- 688. Knight Probability in Chessboard
On an NxN chessboard, a knight starts at the r-th row and c-th column and attempts to make exactly K ...
- 通过修改EIP寄存器实现32位程序的DLL注入
功能:通过修改EIP寄存器实现32位程序的DLL注入 <如果是64位 记得自己对应修改汇编代码部分> 原理:挂起目标进程,停止目标进程EIP的变换,在目标进程开启空间,然后把相关的指令机器 ...
- hdu4815----dp0-1背包
/* 题目大意: 有n个问题,,告诉你答对该题能得多少分,其中一个人随机答题,问另一个人不输的概率为p 至少需要答多多少分 对于样例: 3 0.5 1 2 3 分析: 分数 0 1 2 3 3 4 5 ...