Package javassist.bytecode

Examples of javassist.bytecode.InnerClassesAttribute


        updateInnerEntry(mod, getName(), this, true);
    }

    private static void updateInnerEntry(int mod, String name, CtClass clazz, boolean outer) {
        ClassFile cf = clazz.getClassFile2();
        InnerClassesAttribute ica = (InnerClassesAttribute)cf.getAttribute(
                                                InnerClassesAttribute.tag);
        if (ica == null)
            return;

        int n = ica.tableLength();
        for (int i = 0; i < n; i++)
            if (name.equals(ica.innerClass(i))) {
                int acc = ica.accessFlags(i) & AccessFlag.STATIC;
                ica.setAccessFlags(i, mod | acc);
                String outName = ica.outerClass(i);
                if (outName != null && outer)
                    try {
                        CtClass parent = clazz.getClassPool().get(outName);
                        updateInnerEntry(mod, name, parent, false);
                    }
View Full Code Here


        return AccessFlag.toModifier(acc);
    }

    public CtClass[] getNestedClasses() throws NotFoundException {
        ClassFile cf = getClassFile2();
        InnerClassesAttribute ica
            = (InnerClassesAttribute)cf.getAttribute(InnerClassesAttribute.tag);
        if (ica == null)
            return new CtClass[0];

        String thisName = cf.getName() + "$";
        int n = ica.tableLength();
        ArrayList list = new ArrayList(n);
        for (int i = 0; i < n; i++) {
            String name = ica.innerClass(i);
            if (name != null)
                if (name.startsWith(thisName)) {
                    // if it is an immediate nested class
                    if (name.lastIndexOf('$') < thisName.length())
                        list.add(classPool.get(name));
View Full Code Here

            getClassFile2().addInterface(anInterface.getName());
    }

    public CtClass getDeclaringClass() throws NotFoundException {
        ClassFile cf = getClassFile2();
        InnerClassesAttribute ica = (InnerClassesAttribute)cf.getAttribute(
                                                InnerClassesAttribute.tag);
        if (ica == null)
            return null;

        String name = getName();
        int n = ica.tableLength();
        for (int i = 0; i < n; ++i)
            if (name.equals(ica.innerClass(i))) {
                String outName = ica.outerClass(i);
                if (outName != null)
                    return classPool.get(outName);
                else {
                    // maybe anonymous or local class.
                    EnclosingMethodAttribute ema
View Full Code Here

        checkModify();
        CtClass c = classPool.makeNestedClass(getName() + "$" + name);
        ClassFile cf = getClassFile2();
        ClassFile cf2 = c.getClassFile2();
        InnerClassesAttribute ica = (InnerClassesAttribute)cf.getAttribute(
                                                InnerClassesAttribute.tag);
        if (ica == null) {
            ica = new InnerClassesAttribute(cf.getConstPool());
            cf.addAttribute(ica);
        }

        ica.append(c.getName(), this.getName(), name,
                   (cf2.getAccessFlags() & ~AccessFlag.SUPER) | AccessFlag.STATIC);
        cf2.addAttribute(ica.copy(cf2.getConstPool(), null));
        return c;
    }
View Full Code Here

        return AccessFlag.toModifier(acc);
    }

    public CtClass[] getNestedClasses() throws NotFoundException {
        ClassFile cf = getClassFile2();
        InnerClassesAttribute ica
            = (InnerClassesAttribute)cf.getAttribute(InnerClassesAttribute.tag);
        if (ica == null)
            return new CtClass[0];

        String thisName = cf.getName() + "$";
        int n = ica.tableLength();
        ArrayList list = new ArrayList(n);
        for (int i = 0; i < n; i++) {
            String name = ica.innerClass(i);
            if (name != null)
                if (name.startsWith(thisName)) {
                    // if it is an immediate nested class
                    if (name.lastIndexOf('$') < thisName.length())
                        list.add(classPool.get(name));
View Full Code Here

            getClassFile2().addInterface(anInterface.getName());
    }

    public CtClass getDeclaringClass() throws NotFoundException {
        ClassFile cf = getClassFile2();
        InnerClassesAttribute ica = (InnerClassesAttribute)cf.getAttribute(
                                                InnerClassesAttribute.tag);
        if (ica == null)
            return null;

        String name = getName();
        int n = ica.tableLength();
        for (int i = 0; i < n; ++i)
            if (name.equals(ica.innerClass(i))) {
                String outName = ica.outerClass(i);
                if (outName != null)
                    return classPool.get(outName);
                else {
                    // maybe anonymous or local class.
                    EnclosingMethodAttribute ema
View Full Code Here

        checkModify();
        CtClass c = classPool.makeNestedClass(getName() + "$" + name);
        ClassFile cf = getClassFile2();
        ClassFile cf2 = c.getClassFile2();
        InnerClassesAttribute ica = (InnerClassesAttribute)cf.getAttribute(
                                                InnerClassesAttribute.tag);
        if (ica == null) {
            ica = new InnerClassesAttribute(cf.getConstPool());
            cf.addAttribute(ica);
        }

        ica.append(c.getName(), this.getName(), name,
                   (cf2.getAccessFlags() & ~AccessFlag.SUPER) | AccessFlag.STATIC);
        cf2.addAttribute(ica.copy(cf2.getConstPool(), null));
        return c;
    }
View Full Code Here

        return AccessFlag.toModifier(acc);
    }

    public CtClass[] getNestedClasses() throws NotFoundException {
        ClassFile cf = getClassFile2();
        InnerClassesAttribute ica
            = (InnerClassesAttribute)cf.getAttribute(InnerClassesAttribute.tag);
        if (ica == null)
            return new CtClass[0];

        String thisName = cf.getName() + "$";
        int n = ica.tableLength();
        ArrayList list = new ArrayList(n);
        for (int i = 0; i < n; i++) {
            String name = ica.innerClass(i);
            if (name != null)
                if (name.startsWith(thisName)) {
                    // if it is an immediate nested class
                    if (name.lastIndexOf('$') < thisName.length())
                        list.add(classPool.get(name));
View Full Code Here

            getClassFile2().addInterface(anInterface.getName());
    }

    public CtClass getDeclaringClass() throws NotFoundException {
        ClassFile cf = getClassFile2();
        InnerClassesAttribute ica = (InnerClassesAttribute)cf.getAttribute(
                                                InnerClassesAttribute.tag);
        if (ica == null)
            return null;

        String name = getName();
        int n = ica.tableLength();
        for (int i = 0; i < n; ++i)
            if (name.equals(ica.innerClass(i))) {
                String outName = ica.outerClass(i);
                if (outName != null)
                    return classPool.get(outName);
                else {
                    // maybe anonymous or local class.
                    EnclosingMethodAttribute ema
View Full Code Here

        checkModify();
        CtClass c = classPool.makeNestedClass(getName() + "$" + name);
        ClassFile cf = getClassFile2();
        ClassFile cf2 = c.getClassFile2();
        InnerClassesAttribute ica = (InnerClassesAttribute)cf.getAttribute(
                                                InnerClassesAttribute.tag);
        if (ica == null) {
            ica = new InnerClassesAttribute(cf.getConstPool());
            cf.addAttribute(ica);
        }

        ica.append(c.getName(), this.getName(), name,
                   (cf2.getAccessFlags() & ~AccessFlag.SUPER) | AccessFlag.STATIC);
        cf2.addAttribute(ica.copy(cf2.getConstPool(), null));
        return c;
    }
View Full Code Here

TOP

Related Classes of javassist.bytecode.InnerClassesAttribute

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.