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给我们 ...
随机推荐
- hdu 1231 最大连续子序列 ,1003 Max Sum;
题目(1231) #include<stdio.h> #include<iostream> using namespace std; int main() { int K,nu ...
- DagScheduler 和 TaskScheduler
DagScheduler 和 TaskScheduler 的任务交接 spark 调度器分为两个部分, 一个是 DagScheduler, 一个是 TaskScheduler, DagSchedule ...
- Fig723.asy
import settings; outformat="pdf"; tex="xelatex"; usepackage("amsmath") ...
- 简便方法搞定第三方SDK的Jar包在DelphiXE5中的引入
简便方法搞定第三方SDK的Jar包在DelphiXE5中的引入 (2014-02-21 17:30:17) 转载▼ 标签: android delphi xe5 jar sdk 分类: 编程杂集 折腾 ...
- asp.net 网站监控方案
前言:监控web网站方法有很多种,这篇文章说一下对windows服务器 asp.net网站的监控 采用的方案,Powershell + Influxdb + Grafana 1.PowerShell ...
- ASP.NET Core 2 学习笔记(七)路由
ASP.NET Core通过路由(Routing)设定,将定义的URL规则找到相对应行为:当使用者Request的URL满足特定规则条件时,则自动对应到相符合的行为处理.从ASP.NET就已经存在的架 ...
- 3D Spherical Geometry Kernel( Geometry Kernels) CGAL 4.13 -User Manual
Introduction The goal of the 3D spherical kernel is to offer to the user a large set of functionalit ...
- [Xamarin]我的Xamarin填坑之旅(二)
上一篇交代了我Xamarin填坑的背景,大概聊了聊第一步环境配置,第二步创建项目和开发框架选择.如果有一个可用的梯子,这部分基本不会出错. 接下来就具体聊一聊写代码的过程中遇到的一些事儿. 第三步是码 ...
- chrome 插件学习笔记(一)
主要是屏蔽cnbeta中屏蔽广告之后的弹出层 manifest.json文件 { "js": ["jquery-1.7.2.min.js","cnbe ...
- C - 前m大的数 (结构体)
点击打开链接 还记得Gardon给小希布置的那个作业么?(上次比赛的1005)其实小希已经找回了原来的那张数表,现在她想确认一下她的答案是否正确,但是整个的答案是很庞大的表,小希只想让你把答案中最大的 ...