Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.ConstantMethodref


        boolean sawResourceClass = false;
        for (int i = 0; i < jclass.getConstantPool().getLength(); ++i) {
            Constant constant = jclass.getConstantPool().getConstant(i);
            String className = null;
            if (constant instanceof ConstantMethodref) {
                ConstantMethodref cmr = (ConstantMethodref) constant;

                int classIndex = cmr.getClassIndex();
                className = jclass.getConstantPool().getConstantString(classIndex, Constants.CONSTANT_Class);
            } else if (constant instanceof ConstantInterfaceMethodref) {
                ConstantInterfaceMethodref cmr = (ConstantInterfaceMethodref) constant;

                int classIndex = cmr.getClassIndex();
                className = jclass.getConstantPool().getConstantString(classIndex, Constants.CONSTANT_Class);
            }

            if (className != null) {
                if (DEBUG) {
View Full Code Here


        }

        boolean sawUtilConcurrentLocks = false;
        for (Constant c : jclass.getConstantPool().getConstantPool()) {
            if (c instanceof ConstantMethodref) {
                ConstantMethodref m = (ConstantMethodref) c;
                ConstantClass cl = (ConstantClass) jclass.getConstantPool().getConstant(m.getClassIndex());
                ConstantUtf8 name = (ConstantUtf8) jclass.getConstantPool().getConstant(cl.getNameIndex());
                String nameAsString = name.getBytes();
                if (nameAsString.startsWith("java/util/concurrent/locks")) {
                    sawUtilConcurrentLocks = true;
                }
View Full Code Here

        }
        adjustSize();
        name_and_type_index = addNameAndType(method_name, signature);
        class_index = addClass(class_name);
        ret = index;
        constants[index++] = new ConstantMethodref(class_index, name_and_type_index);
        String key = class_name + METHODREF_DELIM + method_name + METHODREF_DELIM + signature;
        if (!cp_table.containsKey(key)) {
            cp_table.put(key, new Index(ret));
        }
        return ret;
View Full Code Here

                            .getConstant(m_index, CONSTANT_InterfaceMethodref);
                    class_index = c.getClassIndex();
                    str = constant_pool.constantToString(c);
                    index = c.getNameAndTypeIndex();
                } else {
                    ConstantMethodref c = (ConstantMethodref) constant_pool.getConstant(m_index,
                            CONSTANT_Methodref);
                    class_index = c.getClassIndex();
                    str = constant_pool.constantToString(c);
                    index = c.getNameAndTypeIndex();
                }
                name = Class2HTML.referenceClass(class_index);
                str = Class2HTML.toHTML(constant_pool.constantToString(constant_pool.getConstant(
                        index, CONSTANT_NameAndType)));
                // Get signature, i.e., types
View Full Code Here

        int numConstants = cp.getLength();
        for (int i = 0; i < numConstants; ++i) {
            try {
                Constant c = cp.getConstant(i);
                if (c instanceof ConstantMethodref) {
                    ConstantMethodref cmr = (ConstantMethodref) c;
                    ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex(),
                            CONSTANT_NameAndType);
                    String methodName = ((ConstantUtf8) cp.getConstant(cnat.getNameIndex(), CONSTANT_Utf8)).getBytes();
                    String className = cp.getConstantString(cmr.getClassIndex(), CONSTANT_Class).replace('/', '.');
                    String methodSig = ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex(), CONSTANT_Utf8)).getBytes();

                    String classNameLC = className.toLowerCase();
                    String methodNameLC = methodName.toLowerCase();
View Full Code Here

        switch (tag) {
            case CONSTANT_InterfaceMethodref:
            case CONSTANT_Methodref:
                // Get class_index and name_and_type_index, depending on type
                if (tag == CONSTANT_Methodref) {
                    ConstantMethodref c = (ConstantMethodref) constant_pool.getConstant(index,
                            CONSTANT_Methodref);
                    class_index = c.getClassIndex();
                    name_index = c.getNameAndTypeIndex();
                } else {
                    ConstantInterfaceMethodref c1 = (ConstantInterfaceMethodref) constant_pool
                            .getConstant(index, CONSTANT_InterfaceMethodref);
                    class_index = c1.getClassIndex();
                    name_index = c1.getNameAndTypeIndex();
View Full Code Here

            case Constants.CONSTANT_Double:
            case Constants.CONSTANT_Long:
                i++;
                break;
            case Constants.CONSTANT_Methodref:
                ConstantMethodref cmethod = (ConstantMethodref) constant;
                if (cmethod.getClass(cpool.getConstantPool()).equals("java.lang.Integer"))
                {
                    ConstantNameAndType cnt = (ConstantNameAndType) cpool.getConstant(cmethod.getNameAndTypeIndex());

                    if (cnt.getName(cpool.getConstantPool()).equals("valueOf") &&
                        cnt.getSignature(cpool.getConstantPool()).equals("(I)Ljava/lang/Integer;"))
                    {
                        cmethod.setClassIndex(cpool.addClass("macromedia.asc.util.Boxing"));
                    }
                }
               
                else if (cmethod.getClass(cpool.getConstantPool()).equals("java.lang.Double"))
                {
                    ConstantNameAndType cnt = (ConstantNameAndType) cpool.getConstant(cmethod.getNameAndTypeIndex());

                    if (cnt.getName(cpool.getConstantPool()).equals("valueOf") &&
                        cnt.getSignature(cpool.getConstantPool()).equals("(D)Ljava/lang/Double;"))
                    {
                        cmethod.setClassIndex(cpool.addClass("macromedia.asc.util.Boxing"));
                    }
                }
                break;
            }
        }
View Full Code Here

            if (cc.getTag() != CONSTANT_Class)
                return false;

            ih = match[1];
            CPInstruction invokevirtual = (CPInstruction) ih.getInstruction();
            ConstantMethodref cm = (ConstantMethodref) cpool.getConstant(invokevirtual.getIndex());
            ConstantNameAndType cnt = (ConstantNameAndType) cpool.getConstant(cm.getNameAndTypeIndex());
            if (!cnt.getName(cpool.getConstantPool()).equals("desiredAssertionStatus"))
                return false;
            return true;
        }
View Full Code Here

                    result.append(c.getSignatureIndex());
                    result.append(";\t//  ");
                    result.append(Utility.replace(
                            constPool.constantToString(c), " ", ":"));
                } else if (constant instanceof ConstantMethodref) {
                    ConstantMethodref c = (ConstantMethodref) constant;
                    result.append("Method\t#");
                    result.append(c.getClassIndex());
                    result.append(".#");
                    result.append(c.getNameAndTypeIndex());
                    result.append(";\t//  ");
                    result.append(Utility.replace(
                            constPool.constantToString(c), " ", ":"));
                } else if (constant instanceof ConstantInterfaceMethodref) {
                    ConstantInterfaceMethodref c = (ConstantInterfaceMethodref) constant;
                    result.append("InterfaceMethod\t#");
                    result.append(c.getClassIndex());
                    result.append(".#");
                    result.append(c.getNameAndTypeIndex());
                    result.append(";\t//  ");
                    result.append(Utility.replace(
                            constPool.constantToString(c), " ", ":"));
                } else if (constant instanceof ConstantDouble) {
                    ConstantDouble c = (ConstantDouble) constant;
                    result.append("double\t");
                    result.append(constPool.constantToString(c));
                    result.append(';');
                } else if (constant instanceof ConstantFloat) {
                    ConstantFloat c = (ConstantFloat) constant;
                    result.append("float\t");
                    result.append(constPool.constantToString(c));
                    result.append(';');
                } else if (constant instanceof ConstantInteger) {
                    ConstantInteger c = (ConstantInteger) constant;
                    result.append("int\t");
                    result.append(constPool.constantToString(c));
                    result.append(';');
                } else if (constant instanceof ConstantLong) {
                    ConstantLong c = (ConstantLong) constant;
                    result.append("long\t");
                    result.append(constPool.constantToString(c));
                    result.append(';');
                } else if (constant instanceof ConstantClass) {
                    ConstantClass c = (ConstantClass) constant;
                    result.append("class\t#");
                    result.append(c.getNameIndex());
                    result.append(";\t//  ");
                    result.append(constPool.constantToString(c));
                } else if (constant instanceof ConstantString) {
                    ConstantString c = (ConstantString) constant;
                    result.append("String\t#");
                    result.append(c.getStringIndex());
                    result.append(";\t//  ");
                    result.append(constPool.constantToString(c));
                }

                result.append(n);
View Full Code Here

            case 183: // invokespecial
            case 184: // invokestatic
                b1 = bytecodes[++i];
                b2 = bytecodes[++i];
                index = b1 << 8 | b2;
                ConstantMethodref cmr = (ConstantMethodref) cp.getConstant(index);
                className = cmr.getClass(cp);
                CPMethodOrField cpMethod = cpBands.getCPMethodOrField(cmr);
                if(aload_0) {
                    bytecode += 7;
                }
                if(className.equals(thisClass)) {
                    if(bytecode == 183) { // invokespecial
                        ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
                        String name = cnat.getName(cp);
                        if(name.equals("this")) {

                        }
                    }
View Full Code Here

TOP

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

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.