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 ...
随机推荐
- Android-FileUtils-工具类
FileUtils-工具类 是对文件操作处理的方法进行了封装,提供了公共的方法: package common.library.utils; import android.annotation.Sup ...
- 利用人工智能(Magpie开源库)给一段中文的文本内容进行分类打标签
当下人工智能是真心的火热呀,各种原来传统的业务也都在尝试用人工智能技术来处理,以此来节省人工成本,提高生产效率.既然有这么火的利器,那么我们就先来简单认识下什么是人工智能吧,人工智能是指利用语音识别. ...
- Java和.net对比分析
.Net和Java是国内市场占有率最高的两门技术,对于准备学习编程语言的初学者来说,.Net和Java是初学者首先考虑的两门技术,因此很多人一遍遍的问“学.Net还是学Java”,社区中也每天都有“. ...
- [Erlang36]kerl轻松管理安装各种OTP版本
kerl只有一个目标:让我们在不同的OTP版本间随意切换.他是一个纯Bash项目.简单实用的工作利器! Readme里面用法已说明得非常清楚了.建议按流程来一次. 1.下载 安装(一个bash脚本,根 ...
- bootstrap-table简单使用
开发项目时总想着能不能有一款插件包含分页,查询等常用功能,后来发现了bootstrap-table 直接看代码和效果图 <!DOCTYPE html> <html lang=&quo ...
- Windows服务器管理与优化
一.服务器自动重启windows服务器运行时间长了,内存会爆满,比如数据库会缓存大量的数量,IIS进程也会缓存数据而没有及时释放.这样需要定时重启服务器来释放内存. 创建任务计划,如在 每周一/周三/ ...
- javascript做的一个根据table中某个td的值为日期时的倒计时
JavaScript代码: <script> window.onload = window.onload = function () { getTdValue(); } //根据传过来的天 ...
- 爬取lol皮肤
#!/usr/bin/python # -*- coding: utf-8 -*- # data:2018-11-23 # user:fei import re import requests imp ...
- 初学python之路-day15
一.生成器send方法 # send的工作原理 # 1.send发送信息给当前停止的yield # 2.再去调用__next__()方法,生成器接着往下指向,返回下一个yield值并停止 # 案例: ...
- 【OCP|052】OCP最新题库解析系列-2
2.Which two are true about Optimizer Statistics? ❑ A) They do not persist across Instance restarts. ...