首先来看一下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. OpenGl中的Nurbs B样条曲面的封装的GLU的NURBS的接口

    OpenGl中的Nurbs B样条曲面的封装的GLU的NURBS的接口 创建一个NURBS对象: GLUnurbs* gluNewNurbsRenderer (void); //创建一个NURBS对象 ...

  2. C++ 的Tool工具收集

    C++ 的Tool工具收集 1. muparser - Fast Math Parser Library 数学公式解析函数,开源工具库 网址: http://muparser.beltoforion. ...

  3. Android-有序广播是可以中断的

    在之前的博客,Android-广播概念,中介绍了(广播和广播接收者)可以组件与组件之间进行通讯,有两种类型的广播(无序广播 和 有序广播),这篇博客就来讲解有序广播的代码实现: 有序广播:接收者 可以 ...

  4. LINQ to Entity里面不能使用DateTime

    LINQ中不能直接使用DateTime,否则会报错:‘The specified type member 'Date' is not supported in LINQ to Entities. On ...

  5. Tempdb--Snapshot

    The insert operation does not cause a row version to be generated because there is really no prvious ...

  6. 浅谈由管理者角色引出的B端产品设计思考点

    本文来自网易云社区 作者:任琼瑶 最近一直都在持续跟进云课堂B端的交互设计,在此期间,多多少少遇到了一些不曾遇到过的问题,虽然同是做产品设计,但B端和C端产品的确存在很多不同之处. 首先,当我们在做C ...

  7. 如何将JPG格式的图片转化为带地理坐标的TIFF格式

    最近有个项目需要用到开源软件GeoServer,数据源是一张高分辨率的2.5维图片,格式是jpg的,由于GeoServer不支持jpg格式的发布,因此考虑到要进行格式转换,将其转换成tiff格式. 1 ...

  8. 多实例mysql的安装和管理【验证通过】

    mysql的多实例有两种方式可以实现,两种方式各有利弊.第一种是使用多个配置文件启动不同的进程来实现多实例,这种方式的优势逻辑简单,配置简单,缺点是管理起来不太方便.第二种是通过官方自带的mysqld ...

  9. SpringMvc-ModelAndView 结果出不来 显示路径问题 解决办法

    今天写SpringMVC的时候  写ModelAndView的时候 死活跳不过页面去-一直报错 显示路径也错误 查看导包问题 应该: import org.springframework.web.se ...

  10. webpack 踩的坑

    我是看着这篇博客学习的 http://www.jianshu.com/p/42e11515c10f# 看到loaders的时候,按照博主写法去试 结果报错....找了好久,上网查了好多 也看错误信息了 ...