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

📄 classreader.java

📁 jboss规则引擎
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                        case ClassWriter.ITFMETH_INSN :
                            v += 5;
                            break;
                        // case MANA_INSN:
                        default :
                            v += 4;
                            break;
                    }
                }
                // parses the try catch entries
                j = readUnsignedShort( v );
                v += 2;
                for ( ; j > 0; --j ) {
                    label = readUnsignedShort( v );
                    Label start = labels[label];
                    if ( start == null ) {
                        labels[label] = start = new Label();
                    }
                    label = readUnsignedShort( v + 2 );
                    Label end = labels[label];
                    if ( end == null ) {
                        labels[label] = end = new Label();
                    }
                    label = readUnsignedShort( v + 4 );
                    Label handler = labels[label];
                    if ( handler == null ) {
                        labels[label] = handler = new Label();
                    }

                    final int type = readUnsignedShort( v + 6 );
                    if ( type == 0 ) {
                        mv.visitTryCatchBlock( start,
                                               end,
                                               handler,
                                               null );
                    } else {
                        mv.visitTryCatchBlock( start,
                                               end,
                                               handler,
                                               readUTF8( this.items[type],
                                                         c ) );
                    }
                    v += 8;
                }
                // parses the local variable, line number tables, and code
                // attributes
                int varTable = 0;
                int varTypeTable = 0;
                cattrs = null;
                j = readUnsignedShort( v );
                v += 2;
                for ( ; j > 0; --j ) {
                    attrName = readUTF8( v,
                                         c );
                    if ( attrName.equals( "LocalVariableTable" ) ) {
                        if ( !skipDebug ) {
                            varTable = v + 6;
                            k = readUnsignedShort( v + 6 );
                            w = v + 8;
                            for ( ; k > 0; --k ) {
                                label = readUnsignedShort( w );
                                if ( labels[label] == null ) {
                                    labels[label] = new Label();
                                }
                                label += readUnsignedShort( w + 2 );
                                if ( labels[label] == null ) {
                                    labels[label] = new Label();
                                }
                                w += 10;
                            }
                        }
                    } else if ( attrName.equals( "LocalVariableTypeTable" ) ) {
                        varTypeTable = v + 6;
                    } else if ( attrName.equals( "LineNumberTable" ) ) {
                        if ( !skipDebug ) {
                            k = readUnsignedShort( v + 6 );
                            w = v + 8;
                            for ( ; k > 0; --k ) {
                                label = readUnsignedShort( w );
                                if ( labels[label] == null ) {
                                    labels[label] = new Label();
                                }
                                labels[label].line = readUnsignedShort( w + 2 );
                                w += 4;
                            }
                        }
                    } else {
                        for ( k = 0; k < attrs.length; ++k ) {
                            if ( attrs[k].type.equals( attrName ) ) {
                                attr = attrs[k].read( this,
                                                      v + 6,
                                                      readInt( v + 2 ),
                                                      c,
                                                      codeStart - 8,
                                                      labels );
                                if ( attr != null ) {
                                    attr.next = cattrs;
                                    cattrs = attr;
                                }
                            }
                        }
                    }
                    v += 6 + readInt( v + 2 );
                }

                // 2nd phase: visits each instruction
                v = codeStart;
                Label l;
                while ( v < codeEnd ) {
                    w = v - codeStart;
                    l = labels[w];
                    if ( l != null ) {
                        mv.visitLabel( l );
                        if ( !skipDebug && l.line > 0 ) {
                            mv.visitLineNumber( l.line,
                                                l );
                        }
                    }
                    int opcode = b[v] & 0xFF;
                    switch ( ClassWriter.TYPE[opcode] ) {
                        case ClassWriter.NOARG_INSN :
                            mv.visitInsn( opcode );
                            v += 1;
                            break;
                        case ClassWriter.IMPLVAR_INSN :
                            if ( opcode > Opcodes.ISTORE ) {
                                opcode -= 59; // ISTORE_0
                                mv.visitVarInsn( Opcodes.ISTORE + (opcode >> 2),
                                                 opcode & 0x3 );
                            } else {
                                opcode -= 26; // ILOAD_0
                                mv.visitVarInsn( Opcodes.ILOAD + (opcode >> 2),
                                                 opcode & 0x3 );
                            }
                            v += 1;
                            break;
                        case ClassWriter.LABEL_INSN :
                            mv.visitJumpInsn( opcode,
                                              labels[w + readShort( v + 1 )] );
                            v += 3;
                            break;
                        case ClassWriter.LABELW_INSN :
                            mv.visitJumpInsn( opcode - 33,
                                              labels[w + readInt( v + 1 )] );
                            v += 5;
                            break;
                        case ClassWriter.WIDE_INSN :
                            opcode = b[v + 1] & 0xFF;
                            if ( opcode == Opcodes.IINC ) {
                                mv.visitIincInsn( readUnsignedShort( v + 2 ),
                                                  readShort( v + 4 ) );
                                v += 6;
                            } else {
                                mv.visitVarInsn( opcode,
                                                 readUnsignedShort( v + 2 ) );
                                v += 4;
                            }
                            break;
                        case ClassWriter.TABL_INSN :
                            // skips 0 to 3 padding bytes
                            v = v + 4 - (w & 3);
                            // reads instruction
                            label = w + readInt( v );
                            v += 4;
                            final int min = readInt( v );
                            v += 4;
                            final int max = readInt( v );
                            v += 4;
                            final Label[] table = new Label[max - min + 1];
                            for ( j = 0; j < table.length; ++j ) {
                                table[j] = labels[w + readInt( v )];
                                v += 4;
                            }
                            mv.visitTableSwitchInsn( min,
                                                     max,
                                                     labels[label],
                                                     table );
                            break;
                        case ClassWriter.LOOK_INSN :
                            // skips 0 to 3 padding bytes
                            v = v + 4 - (w & 3);
                            // reads instruction
                            label = w + readInt( v );
                            v += 4;
                            j = readInt( v );
                            v += 4;
                            final int[] keys = new int[j];
                            final Label[] values = new Label[j];
                            for ( j = 0; j < keys.length; ++j ) {
                                keys[j] = readInt( v );
                                v += 4;
                                values[j] = labels[w + readInt( v )];
                                v += 4;
                            }
                            mv.visitLookupSwitchInsn( labels[label],
                                                      keys,
                                                      values );
                            break;
                        case ClassWriter.VAR_INSN :
                            mv.visitVarInsn( opcode,
                                             b[v + 1] & 0xFF );
                            v += 2;
                            break;
                        case ClassWriter.SBYTE_INSN :
                            mv.visitIntInsn( opcode,
                                             b[v + 1] );
                            v += 2;
                            break;
                        case ClassWriter.SHORT_INSN :
                            mv.visitIntInsn( opcode,
                                             readShort( v + 1 ) );
                            v += 3;
                            break;
                        case ClassWriter.LDC_INSN :
                            mv.visitLdcInsn( readConst( b[v + 1] & 0xFF,
                                                        c ) );
                            v += 2;
                            break;
                        case ClassWriter.LDCW_INSN :
                            mv.visitLdcInsn( readConst( readUnsignedShort( v + 1 ),
                                                        c ) );
                            v += 3;
                            break;
                        case ClassWriter.FIELDORMETH_INSN :
                        case ClassWriter.ITFMETH_INSN :
                            int cpIndex = this.items[readUnsignedShort( v + 1 )];
                            final String iowner = readClass( cpIndex,
                                                             c );
                            cpIndex = this.items[readUnsignedShort( cpIndex + 2 )];
                            final String iname = readUTF8( cpIndex,
                                                           c );
                            final String idesc = readUTF8( cpIndex + 2,
                                                           c );
                            if ( opcode < Opcodes.INVOKEVIRTUAL ) {
                                mv.visitFieldInsn( opcode,
                                                   iowner,
                                                   iname,
                                                   idesc );
                            } else {
                                mv.visitMethodInsn( opcode,
                                                    iowner,
                                                    iname,
                                                    idesc );
                            }
                            if ( opcode == Opcodes.INVOKEINTERFACE ) {
                                v += 5;
                            } else {
                                v += 3;
                            }
                            break;
                        case ClassWriter.TYPE_INSN :
                            mv.visitTypeInsn( opcode,
                                              readClass( v + 1,
                                                         c ) );
                            v += 3;
                            break;
                        case ClassWriter.IINC_INSN :
                            mv.visitIincInsn( b[v + 1] & 0xFF,
                                              b[v + 2] );
                            v += 3;
                            break;
                        // case MANA_INSN:
                        default :
                            mv.visitMultiANewArrayInsn( readClass( v + 1,
                                                                   c ),
                                                        b[v + 3] & 0xFF );
                            v += 4;
                            break;
                    }
                }
                l = labels[codeEnd - codeStart];
                if ( l != null ) {
                    mv.visitLabel( l );
                }

                // visits the local variable tables
                if ( !skipDebug && varTable != 0 ) {
                    int[] typeTable = null;
                    if ( varTypeTable != 0 ) {
                        w = varTypeTable;
                        k = readUnsignedShort( w ) * 3;
                        w += 2;
                        typeTable = new int[k];
                        while ( k > 0 ) {
                            typeTable[--k] = w + 6; // signature
                            typeTable[--k] = readUnsignedShort( w + 8 ); // index
                            typeTable[--k] = readUnsignedShort( w ); // start
                            w += 10;
                        }
                    }
                    w = varTable;
                    k = readUnsignedShort( w );
                    w += 2;
                    for ( ; k > 0; --k ) {
                        final int start = readUnsignedShort( w );
                        final int length = readUnsignedShort( w + 2 );
                        final int index = readUnsignedShort( w + 8 );
                        String vsignature = null;

⌨️ 快捷键说明

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