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给我们 ...
 
随机推荐
- C++和Python混合编程
			
为何人工智能(AI)首选Python?读完这篇文章你就知道了:https://blog.csdn.net/qq_41769259/article/details/79419322 C++调用Pytho ...
 - Java中的I/O  线程  网络
			
Java学习总结--I/O,线程,网络题目整理 I/O 1.有什么理由必须要用字符流? 答:处理字符数据的语法更方便.自动化字符编码 2.插入哪些代码可以让下面的代码正确编译? Console con ...
 - bootstrap-treeview 关于checkbox选择框不显示的问题
			
bootstrap-treeview.js 1.0.2 不支持checkbox,最后使用 bootstrap-treeview.js 1.2.0 解决此问题.
 - Android:手把手教你打造可缩放移动的ImageView(上)
			
定义ImageView,实现功能如下: 1.初始化时图片垂直居中显示,拉伸图片宽度至ImageView宽度. 2.使用两根手指放大缩小图片,可设置最大放大倍数,当图片小于ImageView宽度时,在手 ...
 - 万能的ctrl+shift+F(Element 'beans' cannot have character [children], because the type's content type is element-only.错误)
			
今天在spring-servlet.xml文件中出现了一个莫名其妙的错误:Element 'beans' cannot have character [children], because the t ...
 - 在 IIS8 中保持网站持续运行
			
在早期版本的 IIS 中执行轮询任务不那么可靠.应用程序池回收后,网站不会自动重启,在新的请求激活应用程序之前,轮询任务不起作用.为了解决这个问题,需要引入外力驱动 Web 端执行任务,如图: 此方式 ...
 - Jersey构建Restful风格的Webserivces(三)
			
一.总体说明 通过jersey-client接口,创建客户端程序,来调用Jersey实现的RESTful服务,实现增.删.改.查等操作. 服务端主要是通过内存的方式,来模拟用户的增加.删除.修改.查询 ...
 - Ajax 访问 或 获取 IIS 虚拟目录
			
使用场景 最近用 .net core mvc 写了一个工具类的项目,作为我们项目的后台管理网站使用.第一次被老大拿去部署的时候被告知不可用,同样的代码在我电脑和我的iis上都可以使用的啊. 后来才知道 ...
 - SQL Server  错误:924 解决方法
			
USE master; GO DECLARE @SQL VARCHAR(MAX); SET @SQL='' SELECT @SQL=@SQL+'; KILL '+RTRIM(SPID) FROM ma ...
 - ASP.NET Core使用EPPlus操作Excel
			
1.前言 本篇文章通过ASP.NET Core的EPPlus包去操作Excel(导入导出),其使用原理与NPOI类似,导出Excel的时候不需要电脑上安装office,非常好用 2.使用 新建一个AS ...