`
mineral
  • 浏览: 291175 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

[10Minutes]Introduction to the ASM 2.0 Bytecode Framework

阅读更多




Introduction 
to the ASM 2.0 Bytecode Framework Introduction to the ASM 2.0 Bytecode Framework

by Eugene Kuleshov
08/17/2005

Java features such as dynamic class loading and reflection make it a dynamic language. However, in many cases, reflection is not sufficient, and developers need to generate bytecode from non-Java source code, such as scripting languages like Groovy (JSR-241) or BeanShell (JSR-274), or from metadata such as an OR-mapping configuration. When working with existing classes, and especially when original Java sources are not available, some tools may need to do a static analysis of the interdependencies or even method behavior in order to produce test coverage or metrics, or to detect bugs and anti-patterns. New features added to into Java 5, such as annotations and generics, affected bytecode structure and require special attention from bytecode manipulation tools to maintain good performance. This article will give an overview of one of the smallest and fastest bytecode manipulation frameworks available for Java.

Framework Structure

The ASM bytecode manipulation framework is written in Java and uses a visitor-based approach to generate bytecode and drive transformations of existing classes. It allows developers to avoid dealing directly with a class constant pool and offsets within method bytecode, thus hiding bytecode complexity from the developer and providing better performance, compared to other tools such as BCEL, SERP, or Javassist.

ASM is divided into several packages that allow flexible bundling. The packaging arrangement is shown in Figure 1.

Arrangement of ASM packages
Figure 1. Arrangement of ASM packages

  • The Core package provides an API to read, write, and transform Java bytecode and defines a foundation for the other packages. This package is sufficient to generate Java bytecode and to implement the majority of bytecode transformations.
  • The Tree package provides in-memory representation of Java bytecode.
  • The Analysis package provides basic data-flow analyses and type-checking algorithms for Java method bytecode stored in structures from the tree package.
  • The Commons package (added in ASM 2.0) provides several commonly used bytecode transformations and adapters to simplify bytecode generation.
  • The Util package contains several helper classes and simple bytecode verifiers that can help in development or testing.
  • The XML package provides an adapter to convert bytecode structures to and from XML, and SAX-compliant adapters that allow the use of XSLT to define bytecode transformations. 

Ref:


分享到:
评论

相关推荐

    asm-2.0.jar.zip

    ASM-2.0.jar是ASM框架的一个早期版本,提供了基础的字节码操作功能。 ASM库的核心功能主要包括: 1. **字节码解析**:ASM可以解析Java类文件,将其转换为一个内部表示形式,这样就可以方便地访问类的结构,如类名...

    ASM ByteCode Viewer IDEA插件

    下载后先解压!里面有2个版本的安装包!下载后先解压!下载后先解压!可以尝试在https://plugins.jetbrains.com/search?products=idea&search=Bytecode Outline下面搜“Bytecode Outline

    asm-util-2.0.jar.zip

    《ASM实用工具库ASM-Util 2.0详解》 ASM-Util 2.0.jar.zip是一个包含ASM库实用工具的压缩文件,主要用于Java字节码操作。在深入探讨ASM-Util 2.0之前,我们需要先理解ASM库的基础概念。 ASM是一个Java字节码操控和...

    ASM Bytecode Viewer Support Kotlin

    AndroidStuido的插件ASM Bytecode Viewer用于展示kotlin/java的字节码,因为AndroidStudio的market经常打不开,现在提供离线包。 安装: File-Settings-Plugins,点击设置按钮,选择“Install Plugin from Disk...”...

    深入字节码 -- 玩转 ASM-Bytecode1

    标题中的“深入字节码 -- 玩转 ASM-Bytecode1”暗示了本文将探讨如何使用ASM库来操作和理解Java字节码。ASM是一个Java字节码操控和分析框架,它允许用户动态生成和修改Java类和注解。在描述中提到,前一篇博文中介绍...

    asm-bytecode-intellij-7.2.zip

    用于Android studio 查看 字节码,ASM Bytecode Viewer,打开Android Studio,FIle -> Setting -> Plugins -> Install Plugins from Disk,选择文件就行,然后重启AS

    OSTC2015-Mozilla张频_Bring Native to the Web_ an introduction to Emscripten and asm

    主题:Bring Native to the Web: an introduction to Emscripten and asm.js 演讲人:张频,谋智网络(Mozilla)软件经理 演讲介绍:Emscripten 是 Mozilla 推出的一个开源编译工具,它能将 C/C++ 程序编译为 ...

    Integrated_Asm2.20

    Integrated_Asm2.20的安装程序,支持XP和Vista

    asm-commons-2.0.jar.zip

    《ASM Commons 2.0.jar.zip:深入理解与应用》 ASM Commons 2.0.jar.zip 是一个包含ASM Commons库的压缩文件,该库是针对Java字节码操作的工具集,广泛应用于Java应用程序和框架的开发。ASM Commons是ASM项目的一...

    asm-attrs-2.0.jar.zip

    标题中的"asm-attrs-2.0.jar.zip"是一个压缩文件,它包含了ASM库的一个特定版本,即ASM Attributes模块的2.0版本。ASM是一个Java字节码操控和分析框架,广泛用于动态代理、代码分析和转换等场景。ASM库主要用于生成...

    org.springframework.asm-3.0.5.RELEASE.jar

    《深入解析Spring ASM库:org.springframework.asm-3.0.5.RELEASE.jar》 Spring框架是Java开发领域中不可或缺的一部分,而org.springframework.asm-3.0.5.RELEASE.jar是Spring框架中的一个关键组件,主要涉及到字节...

    asm-analysis-2.0.jar.zip

    《ASM分析库:深入理解asm-analysis-2.0.jar.zip》 ASM,全称为Advanced Classfile Manipulation,是一个Java字节码操控和分析框架。它主要用于动态生成类或者增强已有类的功能,广泛应用于代码混淆、AOP(面向切面...

    ASM4使用指南 - ASM 4 Guide 中文版

    ASM 4 使用指南中文版。ASM是Java字节码的工业级库。长期以来一直没有中文版。这下好了,中文版横空出世。感兴趣的同学可以投递简历 mars # oneapm ....ASM 4.0 A Java bytecode engineering library

    asm.jar各个版本

    asm-2.0.jar, asm-2.1.jar, asm-2.2.1-sources.jar, asm-2.2.1.jar, asm-2.2.2-sources.jar, asm-2.2.2.jar, asm-2.2.3.jar, asm-2.2.4.jar, asm-2.2.jar, asm-20041228.180559.jar, asm-3.0.jar, asm-3.0_RC1.jar, ...

    org.springframework.asm-3.0.1.RELEASE-A.jar

    rg.springframework.asm-3.0.1.RELEASE-A.jar

    asm-tree-2.0.jar.zip

    《ASM Tree库2.0.jar的深度解析与应用》 ASM是一个Java字节码操控和分析框架,它可以直接动态地修改类或者生成类。而ASM Tree库是ASM的一部分,主要负责将字节码解析成一棵抽象语法树(Abstract Syntax Tree,AST)...

    org.springframework.asm-sources-3.0.5.release.jar

    org.springframework.asm-sources-3.0.5.release.jar

    asm-xml-2.0.jar.zip

    《ASM与XML在Java开发中的应用及asm-xml-2.0.jar.zip解析》 ASM是一个Java字节码操控和分析框架,它可以直接用来动态生成类或者增强已有类的功能。这个框架广泛应用于Java代理技术、AOP(面向切面编程)、代码生成...

    asm bytecode

    ### 字节码(Bytecode)与字节码增强(Bytecode Instrumentation) #### 概述 字节码(Bytecode)是一种中间代码形式,由Java编译器生成,并由Java虚拟机(JVM)解释执行。它允许Java程序在不同平台上运行而无需...

    c32asm(apk编辑器)反汇编工具v2.0.1.0绿色中文免费版

    c32asm是一款非常好用的反汇编工具,该软件使用起来并不难,可以进行反汇编和十六进制编辑,大家试试看吧! 软件介绍 c32asm 的确是款非常好用的反汇编程序,小编测试后发现它的功能已强于winhex 16、W32Dasm,...

Global site tag (gtag.js) - Google Analytics