ASM 4.0 A Java bytecode engineering library Eric Bruneton Copyright c ⃝2007, 20

ASM 4.0 A Java bytecode engineering library Eric Bruneton Copyright c ⃝2007, 2011 Eric Bruneton All rights reserved. Redistribution and use in source (L YX format) and compiled forms (L A T EX, PDF, PostScript, HTML, RTF, etc), with or without modification, are per- mitted provided that the following conditions are met: 1. Redistributions of source code (L YX format) must retain the above copy- right notice, this list of conditions and the following disclaimer. 2. Redistributions in compiled form (converted to L A T EX, PDF, PostScript, HTML, RTF, and other formats) must reproduce the above copyright notice, this list of conditions and the following disclaimer in the docu- mentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this documentation without specific prior written permis- sion. THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDI- RECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Version 2.0, September 2011 Contents 1. Introduction 1 1.1. Motivations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2.1. Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2.2. Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2.3. Architecture . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3. Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.4. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . 6 I. Core API 7 2. Classes 9 2.1. Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.1.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.1.2. Internal names . . . . . . . . . . . . . . . . . . . . . . . 11 2.1.3. Type descriptors . . . . . . . . . . . . . . . . . . . . . . 11 2.1.4. Method descriptors . . . . . . . . . . . . . . . . . . . . . 12 2.2. Interfaces and components . . . . . . . . . . . . . . . . . . . . . 12 2.2.1. Presentation . . . . . . . . . . . . . . . . . . . . . . . . 12 2.2.2. Parsing classes . . . . . . . . . . . . . . . . . . . . . . . 14 2.2.3. Generating classes . . . . . . . . . . . . . . . . . . . . . 16 2.2.4. Transforming classes . . . . . . . . . . . . . . . . . . . . 18 2.2.5. Removing class members . . . . . . . . . . . . . . . . . 22 2.2.6. Adding class members . . . . . . . . . . . . . . . . . . . 23 2.2.7. Transformation chains . . . . . . . . . . . . . . . . . . . 25 2.3. Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.3.1. Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 2.3.2. TraceClassVisitor . . . . . . . . . . . . . . . . . . . . 27 2.3.3. CheckClassAdapter . . . . . . . . . . . . . . . . . . . . 28 2.3.4. ASMifier . . . . . . . . . . . . . . . . . . . . . . . . . . 28 i Contents 3. Methods 31 3.1. Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 3.1.1. Execution model . . . . . . . . . . . . . . . . . . . . . . 31 3.1.2. Bytecode instructions . . . . . . . . . . . . . . . . . . . 33 3.1.3. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 35 3.1.4. Exception handlers . . . . . . . . . . . . . . . . . . . . . 38 3.1.5. Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 3.2. Interfaces and components . . . . . . . . . . . . . . . . . . . . . 41 3.2.1. Presentation . . . . . . . . . . . . . . . . . . . . . . . . 41 3.2.2. Generating methods . . . . . . . . . . . . . . . . . . . . 45 3.2.3. Transforming methods . . . . . . . . . . . . . . . . . . . 46 3.2.4. Stateless transformations . . . . . . . . . . . . . . . . . 48 3.2.5. Statefull transformations . . . . . . . . . . . . . . . . . 52 3.3. Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 3.3.1. Basic tools . . . . . . . . . . . . . . . . . . . . . . . . . 58 3.3.2. AnalyzerAdapter . . . . . . . . . . . . . . . . . . . . . 61 3.3.3. LocalVariablesSorter . . . . . . . . . . . . . . . . . . 63 3.3.4. AdviceAdapter . . . . . . . . . . . . . . . . . . . . . . . 65 4. Metadata 67 4.1. Generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 4.1.1. Structure . . . . . . . . . . . . . . . . . . . . . . . . . . 67 4.1.2. Interfaces and components . . . . . . . . . . . . . . . . . uploads/Ingenierie_Lourd/ asm4-guide.pdf

  • 16
  • 0
  • 0
Afficher les détails des licences
Licence et utilisation
Gratuit pour un usage personnel Attribution requise
Partager