Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.LocalVariableTable


     */
    public String getParameterName(int index) {
        if (m_item instanceof Method) {
            if (m_parmNames == null) {
                int offset = isStatic() ? 0 : 1;
                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++;
                    }
View Full Code Here


    MethodBlock mb = null;
    boolean isConstructor = false;
   
   
        ConstantPoolGen cpg = methodGen.getConstantPool();
        LocalVariableTable lvt = methodGen.getLocalVariableTable(cpg);
       
    String access = Utility.accessToString(methodGen.getAccessFlags());
    String signature = Type.getMethodSignature(methodGen.getType(), methodGen.getArgumentTypes());
       
        String name = methodGen.getName();
View Full Code Here

        int size = lg.length;
        LocalVariable[] lv = new LocalVariable[size];
        for (int i = 0; i < size; i++) {
            lv[i] = lg[i].getLocalVariable(cp);
        }
        return new LocalVariableTable(cp.addUtf8("LocalVariableTable"), 2 + lv.length * 10, lv, cp
                .getConstantPool());
    }
View Full Code Here

        byte[] byte_code = null;
        if (il != null) {
            byte_code = il.getByteCode();
        }
        LineNumberTable lnt = null;
        LocalVariableTable lvt = null;
        /* Create LocalVariableTable and LineNumberTable attributes (for debuggers, e.g.)
         */
        if ((variable_vec.size() > 0) && !strip_attributes) {
            addCodeAttribute(lvt = getLocalVariableTable(cp));
        }
View Full Code Here

    /* We cannot use code.getLocalVariableTable() because there could be more
       than only one. This is a bug in BCEL. */
    Attribute[] atts = code.getAttributes();
    for (int a=0; a<atts.length; a++){
      if (atts[a] instanceof LocalVariableTable){
        LocalVariableTable lvt = (LocalVariableTable) atts[a];
        if (lvt != null){
          LocalVariable[] localVariables = lvt.getLocalVariableTable();
          for (int i=0; i<localVariables.length; i++){
            int startpc = localVariables[i].getStartPC();
            int length  = localVariables[i].getLength();
       
            if (!contains(instructionPositions, startpc)){
View Full Code Here

        //Here because its easier to collect the information of the
        //(possibly more than one) LocalVariableTables belonging to
        //one certain Code attribute.
        if (atts[a] instanceof LocalVariableTable){ // checks conforming to vmspec2 4.7.9

          LocalVariableTable lvt = (LocalVariableTable) atts[a];

          checkIndex(lvt, lvt.getNameIndex(), CONST_Utf8);

          String lvtname = ((ConstantUtf8) cp.getConstant(lvt.getNameIndex())).getBytes();
          if (! lvtname.equals("LocalVariableTable")){
            throw new ClassConstraintException("The LocalVariableTable attribute '"+tostring(lvt)+"' is not correctly named 'LocalVariableTable' but '"+lvtname+"'.");
          }

          Code code = obj;

          //In JustIce, the check for correct offsets into the code array is delayed to Pass 3a.
          LocalVariable[] localvariables = lvt.getLocalVariableTable();

          for (int i=0; i<localvariables.length; i++){
            checkIndex(lvt, localvariables[i].getNameIndex(), CONST_Utf8);
            String localname = ((ConstantUtf8) cp.getConstant(localvariables[i].getNameIndex())).getBytes();
            if (!validJavaIdentifier(localname)){
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);
View Full Code Here

        return getLocalVariableAnnotation(method, local, position1, position2);
    }

    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
                            localName = "?";
                            break;
View Full Code Here

        if (!getMethod().isPublic() && !getMethod().isProtected()) {
            return;
        }
        SignatureParser p = new SignatureParser(getMethodSig());
        LocalVariableTable t = obj.getLocalVariableTable();

        if (t == null) {
            return;
        }
        ParameterProperty property = new ParameterProperty();

        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);
View Full Code Here

        // Get the Code object, which contains the local variable table.
        Code code = method.getCode();
        if (code == null)
            return null;

        LocalVariableTable attr = method.getLocalVariableTable();
        if (attr == null)
            return null;

        // OK, found it.  Now scan through the local variables and record
        // the names in the right indices.
        LocalVariable[] vars = attr.getLocalVariableTable();

        String[] argNames = new String[numParams + 1];
        argNames[0] = null; // don't know return name

        // NOTE: we scan through all the variables here, because I have been
View Full Code Here

TOP

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

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.