Package org.cojen.classfile.constant

Examples of org.cojen.classfile.constant.ConstantClassInfo


        length -= 2;

        for (int i=0; i<size; i++) {
            int index = din.readUnsignedShort();
            length -= 2;
            ConstantClassInfo info = (ConstantClassInfo)cp.getConstant(index);
            addException(info);
        }

        skipBytes(din, length);
    }
View Full Code Here


   
    public void writeDataTo(DataOutput dout) throws IOException {
        int size = mExceptions.size();
        dout.writeShort(size);
        for (int i=0; i<size; i++) {
            ConstantClassInfo info = mExceptions.get(i);
            dout.writeShort(info.getIndex());
        }
    }
View Full Code Here

            int inner_index = din.readUnsignedShort();
            int outer_index = din.readUnsignedShort();
            int name_index = din.readUnsignedShort();
            int af = din.readUnsignedShort();
           
            ConstantClassInfo inner;
            if (inner_index == 0) {
                inner = null;
            } else {
                inner = (ConstantClassInfo)cp.getConstant(inner_index);
            }

            ConstantClassInfo outer;
            if (outer_index == 0) {
                outer = null;
            } else {
                outer = (ConstantClassInfo)cp.getConstant(outer_index);
            }
View Full Code Here

    public void addInnerClass(String inner,
                              String outer,
                              String name,
                              Modifiers modifiers) {
       
        ConstantClassInfo innerInfo = getConstantPool().addConstantClass(inner);
        ConstantClassInfo outerInfo;
        if (outer == null) {
            outerInfo = null;
        } else {
            outerInfo = getConstantPool().addConstantClass(outer);
        }
View Full Code Here

        ConstantPool cp = ConstantPool.readFrom(din);
        Modifiers modifiers = Modifiers.getInstance(din.readUnsignedShort())
            .toSynchronized(false);

        int index = din.readUnsignedShort();
        ConstantClassInfo thisClass = (ConstantClassInfo)cp.getConstant(index);

        index = din.readUnsignedShort();
        ConstantClassInfo superClass = null;
        if (index > 0) {
            superClass = (ConstantClassInfo)cp.getConstant(index);
        }

        ClassFile cf = new ClassFile(cp, modifiers, thisClass, superClass, outerClass);
        cf.setVersion(major, minor);
        loadedClassFiles.put(cf.getClassName(), cf);

        // Read interfaces.
        int size = din.readUnsignedShort();
        for (int i=0; i<size; i++) {
            index = din.readUnsignedShort();
            ConstantClassInfo info = (ConstantClassInfo)cp.getConstant(index);
            cf.addInterface(info.getType().getRootName());
        }
       
        // Read fields.
        size = din.readUnsignedShort();
        for (int i=0; i<size; i++) {
            cf.mFields.add(FieldInfo.readFrom(cf, din, attrFactory));
        }
       
        // Read methods.
        size = din.readUnsignedShort();
        for (int i=0; i<size; i++) {
            cf.mMethods.add(MethodInfo.readFrom(cf, din, attrFactory));
        }

        // Read attributes.
        size = din.readUnsignedShort();
        for (int i=0; i<size; i++) {
            Attribute attr = Attribute.readFrom(cp, din, attrFactory);
            cf.addAttribute(attr);
            if (attr instanceof InnerClassesAttr) {
                cf.mInnerClassesAttr = (InnerClassesAttr)attr;
            }
        }

        // Load inner and outer classes.
        if (cf.mInnerClassesAttr != null && loader != null) {
            InnerClassesAttr.Info[] infos = cf.mInnerClassesAttr.getInnerClassesInfo();
            for (int i=0; i<infos.length; i++) {
                InnerClassesAttr.Info info = infos[i];

                if (thisClass.equals(info.getInnerClass())) {
                    // This class is an inner class.
                    if (info.getInnerClassName() != null) {
                        cf.mInnerClassName = info.getInnerClassName().getValue();
                    }
                    ConstantClassInfo outer = info.getOuterClass();
                    if (cf.mOuterClass == null && outer != null) {
                        cf.mOuterClass = readOuterClass
                            (outer, loader, attrFactory, loadedClassFiles);
                    }
                    Modifiers innerFlags = info.getModifiers();
                    cf.mModifiers = cf.mModifiers
                        .toStatic(innerFlags.isStatic())
                        .toPrivate(innerFlags.isPrivate())
                        .toProtected(innerFlags.isProtected())
                        .toPublic(innerFlags.isPublic());
                } else if (info.getOuterClass() == null ||
                           thisClass.equals(info.getOuterClass())) {

                    // This class is an outer class.
                    ConstantClassInfo inner = info.getInnerClass();
                    if (inner != null) {
                        ClassFile innerClass = readInnerClass
                            (inner, loader, attrFactory, loadedClassFiles, cf);
                       
                        if (innerClass != null) {
View Full Code Here

    public void writeTo(DataOutput dout) throws IOException {
        int start_pc = getStartLocation().getLocation();
        int end_pc = getEndLocation().getLocation();
        int handler_pc = getCatchLocation().getLocation();
        int catch_type;
        ConstantClassInfo catchType = getCatchType();
        if (catchType == null) {
            catch_type = 0;
        }
        else {
            catch_type = catchType.getIndex();
        }

        check("exception start PC", start_pc);
        check("exception end PC", end_pc);
        check("exception handler PC", handler_pc);
View Full Code Here

        int start_pc = din.readUnsignedShort();
        int end_pc = din.readUnsignedShort();
        int handler_pc = din.readUnsignedShort();
        int catch_type = din.readUnsignedShort();

        ConstantClassInfo catchTypeConstant;
        if (catch_type == 0) {
            catchTypeConstant = null;
        } else {
            catchTypeConstant = (ConstantClassInfo)cp.getConstant(catch_type);
        }
View Full Code Here

            throw new IllegalArgumentException("End location is not a label instruction");
        }

        Location catchLocation = createLabel().setLocation();

        ConstantClassInfo catchClass;
        if (catchClassName == null) {
            catchClass = null;
        } else {
            catchClass = mCp.addConstantClass(catchClassName);
        }
View Full Code Here

    public void addException(TypeDesc type) {
        if (mExceptions == null) {
            addAttribute(new ExceptionsAttr(mCp));
        }
        // TODO: Special handling for generics
        ConstantClassInfo cci = mCp.addConstantClass(type);
        mExceptions.addException(cci);
    }
View Full Code Here

    /**
     * Get or create a constant from the constant pool representing a class.
     */
    public ConstantClassInfo addConstantClass(String className) {
        return (ConstantClassInfo)addConstant(new ConstantClassInfo(this, className));
    }
View Full Code Here

TOP

Related Classes of org.cojen.classfile.constant.ConstantClassInfo

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.