Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.ConstantPool


     * @return constant pool with proper length
     */
    public ConstantPool getFinalConstantPool() {
        Constant[] cs = new Constant[index];
        System.arraycopy(constants, 0, cs, 0, index);
        return new ConstantPool(cs);
    }
View Full Code Here


     * @param patches The already generated patches.
     */
    public static void generate(Attribute[] old, Attribute[] new_,
            List<AttributePatch> patches){
        InnerClass[] oldIC = new InnerClass[0];
        ConstantPool oldCP = null;
        InnerClass[] newIC = new InnerClass[0];
        ConstantPool newCP = null;
       
        for(Attribute a : old){
            if(a instanceof InnerClasses){
                oldIC = ((InnerClasses)a).getInnerClasses();
                oldCP = a.getConstantPool();
View Full Code Here

            attributes = new Attribute[attribute_vec.size()+annAttributes.length];
            attribute_vec.toArray(attributes);
            System.arraycopy(annAttributes,0,attributes,attribute_vec.size(),annAttributes.length);      
        }
        // Must be last since the above calls may still add something to it
        ConstantPool _cp = this.cp.getFinalConstantPool();
        return new JavaClass(class_name_index, superclass_name_index, file_name, major, minor,
                access_flags, _cp, interfaces, fields, methods, attributes);
    }
View Full Code Here

        int[] addedInt = new int[addedIndexes.size()];
        String[] removedStr = new String[removedIndexes.size()];
        for(int i = 0; i < addedInt.length; i++)
            addedInt[i] = addedIndexes.get(i);
       
        ConstantPool c = null;
        for(int i = 0; i < removedStr.length; i++){
            if(c == null)
                // Guaranteed to be set as some where apparently "removed"
                // if this point is reached.
                c = old[0].getConstantPool();
            removedStr[i] = c.getConstantString(removedIndexes.get(i),
                    Constants.CONSTANT_Class);
        }
        patches.add(new ExceptionsPatch(addedInt, removedStr));
    }
View Full Code Here

     * being found in the cpool.
     * @param j The class.
     * @return The interfaces implemented by the class.
     */
    public static String[] getInterfaceNamesProper(JavaClass j){
        ConstantPool cpool = j.getConstantPool();
        int[] indexes = j.getInterfaceIndices();
        String[] names = new String[indexes.length];
        for(int i = 0; i < indexes.length; i++)
            names[i] = cpool.getConstantString(indexes[i],
                    Constants.CONSTANT_Class);
        return names;
    }
View Full Code Here

    @Override
    public JavaClass patch(JavaClass j, CPoolMap map){
       
        int flags = accessPatch.patch(j.getAccessFlags());
       
        ConstantPool cpool = map.to;
       
        int superclassIndex;
        if(superClass == null)
            superclassIndex = j.getSuperclassNameIndex();
        else
View Full Code Here

        }
    }


    private void setValue( int index ) {
        ConstantPool cp = this.cp.getConstantPool();
        Constant c = cp.getConstant(index);
        value = ((ConstantObject) c).getConstantValue(cp);
    }
View Full Code Here

        } catch (Throwable e) {
            e.printStackTrace();
            return null;
        }
        // Adapt the class name to the passed value
        ConstantPool cp = clazz.getConstantPool();
        ConstantClass cl = (ConstantClass) cp.getConstant(clazz.getClassNameIndex(),
                Constants.CONSTANT_Class);
        ConstantUtf8 name = (ConstantUtf8) cp.getConstant(cl.getNameIndex(),
                Constants.CONSTANT_Utf8);
        name.setBytes(class_name.replace('.', '/'));
        return clazz;
    }
View Full Code Here

TOP

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

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.