Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.LocalVariable


                LocalVariableTable vtab =
                    ((Method)m_item).getLocalVariableTable();
                String[] names = new String[m_argTypes.length];
                int fill = 0;
                while (fill < names.length) {
                    LocalVariable var = vtab.getLocalVariable(offset);
                    offset++;
                    String type = m_argTypes[fill];
                    if ("long".equals(type) || "double".equals(type)) {
                        offset++;
                    }
                    names[fill++] = var.getName();
                }
                m_parmNames = names;
            }
            return m_parmNames[index];
        } else {
View Full Code Here


                        }
                    } else if (a instanceof LocalVariableTable) {
                        LocalVariable[] lv = ((LocalVariableTable) a).getLocalVariableTable();
                        removeLocalVariables();
                        for (int k = 0; k < lv.length; k++) {
                            LocalVariable l = lv[k];
                            InstructionHandle start = il.findHandle(l.getStartPC());
                            InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength());
                            // Repair malformed handles
                            if (null == start) {
                                start = il.getStart();
                            }
                            if (null == end) {
                                end = il.getEnd();
                            }
                            addLocalVariable(l.getName(), Type.getType(l.getSignature()), l
                                    .getIndex(), start, end);
                        }
                    } else {
                        addCodeAttribute(a);
                    }
View Full Code Here

        if (length > 0) {
            length += end.getInstruction().getLength();
        }
        int name_index = cp.addUtf8(name);
        int signature_index = cp.addUtf8(type.getSignature());
        return new LocalVariable(start_pc, length, name_index, signature_index, index, cp
                .getConstantPool());
    }
View Full Code Here

            break;

        case SEEN_ALOAD:
            try {
                if (seen == INSTANCEOF) {
                    LocalVariable lv = LVTHelper.getLocalVariableAtPC(varTable, register, getPC());
                    if (lv != null) {
                        String objSignature = lv.getSignature();
                        if (objSignature.charAt(0) == 'L') {
                            objSignature = objSignature.substring(1, objSignature.length() - 1).replace('/', '.');
                            String clsSignature = getDottedClassConstantOperand();

                            if (clsSignature.charAt(0) != '[') {
View Full Code Here

    private void pushByLocalObjectLoad(DismantleBytecode dbc, int register) {
        Method m = dbc.getMethod();
        LocalVariableTable lvt = m.getLocalVariableTable();
        if (lvt != null) {
            LocalVariable lv = LVTHelper.getLocalVariableAtPC(lvt, register, dbc.getPC());
            if (lv != null) {
                String signature = lv.getSignature();
                pushByLocalLoad(signature, register);
                return;
            }
        }
        pushByLocalLoad("Ljava/lang/Object;", register);
View Full Code Here

    public static LocalVariableAnnotation getLocalVariableAnnotation(Method method, int local, int position1, int position2) {

        LocalVariableTable localVariableTable = method.getLocalVariableTable();
        String localName = "?";
        if (localVariableTable != null) {
            LocalVariable lv1 = localVariableTable.getLocalVariable(local, position1);
            if (lv1 == null) {
                lv1 = localVariableTable.getLocalVariable(local, position2);
                position1 = position2;
            }
            if (lv1 != null) {
                localName = lv1.getName();
            } else {
                for (LocalVariable lv : localVariableTable.getLocalVariableTable()) {
                    if (lv.getIndex() == local) {
                        if (!localName.equals("?") && !localName.equals(lv.getName())) {
                            // not a single consistent name
View Full Code Here

        int index = getMethod().isStatic() ? 0 : 1;
        int parameterNumber = 0;
        for (Iterator<String> i = p.parameterSignatureIterator(); i.hasNext();) {
            String s = i.next();
            LocalVariable localVariable = t.getLocalVariable(index, 0);
            if (localVariable != null) {
                String name = localVariable.getName();
                if (s.equals("J") && (name.toLowerCase().indexOf("instant") >= 0 || name.startsWith("date"))) {

                    // System.out.println(getFullyQualifiedMethodName() + " " + s + " " + index + " " + name);
                    property.setParamWithProperty(parameterNumber, true);
                }
View Full Code Here

        // NOTE: we scan through all the variables here, because I have been
        // told that jikes sometimes produces unpredictable ordering of the
        // local variable table.
        for (int j = 0; j < vars.length; j++) {
            LocalVariable var = vars[j];
            if (!var.getName().equals("this")) {
                if (temp.size() < var.getIndex() + 1)
                    temp.setSize(var.getIndex() + 1);
                temp.setElementAt(var.getName(), var.getIndex());
            }
        }
        int k = 0;
        for (int j = 0; j < temp.size(); j++) {
            if (temp.elementAt(j) != null) {
View Full Code Here

     private void checkReferences()
     {
        if (mLocalVariableTable != null) {
           for (int i = 0; i < mLocalVariableTable.getLength(); i++) {
                if (!mLocalVariableBitSet.get(i)) {
                    final LocalVariable localVariable =
                        mLocalVariableTable.getLocalVariable(i);
                    if (localVariable != null
                        && !localVariable.getName().equals("this"))
                    {
                        log(0,
                            "unread.variable",
                            new Object[] {
                                mCurrentJavaClass.getClassName(),
                                mCurrentMethod.getName(),
                                localVariable.getName(),});
                    }
                }
            }
        }
     }
View Full Code Here

            // Append the local variables table.
            if (printLocalVariables) {
                LocalVariableTable vt = m.getLocalVariableTable();
                if (vt != null) {
                    LocalVariable vars[] = vt.getLocalVariableTable();
                    if (vars.length > 0) {
                        String indentStr3 = indentString(indent * 3);
                        result.append(indentString(
                                indent * 2, "LocalVariableTable:"));
                        result.append(n);
                        result.append(indentStr3);
                        result.append("Start\tLength\tSlot\tName\tSignature");
                        result.append(n);
                        for (int j = 0; j < vars.length; j++) {
                            LocalVariable lv = vars[j];
                            result.append(indentStr3);
                            result.append(lv.getStartPC());
                            result.append("\t\t");
                            result.append(lv.getLength());
                            result.append("\t");
                            result.append(lv.getIndex());
                            result.append("\t");
                            result.append(lv.getName());
                            result.append("\t");
                            result.append(lv.getSignature());
                            result.append("\t");
                            result.append(n);
                        }
                    }
                }
View Full Code Here

TOP

Related Classes of org.apache.bcel.classfile.LocalVariable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.