ASM介绍.pptxVIP

  • 9
  • 0
  • 约9.37千字
  • 约 30页
  • 2017-12-26 发布于河北
  • 举报
ASM介绍

ASM(3.0) 简介ASM ------一种Java 字节码操控框架。ASM基本功能: ASM既可以分析已有的class文件,也可以修改已有类,增强其功能 , 亦可以直接生成class文件。 ASM 现在作为主流的AOP编程工具。ASM的优势ASM功能强大,几乎可以完全操纵类。ASM使用较简单,不要求使用者对 Java class文件的格式了熟于心,即并不需要处理如计算二进制文件偏移量之类的细节。ASM效率高,速度快(直接硬编码在新生成的类文件内部,并非采用反射机制,即使同其他流行的 Java 字节码操纵工具相比效率依很高)。ASM--ModelThe ASM library provides two APIs for generating and transforming compiled classes: the core API provides an event based representation of classes, while the tree API provides an object based representation.ASM provides both APIs because there is no best API. Indeed each API has its own advantages and drawbacks:advantages and drawbacks of the two API’s? The event based API is faster and requires less memory than the object based API, since there is no need to create and store in memory a tree of objects representing the class.? However implementing class transformations can be more di?cult with the event based API, since only one element of the class is available at any given time (the element that corresponds to the current event), while the whole class is available in memory with the object based API.the core APIWith the event based model a class is represented with a sequence of events,each event representing an element of the class, such as its header, a ?eld, a method declaration, an instruction, etc. The event based API de?nes the set of possible events and the order in which they must occur, and provides a class parser that generates one event per element that is parsed, as well as a class writer that generates compiled classes from sequences of such events.the tree APIWith the object based model a class is represented with a tree of objects, each object representing a part of the class, such as the class itself, a ?eld, a method, an instruction, etc.and each object having references to the objects that represent its constituents. The object based API provides a way to convert a sequence of events representing a class to the object tree representing the same class and, vice versa

文档评论(0)

1亿VIP精品文档

相关文档