首先来看一下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. ASP.NET Core2基于RabbitMQ对Web前端实现推送功能

    在我们很多的Web应用中会遇到需要从后端将指定的数据或消息实时推送到前端,通常的做法是前端写个脚本定时到后端获取,或者借助WebSocket技术实现前后端实时通讯.因定时刷新的方法弊端很多(已不再采用 ...

  2. memory leak-----tomcat日志warn

    web应用借助于结构:spring mvc + quartz结构,部署到tomcat容器时,shutdown时的error信息: appears to have started a thread na ...

  3. 全面了解SQL

    很多程序员认为SQL是一头难以驯服的野兽.它是为数不多的声明性语言之一,也因为这样,其展示了完全不同于其他的表现形式.命令式语言. 面向对象语言甚至函数式编程语言(虽然有些人觉得SQL 还是有些类似功 ...

  4. [Erlang29]进程收到不是期望的消息时怎么办?

    最近在项目中升级了第三方库,导致本应用gen_server中A进程中: handle_info({add,X},Sum) -> {noreply,Sum+X}; 结果这么简单的一个工作居然不工作 ...

  5. .net core webapi 定义多版本与 Swagger 的文档输出

    前提: 需要nuget  以下两个程序集 Swashbuckle.AspNetCore 我暂时用的是  4.01: Microsoft.AspNetCore.Mvc.Versioning.ApiExp ...

  6. npm 安装less

    npm install less less-loader --save 在style加上lang="less" 就可以直接用了

  7. .Net Core使用HttpClient请求Web API注意事项

    HttpClient 使用HttpClient可以很方便的请求Web API,但在使用时有一些需要注意的地方,不然会给你的程序带来毁灭性的问题. HttpClient是一个继承了IDisposable ...

  8. GO学习笔记 - Go 只有一种循环结构—— for 循环。

    一,Go 只有一种循环结构—— for 循环. 官方教程:https://tour.go-zh.org/flowcontrol/1 Go 只有一种循环结构—— for 循环. 基本的 for 循环包含 ...

  9. 如何成功导入SlidingMenu库?

    SlidingMenu是一个开源的侧滑菜单(https://github.com/jfeinstein10/SlidingMenu).  为大家的安卓程序提供侧滑菜单,这个功能也非常有用. 要想正常使 ...

  10. 利用CXF生成webservice客户端代码

    一.CXF环境的配置 1.下载CXF的zip包. 2.解压.例如:D:\ITSoft\webserviceClientUtils\cxf\apache-cxf-2.7.17 3.配置环境变量:新建变量 ...