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

📄 stackmaptable.java

📁 Javassist是一个开源的分析、编辑和创建Java字节码的类库。是由东京技术学院的数学和计算机科学系的 Shigeru Chiba 所创建的。它已加入了开放源代码JBoss 应用服务器项目,通过使
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Javassist, a Java-bytecode translator toolkit. * Copyright (C) 1999-2006 Shigeru Chiba. All Rights Reserved. * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License.  Alternatively, the contents of this file may be used under * the terms of the GNU Lesser General Public License Version 2.1 or later. * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. */package javassist.bytecode;import java.io.DataInputStream;import java.io.DataOutputStream;import java.io.ByteArrayOutputStream;import java.io.IOException;import java.util.Map;/** * <code>stack_map</code> attribute. * * <p>This is an entry in the attributes table of a Code attribute. * It was introduced by J2SE 6 for the process of verification by * typechecking. * * @since 3.4 */public class StackMapTable extends AttributeInfo {    /**     * The name of this attribute <code>"StackMapTable"</code>.     */    public static final String tag = "StackMapTable";    /**     * Constructs a <code>stack_map</code> attribute.     */    private StackMapTable(ConstPool cp, byte[] newInfo) {        super(cp, tag, newInfo);    }    StackMapTable(ConstPool cp, int name_id, DataInputStream in)        throws IOException    {        super(cp, name_id, in);    }    /**     * Makes a copy.     */    public AttributeInfo copy(ConstPool newCp, Map classnames) {        int s = info.length;        byte[] newInfo = new byte[s];        System.arraycopy(info, 0, newInfo, 0, s);        return new StackMapTable(newCp, newInfo);    }    void write(DataOutputStream out) throws IOException {        super.write(out);    }    /**     * <code>Top_variable_info.tag</code>.     */    public static final int TOP = 0;    /**     * <code>Float_variable_info.tag</code>.     */    public static final int INTEGER = 1;    /**     * <code>Integer_variable_info.tag</code>.     */    public static final int FLOAT = 2;    /**     * <code>Double_variable_info.tag</code>.     */    public static final int DOUBLE = 3;    /**     * <code>Long_variable_info.tag</code>.     */    public static final int LONG = 4;    /**     * <code>Null_variable_info.tag</code>.     */    public static final int NULL = 5;    /**     * <code>UninitializedThis_variable_info.tag</code>.     */    public static final int THIS = 6;    /**     * <code>Object_variable_info.tag</code>.     */    public static final int OBJECT = 7;    /**     * <code>Uninitialized_variable_info.tag</code>.     */    public static final int UNINIT = 8;    /**     * A code walker for a StackMapTable attribute.     */    static class Walker {        byte[] info;        int numOfEntries;        /**         * Constructs a walker.         *         * @param data      the <code>info</code> field of the         *                  <code>attribute_info</code> structure.         */        public Walker(byte[] data) {            info = data;            numOfEntries = ByteArray.readU16bit(data, 0);        }        /**         * Returns the number of the entries.         */        public final int size() { return numOfEntries; }        /**         * Visits each entry of the stack map frames.          */        public final void parse() throws BadBytecode {            int n = numOfEntries;            int pos = 2;            for (int i = 0; i < n; i++)                pos = stackMapFrames(pos, i);        }        /**         * Invoked when the next entry of the stack map frames is visited.         *         * @param pos       the position of the frame in the <code>info</code>         *                  field of <code>attribute_info</code> structure.         * @param nth       the frame is the N-th         *                  (0, 1st, 2nd, 3rd, 4th, ...) entry.          * @return          the position of the next frame.         */        int stackMapFrames(int pos, int nth) throws BadBytecode {            int type = info[pos] & 0xff;            if (type < 64) {                sameFrame(pos, type);                pos++;            }            else if (type < 128)                pos = sameLocals(pos, type);            else if (type < 247)                throw new BadBytecode("bad frame_type in StackMapTable");            else if (type == 247)   // SAME_LOCALS_1_STACK_ITEM_EXTENDED                pos = sameLocals(pos, type);            else if (type < 251) {                int offset = ByteArray.readU16bit(info, pos + 1);                chopFrame(pos, offset, 251 - type);                pos += 3;            }            else if (type == 251) { // SAME_FRAME_EXTENDED                int offset = ByteArray.readU16bit(info, pos + 1);                sameFrame(pos, offset);                pos += 3;            }            else if (type < 255)                pos = appendFrame(pos, type);            else    // FULL_FRAME                pos = fullFrame(pos);            return pos;        }        /**         * Invoked if the visited frame is a <code>same_frame</code> or         * a <code>same_frame_extended</code>.         *         * @param pos       the position of this frame in the <code>info</code>         *                  field of <code>attribute_info</code> structure.         * @param offsetDelta         */        public void sameFrame(int pos, int offsetDelta) {}        private int sameLocals(int pos, int type) {            int offset;            if (type < 128)                offset = type - 64;            else { // type == 247                offset = ByteArray.readU16bit(info, pos + 1);                pos += 2;            }            int tag = info[pos + 1] & 0xff;            int data = 0;            if (tag == OBJECT || tag == UNINIT) {                data = ByteArray.readU16bit(info, pos + 2);                pos += 2;            }            sameLocals(pos, offset, tag, data);            return pos + 2;        }        /**         * Invoked if the visited frame is a <code>same_locals_1_stack_item_frame</code>         * or a <code>same_locals_1_stack_item_frame_extended</code>.         *         * @param pos               the position.         * @param offsetDelta         * @param stackTag          <code>stack[0].tag</code>.         * @param stackData         <code>stack[0].cpool_index</code>         *                          if the tag is <code>OBJECT</code>,         *                          or <code>stack[0].offset</code>         *                          if the tag is <code>UNINIT</code>.         */        public void sameLocals(int pos, int offsetDelta, int stackTag, int stackData) {}

⌨️ 快捷键说明

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