Java类文件结构及javac的ClassReader类解读
首先来看一下ClassFile,类注释如下:
A JVM class file.
Generic Java classfiles have one additional attribute for classes, methods and fields:
"Signature" (u4 attr-length, u2 signature-index)
A signature gives the full Java type of a method or field. When used as a class attribute, it indicates type parameters, followed by supertype, followed by all interfaces.
methodOrFieldSignature ::= type classSignature ::= [ typeparams ] supertype { interfacetype }
The type syntax in signatures is extended as follows:
type ::= ... | classtype | methodtype | typevar classtype ::= classsig { '.' classsig } classig ::= 'L' name [typeargs] ';' methodtype ::= [ typeparams ] '(' { type } ')' type typevar ::= 'T' name ';' typeargs ::= '<' type { type } '>' typeparams ::= '<' typeparam { typeparam } '>' typeparam ::= name ':' type
This class defines constants used in class files as well as routines to convert between internal ``.'' and external ``/'' separators in class names.
一些常量定义(由虚拟机严格规定)如下:
public final static int JAVA_MAGIC = 0xCAFEBABE; // 魔数
// 常量池中14种常量项
public final static int CONSTANT_Utf8 = 1;
public final static int CONSTANT_Unicode = 2;
public final static int CONSTANT_Integer = 3;
public final static int CONSTANT_Float = 4;
public final static int CONSTANT_Long = 5;
public final static int CONSTANT_Double = 6;
public final static int CONSTANT_Class = 7;
public final static int CONSTANT_String = 8;
public final static int CONSTANT_Fieldref = 9;
public final static int CONSTANT_Methodref = 10;
public final static int CONSTANT_InterfaceMethodref = 11;
public final static int CONSTANT_NameandType = 12;
public final static int CONSTANT_MethodHandle = 15;
public final static int CONSTANT_MethodType = 16;
public final static int CONSTANT_InvokeDynamic = 18;
public final static int MAX_PARAMETERS = 0xff; // max_parameters
public final static int MAX_DIMENSIONS = 0xff; // max_dimensions
public final static int MAX_CODE = 0xffff; // max_code
public final static int MAX_LOCALS = 0xffff; // max_locals
public final static int MAX_STACK = 0xffff; // max_stack
ClassReader类的注释如下:
This class provides operations to read a classfile into an internal representation. The internal representation is anchored in (立足于) a ClassSymbol which contains in its scope symbol representations for all other definitions in the classfile. Top-level Classes themselves appear as members of the scopes of PackageSymbols. Error Diagnoses Buffer Access Constant Pool Access Reading Types Reading Attributes Reading Java-language annotations Reading Symbols Adjusting flags Loading Classes Loading Packages
参考文章:
http://blog.csdn.net/column/details/jvm-principle.html
Java类文件结构及javac的ClassReader类解读的更多相关文章
- 《深入理解Java虚拟机》类文件结构
上节学习回顾 在上一节当中,主要以自己的工作环境简单地介绍了一下自身的一些调优或者说是故障处理经验.所谓百变不离其宗,这个宗就是我们解决问题的思路了. 本节学习重点 在前面几章,我们宏观地了解了虚拟机 ...
- 转: 深入Java虚拟机】之二:Class类文件结构
转载请注明出处:http://blog.csdn.net/ns_code/article/details/17675609 平台无关性 Java是与平台无关的语言,这得益于Java源代码编译后生成的存 ...
- 《深入理解java虚拟机》笔记——简析java类文件结构
一直不太搞得明确jvm究竟是如何进行类载入的,在看资料的过程中迷迷糊糊.在理解类载入之前,首先看看java的类文件结构究竟是如何的,都包含了哪些内容. 最直接的參考当然是官方文档:The Java® ...
- 《深入理解Java虚拟机》-----第6章 类文件结构——Java高级开发必须懂的
代码编译的结果从本地机器码转变为字节码,是存储格式发展的一小步,却是编程语言发展的一大步. 6.1 概述 记得在第一节计算机程序课上我的老师就讲过:“计算机只认识0和1,所以我们写的程序需要经编译器翻 ...
- Java类文件结构详解
概述: Class文件结构是了解虚拟机的重要基础之一,如果想深入的了解虚拟机,Class文件结构是不能不了解的.Class文件是一组以8位字节为基础单位的二进制流,各项数据项目严格按照顺序紧凑地排列在 ...
- 深入理解Java虚拟机(类文件结构+类加载机制+字节码执行引擎)
目录 1.类文件结构 1.1 Class类文件结构 1.2 魔数与Class文件的版本 1.3 常量池 1.4 访问标志 1.5 类索引.父索引与接口索引集合 1.6 字段表集合 1.7 方法集合 1 ...
- 《深入理解java虚拟机》第六章 类文件结构
第六章 类文件结构 6.2 无关性的基石 各种不同平台的虚拟机与所有的平台都统一使用的程序存储格式--字节码(ByteCode)是构成平台无关性的基石.java虚拟机不和包括java在内的任何语言 ...
- Java虚拟机 - Class类文件结构
[深入Java虚拟机]之二:Class类文件结构 平台无关性 Java是与平台无关的语言,这得益于Java源代码编译后生成的存储字节码的文件,即Class文件,以及Java虚拟机的实现.不仅使用Jav ...
- 深入了解Java虚拟机(3)类文件结构
虚拟机执行子系统 一.类文件结构 1.魔数和class版本 1.magic-魔数:0xCAFEBABE:4字节 2.minor_version:次版本,丶之后的数字:2字节 3.major_versi ...
随机推荐
- ZOJ3700 Ever Dream 2017-04-06 23:22 76人阅读 评论(0) 收藏
Ever Dream Time Limit: 2 Seconds Memory Limit: 65536 KB "Ever Dream" played by Nigh ...
- linux gitlab-ctl reconfigure报错问题修复 502
Running handlers: There was an error running gitlab-ctl reconfigure: bash[migrate gitlab-rails datab ...
- C#获取枚举的描述
public enum StatusEnum { /// <summary> /// 运行中 /// </summary> [Description("运行中&quo ...
- Monthly数据类型
Monthly由来 最近在做关于智能财税的项目,大量用到了账期相关的数据操作.项目已有两年历史了,对于账期数据,前辈们用的是DateTime数据类型,即每个月的最后一天就是账期.而用DateTime来 ...
- [uwp]MVVM模式实战之必应壁纸查看器
最近学习MVVM,至于什么是MVVM我也在这儿不多说了,一是关于它的解释解释网上非常多,二是我怕自己讲不清,误导自己没关系,误导别人就不好了.. 好了,废话结束,看是实战...... 这个必应壁纸的d ...
- sharepoint 2013工具
caml designer 2013 生成caml工具 http://camlbuilder.codeplex.com/ 设计工具 CamlDesigner2013 爬网工具 HtmlAgilityP ...
- Android 如何查看源码 (eclipse 按住 ctrl )
首先要确认 Android SDK Manager 下载并安装了 sources.然后在代码中按住 ctrl 在点一个类名, 如果打开的页面是找不到源码,就点那个按钮,然后找到源码所在的文件夹,就可以 ...
- leetcode 72 编辑距离 JAVA
题目: 给定两个单词 word1 和 word2,计算出将 word1 转换成 word2 所使用的最少操作数 . 你可以对一个单词进行如下三种操作: 插入一个字符 删除一个字符 替换一个字符 示例 ...
- Java50道经典习题-程序18 乒乓球赛
题目:两个乒乓球队进行比赛,各出三人.甲队为a,b,c三人,乙队为x,y,z三人.已抽签决定比赛名单.有人向队员打听比赛的名单. a说他不和x比,c说他不和x,z比,请编程序找出三队赛手的名单.分析: ...
- Spark Streaming初步使用以及工作原理详解
在大数据的各种框架中,hadoop无疑是大数据的主流,但是随着电商企业的发展,hadoop只适用于一些离线数据的处理,无法应对一些实时数据的处理分析,我们需要一些实时计算框架来分析数据.因此出现了很多 ...