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

📄 stackmaptable.java

📁 Javassist是一个开源的分析、编辑和创建Java字节码的类库。是由东京技术学院的数学和计算机科学系的 Shigeru Chiba 所创建的。它已加入了开放源代码JBoss 应用服务器项目,通过使
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        /**         * Invoked if the visited frame is a <code>chop_frame</code>.         *          * @param pos               the position.         * @param offsetDelta         * @param k                 the <cod>k</code> last locals are absent.          */        public void chopFrame(int pos, int offsetDelta, int k) {}        private int appendFrame(int pos, int type) {            int k = type - 251;            int offset = ByteArray.readU16bit(info, pos + 1);            int[] tags = new int[k];            int[] data = new int[k];            int p = pos + 3;            for (int i = 0; i < k; i++) {                int tag = info[p] & 0xff;                tags[i] = tag;                if (tag == OBJECT || tag == UNINIT) {                    data[i] = ByteArray.readU16bit(info, p + 1);                    p += 3;                }                else {                    data[i] = 0;                    p++;                }            }            appendFrame(pos, offset, tags, data);            return p;        }        /**         * Invoked if the visited frame is a <code>append_frame</code>.         *         * @param pos           the position.         * @param offsetDelta         * @param tags          <code>locals[i].tag</code>.         * @param data          <code>locals[i].cpool_index</code>         *                      or <cod>locals[i].offset</code>.         */        public void appendFrame(int pos, int offsetDelta, int[] tags, int[] data) {}         private int fullFrame(int pos) {            int offset = ByteArray.readU16bit(info, pos + 1);            int numOfLocals = ByteArray.readU16bit(info, pos + 3);            int[] localsTags = new int[numOfLocals];            int[] localsData = new int[numOfLocals];            int p = verifyTypeInfo(pos + 5, numOfLocals, localsTags, localsData);            int numOfItems = ByteArray.readU16bit(info, p);            int[] itemsTags = new int[numOfItems];            int[] itemsData = new int[numOfItems];            p = verifyTypeInfo(p + 2, numOfItems, itemsTags, itemsData);            fullFrame(pos, offset, localsTags, localsData, itemsTags, itemsData);            return p;        }        /**         * Invoked if the visited frame is <code>full_frame</code>.         *         * @param pos               the position.         * @param offsetDelta         * @param localTags         <code>locals[i].tag</code>         * @param localData         <code>locals[i].cpool_index</code>         *                          or <code>locals[i].offset</code>         * @param stackTags         <code>stack[i].tag</code>         * @param stackData         <code>stack[i].cpool_index</code>         *                          or <code>stack[i].offset</code>         */        void fullFrame(int pos, int offsetDelta, int[] localTags, int[] localData,                       int[] stackTags, int[] stackData) {}        private int verifyTypeInfo(int pos, int n, int[] tags, int[] data) {            for (int i = 0; i < n; i++) {                int tag = info[pos++] & 0xff;                tags[i] = tag;                if (tag == OBJECT || tag == UNINIT) {                    data[i] = ByteArray.readU16bit(info, pos);                    pos += 2;                }            }            return pos;        }    }    /**     * A writer of stack map tables.     */    static class Writer {        ByteArrayOutputStream output;        int numOfEntries;        /**         * Constructs a writer.         * @param size      the initial buffer size.         */        public Writer(int size) {            output = new ByteArrayOutputStream(size);            numOfEntries = 0;            output.write(0);        // u2 number_of_entries            output.write(0);        }        /**         * Returns the stack map table written out.         */        public byte[] toByteArray() {            byte[] b = output.toByteArray();            ByteArray.write16bit(numOfEntries, b, 0);            return b;        }        /**         * Writes a <code>same_frame</code> or a <code>same_frame_extended</code>.         */        public void sameFrame(int offsetDelta) {            numOfEntries++;            if (offsetDelta < 64)                output.write(offsetDelta);            else {                output.write(251);  // SAME_FRAME_EXTENDED                write16(offsetDelta);            }        }        /**         * Writes a <code>same_locals_1_stack_item</code>         * or a <code>same_locals_1_stack_item_extended</code>.         *         * @param tag           <code>stack[0].tag</code>.         * @param data          <code>stack[0].cpool_index</code>         *                      if the tag is <code>OBJECT</code>,         *                      or <cod>stack[0].offset</code>         *                      if the tag is <code>UNINIT</code>.         *                      Otherwise, this parameter is not used.         */        public void sameLocals(int offsetDelta, int tag, int data) {            numOfEntries++;            if (offsetDelta < 64)                output.write(offsetDelta + 64);            else {                output.write(247);  // SAME_LOCALS_1_STACK_ITEM_EXTENDED                write16(offsetDelta);            }            writeTypeInfo(tag, data);        }        /**         * Writes a <code>chop_frame</code>.         *         * @param k                 the number of absent locals. 1, 2, or 3.         */        public void chopFrame(int offsetDelta, int k) {            numOfEntries++;            output.write(251 - k);            write16(offsetDelta);        }        /**         * Writes a <code>append_frame</code>.         *         * @param tag           <code>locals[].tag</code>.         *                      The length of this array must be         *                      either 1, 2, or 3.         * @param data          <code>locals[].cpool_index</code>         *                      if the tag is <code>OBJECT</code>,         *                      or <cod>locals[].offset</code>         *                      if the tag is <code>UNINIT</code>.         *                      Otherwise, this parameter is not used.         */        public void appendFrame(int offsetDelta, int[] tags, int[] data) {            numOfEntries++;            int k = tags.length;    // k is 1, 2, or 3            output.write(k + 251);            write16(offsetDelta);            for (int i = 0; i < k; i++)                writeTypeInfo(tags[i], data[i]);        }        /**         * Writes a <code>full_frame</code>.         *         * @param localTags     <code>locals[].tag</code>.         * @param localData     <code>locals[].cpool_index</code>         *                      if the tag is <code>OBJECT</code>,         *                      or <cod>locals[].offset</code>         *                      if the tag is <code>UNINIT</code>.         *                      Otherwise, this parameter is not used.         * @param stackTags     <code>stack[].tag</code>.         * @param stackData     <code>stack[].cpool_index</code>         *                      if the tag is <code>OBJECT</code>,         *                      or <cod>stack[].offset</code>         *                      if the tag is <code>UNINIT</code>.         *                      Otherwise, this parameter is not used.         */        public void fullFrame(int offsetDelta, int[] localTags, int[] localData,                              int[] stackTags, int[] stackData) {            numOfEntries++;            output.write(255);      // FULL_FRAME            write16(offsetDelta);            int n = localTags.length;            write16(n);            for (int i = 0; i < n; i++)                writeTypeInfo(localTags[i], localData[i]);            n = stackTags.length;            for (int i = 0; i < n; i++)                writeTypeInfo(stackTags[i], stackData[i]);        }        private void writeTypeInfo(int tag, int data) {            output.write(tag);            if (tag == OBJECT || tag == UNINIT)                write16(data);        }        private void write16(int value) {            output.write((value >>> 8) & 0xff);            output.write(value & 0xff);        }    }}

⌨️ 快捷键说明

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