首先来看一下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. 7、Docker Container

    7.1 什么是Container 通过image创建(copy) 在Image layer之上建立一个Container layer(可读写) 类比面向对象:类和实例 Image负责APP的存储和分发 ...

  2. EBS11i - 常用Profile

      Profile Name 说明 设置建议 FND: Enable Cancel Query 当执行一个超长时间的查询时,会出现一个 Cancel窗口,允许用户取消.比如我们在SO 界面没有输入条件 ...

  3. SqlServer 的一个坑

    以前一直以为sqlserver 在做ddl 操作的时候是锁表的,而oracle 是锁行,感觉oracle 要比sqlserver 先进一些,但是这是我的认识错误.其实sqlserver 也是可以锁行的 ...

  4. CentOS6.5中使用 iperf 检测主机间网络带宽

    安装方式 # yum install http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm# yum inst ...

  5. PPI协议(西门子PLCS7-200)

    西门子PLC S7-200 PPI协议报文,9600,偶校验,8数据位,1停止位 读取vb100寄存器:PC发送报文68 1B 1B 68 2 0 6C 32 1 0 0 0 0 0 E 0 0 4 ...

  6. 在jquery中怎么使用css类名和id来获取元素?

    在jquery中,你可以很容易的使用CSS类名和id类获取元素. 例如: 1.ID:#id $('#idA')——选择id为idA的所有元素,不管元素的标签名如何. $('div#idA')——选择i ...

  7. [JAVA]java复制文件的4种方式

    尽管Java提供了一个可以处理文件的IO操作类. 但是没有一个复制文件的方法. 复制文件是一个重要的操作,当你的程序必须处理很多文件相关的时候. 然而有几种方法可以进行Java文件复制操作,下面列举出 ...

  8. django drf 改变retrive的pk查询字段

    lookup_filed可以改变retrive查询时默认以pk查询的逻辑 from django.shortcuts import render from rest_framework import ...

  9. struts2 Convention插件好处及使用

    现在JAVA开发都流行SSH.而很大部分公司也使用了struts2进行开发..因为struts2提供了很多插件和标签方便使用..在之前开发过程中总发现使用了struts2会出现很多相应的配合文件.如果 ...

  10. Android优化之内存优化倒计时篇

    本文来自网易云社区 作者:聂雷震 本篇文章介绍的内容是如何在安卓手机上实现高效的倒计时效果,这个高效有两个标准:1.刷新频率足够高,让用户觉得这个倒计时的确是倒计时,而不是幻灯片:2.不能占用太多的内 ...