首先来看一下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类解读的更多相关文章

  1. 《深入理解Java虚拟机》类文件结构

    上节学习回顾 在上一节当中,主要以自己的工作环境简单地介绍了一下自身的一些调优或者说是故障处理经验.所谓百变不离其宗,这个宗就是我们解决问题的思路了. 本节学习重点 在前面几章,我们宏观地了解了虚拟机 ...

  2. 转: 深入Java虚拟机】之二:Class类文件结构

    转载请注明出处:http://blog.csdn.net/ns_code/article/details/17675609 平台无关性 Java是与平台无关的语言,这得益于Java源代码编译后生成的存 ...

  3. 《深入理解java虚拟机》笔记——简析java类文件结构

    一直不太搞得明确jvm究竟是如何进行类载入的,在看资料的过程中迷迷糊糊.在理解类载入之前,首先看看java的类文件结构究竟是如何的,都包含了哪些内容. 最直接的參考当然是官方文档:The Java® ...

  4. 《深入理解Java虚拟机》-----第6章 类文件结构——Java高级开发必须懂的

    代码编译的结果从本地机器码转变为字节码,是存储格式发展的一小步,却是编程语言发展的一大步. 6.1 概述 记得在第一节计算机程序课上我的老师就讲过:“计算机只认识0和1,所以我们写的程序需要经编译器翻 ...

  5. Java类文件结构详解

    概述: Class文件结构是了解虚拟机的重要基础之一,如果想深入的了解虚拟机,Class文件结构是不能不了解的.Class文件是一组以8位字节为基础单位的二进制流,各项数据项目严格按照顺序紧凑地排列在 ...

  6. 深入理解Java虚拟机(类文件结构+类加载机制+字节码执行引擎)

    目录 1.类文件结构 1.1 Class类文件结构 1.2 魔数与Class文件的版本 1.3 常量池 1.4 访问标志 1.5 类索引.父索引与接口索引集合 1.6 字段表集合 1.7 方法集合 1 ...

  7. 《深入理解java虚拟机》第六章 类文件结构

    第六章 类文件结构   6.2 无关性的基石 各种不同平台的虚拟机与所有的平台都统一使用的程序存储格式--字节码(ByteCode)是构成平台无关性的基石.java虚拟机不和包括java在内的任何语言 ...

  8. Java虚拟机 - Class类文件结构

    [深入Java虚拟机]之二:Class类文件结构 平台无关性 Java是与平台无关的语言,这得益于Java源代码编译后生成的存储字节码的文件,即Class文件,以及Java虚拟机的实现.不仅使用Jav ...

  9. 深入了解Java虚拟机(3)类文件结构

    虚拟机执行子系统 一.类文件结构 1.魔数和class版本 1.magic-魔数:0xCAFEBABE:4字节 2.minor_version:次版本,丶之后的数字:2字节 3.major_versi ...

随机推荐

  1. Centos 下部署tomcat多实例

    基础环境及JDK就不多说了,下面的目录结构以如下为准: 根目录-apps 根目录-apps--tomcat 根目录-apps--ins1 根目录-apps--ins2 ================ ...

  2. linux 进程通信之 管道和FIFO

    进程间通信:IPC概念 IPC:Interprocess Communication,通过内核提供的缓冲区进行数据交换的机制. IPC通信的方式: pipe:管道(最简单) fifo:有名管道 mma ...

  3. 开源WebGIS实施方案(四):GeoServer发布PostGIS数据

    GeoServer可以支持多种格式的数据源,本文只介绍其中一种,即PostGIS数据源. 新建一个工作区.工作区这个名字也是一变再变,早前叫做目录,后来改为工作空间,如今已变为工作区了. 添加数据存储 ...

  4. mysqldump的简单使用

    背景 需要搞mysql数据同步,从一台服务器把数据库同步到另外一台服务器上,如果折腾过的话,就知道有个这玩意--mysqldump,其实就是mysql自带的一个命令而已 操作步骤 1. 认识mysql ...

  5. async异步方法

    在C# 中,可以使用asyc+await来完成一个异步方法. async用来标志一个使用了await的方法是非阻塞API,是一个异步方法,就当成一个普通关键字就行了.关键是await,await是配合 ...

  6. 8-网络请求之http

    本篇博客对应视频讲解 回顾 上一篇讲了Linq的使用,大家自己上手实践之后,相信一定会感到非常快捷方便.更多详细的内容还是需要自己去阅读官方文档. 今天要讲网络请求中的http请求,这也是在编程当中经 ...

  7. (转载)Oracle的悲观锁和乐观锁

    为了得到最大的性能,一般数据库都有并发机制,不过带来的问题就是数据访问的冲突.为了解决这个问题,大多数数据库用的方法就是数据的锁定. 数据的锁定分为两种方法,第一种叫做悲观锁,第二种叫做乐观锁.什么叫 ...

  8. 「BZOJ4318」OSU!

    题目链接 戳我 \(Solution\) 我们考虑每增加一个\(1\)会对答案有什么影响: \[E((x+1)^3)-E(x^3)=E(3x^2+3x+1)=3E(x^2)+3E(x)+1\] 所以我 ...

  9. json相关知识

    整理json相关知识: 1.for in 循环获取json中的键(key)与值(value) <!DOCTYPE html> <html lang="en"> ...

  10. 2018国庆YALI集训游记

    想了想,像之前那样简略地叙述题意和做法,根本没讲清楚,没有任何意义,还不如写写自己的感受. 感觉YALI真的是一所挺不错的学校吧.总是能有一机房的julao轮番吊打你,总是能有集训队的奆佬来给你出dl ...