Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.Constant


        ConstantPool constantPool = lookupClass.getConstantPool();

        int length = constantPool.getLength();
        for (int i = 0; i < length; i++) {
            Constant constant = constantPool.getConstant(i);
            if (constant instanceof ConstantClass) {
                ConstantClass cc = (ConstantClass) constant;
                ConstantUtf8 constant2 = (ConstantUtf8) constantPool.getConstant(cc.getNameIndex());

                // In case a subclass fails, skip, but print warning.
View Full Code Here


        jc.setMajor(47);

        for (int i=1, n=cpool.getSize(); i < n; i++)
        {
            Constant constant = cpool.getConstant(i);
            switch (constant.getTag())
            {
            case Constants.CONSTANT_Utf8:
                ConstantUtf8 cstring = (ConstantUtf8)constant;
                String bytes = cstring.getBytes();
                String newbytes = (String) strings.get(bytes);
View Full Code Here

    {
        public boolean checkCode(InstructionHandle[] match)
        {
            InstructionHandle ih = match[2];
            CPInstruction putfield = (CPInstruction) ih.getInstruction();
            Constant cc = cpool.getConstant(putfield.getIndex());
            if (cc.getTag() != CONSTANT_Fieldref)
                return false;
            ConstantFieldref cfield = (ConstantFieldref) cc;
            ConstantNameAndType cnt = (ConstantNameAndType) cpool.getConstant(cfield.getNameAndTypeIndex());
            if (!cnt.getName(cpool.getConstantPool()).equals("this$0"))
                return false;
View Full Code Here

    {
        public boolean checkCode(InstructionHandle[] match)
        {
            InstructionHandle ih = match[0];
            CPInstruction ldc_w = (CPInstruction) ih.getInstruction();
            Constant cc = cpool.getConstant(ldc_w.getIndex());
            if (cc.getTag() != CONSTANT_Class)
                return false;

            ih = match[1];
            CPInstruction invokevirtual = (CPInstruction) ih.getInstruction();
            ConstantMethodref cm = (ConstantMethodref) cpool.getConstant(invokevirtual.getIndex());
View Full Code Here

        }
        out.write(RCBREOL);
        fout.write(RCBREOL);
        for (int i = 0; i < v.length - 1; i++) {
            if (v[i] != 1) {
                Constant constant = cp.getConstant(i);
                if (constant != null) {
                    full.add(constantToString(constant, cp, v));
                }
            }
        }
View Full Code Here

        switch (tag) {
            case org.apache.bcel.Constants.CONSTANT_Class:
                i = ((ConstantClass) c).getNameIndex();
                v[i] = 1;
                Constant con = cp.getConstant(i, org.apache.bcel.Constants.CONSTANT_Utf8);
                str = Utility.compactClassName(((ConstantUtf8) con).getBytes(), false);
                break;

            case org.apache.bcel.Constants.CONSTANT_String:
                i = ((ConstantString) c).getStringIndex();
                v[i] = 1;
                Constant con2 = cp.getConstant(i, org.apache.bcel.Constants.CONSTANT_Utf8);
                str = ((ConstantUtf8) con2).getBytes();
                break;

            case org.apache.bcel.Constants.CONSTANT_Utf8:
                str = ((ConstantUtf8) c).toString();
View Full Code Here

        if (constPool.getLength() > 0) {
            result.append(indentStr);
            result.append("Constant pool:");
            result.append(n);

            Constant pool[] = constPool.getConstantPool();
            for (int i = 0; i < pool.length; i++) {
                Constant constant = pool[i];
                // pool[i] may be null, so we skip such elements.
                if (constant == null) {
                    continue;
                }
               
View Full Code Here

            Attribute[] attributes = fields[i].getAttributes();
            for (int j = 0; j < attributes.length; j++) {
                if (attributes[j] instanceof ConstantValue) {
                    flags |= (1<<17);
                    ConstantValue constV = ((ConstantValue)attributes[j]);
                    Constant theConstant = constV.getConstantPool().getConstant(constV.getConstantValueIndex());
                    CPConstant cpConstant = cpBands.getCPConstant(theConstant, constV.getConstantPool());
                    fieldConstantValueKQ.add(cpConstant);
                } else if (attributes[j] instanceof Signature) {
                    flags |= (1<<19);
                    fieldSignature.add(cpBands.getCPSignature(((Signature)attributes[j]).getSignature()));
View Full Code Here

                byte b2 = bytecodes[++i];
                short s = (short) (b1 << 8 | b2);
                bcShort.add(new Integer(s));
                break;
            case 18: // ldc
                Constant constant = cp.getConstant(bytecodes[++i] & 0xFF);
                if (constant instanceof ConstantInteger) {
                    bcCodes.add(new Integer(234)); // ildc
                    bcIntref.add(cpBands.getCPConstant(constant, cp));
                } else if (constant instanceof ConstantFloat) {
                    bcCodes.add(new Integer(235)); // fldc
View Full Code Here

        if (constPool.getLength() > 0) {
            result.append(indentStr);
            result.append("Constant pool:");
            result.append(n);

            Constant pool[] = constPool.getConstantPool();
            for (int i = 0; i < pool.length; i++) {
                Constant constant = pool[i];
                // pool[i] may be null, so we skip such elements.
                if (constant == null) {
                    continue;
                }
               
View Full Code Here

TOP

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

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.