⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 manual.html

📁 一个用于对.class文件进行插桩的开源工具
💻 HTML
📖 第 1 页 / 共 5 页
字号:
    integer number. Within signatures they are represented by single    characters, e.g., <tt>I</tt>, for integer. Arrays are denoted with    a <tt>[</tt> at the start of the signature.  </p>                            </blockquote>        </p>      </td></tr>      <tr><td><br/></td></tr>    </table>                                                <table border="0" cellspacing="0" cellpadding="2" width="100%">      <tr><td bgcolor="#525D76">        <font color="#ffffff" face="arial,helvetica,sanserif">          <a name="2.6 Code example"><strong>2.6 Code example</strong></a>        </font>      </td></tr>      <tr><td>        <blockquote>                                    <p>    The following example program prompts for a number and prints the    faculty of it. The <tt>readLine()</tt> method reading from the    standard input may raise an <tt>IOException</tt> and if a    misspelled number is passed to <tt>parseInt()</tt> it throws a    <tt>NumberFormatException</tt>. Thus, the critical area of code    must be encapsulated in a <tt>try-catch</tt> block.  </p>                                                    <div align="left">    <table cellspacing="4" cellpadding="0" border="0">    <tr>      <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>      <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>      <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>    </tr>    <tr>      <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>      <td bgcolor="#ffffff"><pre>      import java.io.*;    public class Faculty {      private static BufferedReader in = new BufferedReader(new                                InputStreamReader(System.in));      public static final int fac(int n) {        return (n == 0)? 1 : n * fac(n - 1);      }      public static final int readInt() {        int n = 4711;        try {        System.out.print(&quot;Please enter a number&gt; &quot;);        n = Integer.parseInt(in.readLine());        } catch(IOException e1) { System.err.println(e1); }        catch(NumberFormatException e2) { System.err.println(e2); }        return n;      }      public static void main(String[] argv) {        int n = readInt();        System.out.println(&quot;Faculty of &quot; + n + &quot; is &quot; + fac(n));      }    }  </pre></td>      <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>    </tr>    <tr>      <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>      <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>      <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>    </tr>    </table>    </div>                                                <p>    This code example typically compiles to the following chunks of    byte code:  </p>                                                    <div align="left">    <table cellspacing="4" cellpadding="0" border="0">    <tr>      <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>      <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>      <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>    </tr>    <tr>      <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>      <td bgcolor="#ffffff"><pre>    0:  iload_0    1:  ifne            #8    4:  iconst_1    5:  goto            #16    8:  iload_0    9:  iload_0    10: iconst_1    11: isub    12: invokestatic    Faculty.fac (I)I (12)    15: imul    16: ireturn    LocalVariable(start_pc = 0, length = 16, index = 0:int n)  </pre></td>      <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>    </tr>    <tr>      <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>      <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>      <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>    </tr>    </table>    </div>                                                <p><b>fac():</b>    The method <tt>fac</tt> has only one local variable, the argument    <tt>n</tt>, stored at index 0. This variable's scope ranges from    the start of the byte code sequence to the very end.  If the value    of <tt>n</tt> (the value fetched with <tt>iload_0</tt>) is not    equal to 0, the <tt>ifne</tt> instruction branches to the byte    code at offset 8, otherwise a 1 is pushed onto the operand stack    and the control flow branches to the final return.  For ease of    reading, the offsets of the branch instructions, which are    actually relative, are displayed as absolute addresses in these    examples.  </p>                                                <p>    If recursion has to continue, the arguments for the multiplication    (<tt>n</tt> and <tt>fac(n - 1)</tt>) are evaluated and the results    pushed onto the operand stack.  After the multiplication operation    has been performed the function returns the computed value from    the top of the stack.  </p>                                                    <div align="left">    <table cellspacing="4" cellpadding="0" border="0">    <tr>      <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>      <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>      <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>    </tr>    <tr>      <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>      <td bgcolor="#ffffff"><pre>    0:  sipush        4711    3:  istore_0    4:  getstatic     java.lang.System.out Ljava/io/PrintStream;    7:  ldc           &quot;Please enter a number&gt; &quot;    9:  invokevirtual java.io.PrintStream.print (Ljava/lang/String;)V    12: getstatic     Faculty.in Ljava/io/BufferedReader;    15: invokevirtual java.io.BufferedReader.readLine ()Ljava/lang/String;    18: invokestatic  java.lang.Integer.parseInt (Ljava/lang/String;)I    21: istore_0    22: goto          #44    25: astore_1    26: getstatic     java.lang.System.err Ljava/io/PrintStream;    29: aload_1    30: invokevirtual java.io.PrintStream.println (Ljava/lang/Object;)V    33: goto          #44    36: astore_1    37: getstatic     java.lang.System.err Ljava/io/PrintStream;    40: aload_1    41: invokevirtual java.io.PrintStream.println (Ljava/lang/Object;)V     44: iload_0    45: ireturn    Exception handler(s) =     From    To      Handler Type    4       22      25      java.io.IOException(6)    4       22      36      NumberFormatException(10)  </pre></td>      <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>    </tr>    <tr>      <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>      <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>      <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>    </tr>    </table>    </div>                                                <p><b>readInt():</b> First the local variable <tt>n</tt> (at index 0)    is initialized to the value 4711.  The next instruction,    <tt>getstatic</tt>, loads the referencs held by the static    <tt>System.out</tt> field onto the stack. Then a string is loaded    and printed, a number read from the standard input and assigned to    <tt>n</tt>.  </p>                                                <p>    If one of the called methods (<tt>readLine()</tt> and    <tt>parseInt()</tt>) throws an exception, the Java Virtual Machine    calls one of the declared exception handlers, depending on the    type of the exception.  The <tt>try</tt>-clause itself does not    produce any code, it merely defines the range in which the    subsequent handlers are active. In the example, the specified    source code area maps to a byte code area ranging from offset 4    (inclusive) to 22 (exclusive).  If no exception has occurred    ("normal" execution flow) the <tt>goto</tt> instructions branch    behind the handler code. There the value of <tt>n</tt> is loaded    and returned.  </p>                                                <p>    The handler for <tt>java.io.IOException</tt> starts at    offset 25. It simply prints the error and branches back to the    normal execution flow, i.e., as if no exception had occurred.  </p>                            </blockquote>        </p>      </td></tr>      <tr><td><br/></td></tr>    </table>                                                <table border="0" cellspacing="0" cellpadding="2" width="100%">      <tr><td bgcolor="#525D76">        <font color="#ffffff" face="arial,helvetica,sanserif">          <a name="3 The BCEL API"><strong>3 The BCEL API</strong></a>        </font>      </td></tr>      <tr><td>        <blockquote>                                    <p>    The <font face="helvetica,arial">BCEL</font> API abstracts from    the concrete circumstances of the Java Virtual Machine and how to    read and write binary Java class files. The API mainly consists    of three parts:  </p>                                                <p>    <ol type="1">    <li> A package that contains classes that describe "static"    constraints of class files, i.e., reflects the class file format and    is not intended for byte code modifications. The classes may be    used to read and write class files from or to a file.  This is    useful especially for analyzing Java classes without having the    source files at hand.  The main data structure is called    <tt>JavaClass</tt> which contains methods, fields, etc..</li>    <li> A package to dynamically generate or modify    <tt>JavaClass</tt> or <tt>Method</tt> objects.  It may be used to    insert analysis code, to strip unnecessary information from class    files, or to implement the code generator back-end of a Java    compiler.</li>    <li> Various code examples and utilities like a class file viewer,    a tool to convert class files into HTML, and a converter from    class files to the <a href="http://mrl.nyu.edu/~meyer/jasmin/">Jasmin</a> assembly    language.</li>    </ol>  </p>                            </blockquote>        </p>      </td></tr>      <tr><td><br/></td></tr>    </table>                                                <table border="0" cellspacing="0" cellpadding="2" width="100%">      <tr><td bgcolor="#525D76">        <font color="#ffffff" face="arial,helvetica,sanserif">          <a name="3.1 JavaClass"><strong>3.1 JavaClass</strong></a>        </font>      </td></tr>      <tr><td>        <blockquote>                                    <p>    The "static" component of the <font face="helvetica,arial">BCEL</font> API resides in the package     <tt>org.apache.bcel.classfile</tt> and closely represents class     files. All of the binary components and data structures declared     in the <a href="http://java.sun.com/docs/books/vmspec/index.html">JVM     specification</a> and described in section <a href="#2 The Java Virtual Machine">2</a> are mapped to classes.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -