Package serp.bytecode.lowlevel

Examples of serp.bytecode.lowlevel.ConstantPoolTable


    public boolean matches(Resource rsrc) throws IOException {
        if (_annos.length == 0 || !rsrc.getName().endsWith(".class"))
            return false;

        try {
            ConstantPoolTable table = new ConstantPoolTable(rsrc.getContent());
            int idx = table.getEndIndex();
            idx += 6; // skip access, cls, super

            // skip interfaces
            int interfaces = table.readUnsignedShort(idx);
            idx += 2 + interfaces * 2;

            // skip fields and methods
            int fields = table.readUnsignedShort(idx);
            idx += 2;
            for (int i = 0; i < fields; i++)
                idx += skipFieldOrMethod(table, idx);
            int methods = table.readUnsignedShort(idx);
            idx += 2;
            for (int i = 0; i < methods; i++)
                idx += skipFieldOrMethod(table, idx);

            // look for annotation attrs
            int attrs = table.readUnsignedShort(idx);
            idx += 2;
            int name;
            for (int i = 0; i < attrs; i++) {
                name = table.readUnsignedShort(idx);
                idx += 2;
                if ("RuntimeVisibleAnnotations".equals(table.readString
                    (table.get(name))))
                    return matchAnnotations(table, idx + 4);
                idx += 4 + table.readInt(idx);
            }
        } catch (ArrayIndexOutOfBoundsException e) {
            Error cfe = new ClassFormatError(rsrc.getName());
            cfe.initCause(e);
            throw cfe;
View Full Code Here


    /**
     * Analyze the bytecode to see if the given class definition implements
     * {@link PersistenceCapable}.
     */
    private static boolean isEnhanced(byte[] b) {
        ConstantPoolTable table = new ConstantPoolTable(b);
        int idx = table.getEndIndex();

        idx += 6; // skip access, cls, super
        int ifaces = table.readUnsignedShort(idx);
        int clsEntry, utfEntry;
        String name;
        for (int i = 0; i < ifaces; i++) {
            idx += 2;
            clsEntry = table.readUnsignedShort(idx);
            utfEntry = table.readUnsignedShort(table.get(clsEntry));
            name = table.readString(table.get(utfEntry));
            if ("org/apache/openjpa/enhance/PersistenceCapable".equals(name))
                return true;
        }
        return false;
    }
View Full Code Here

    /**
     * Analyze the bytecode to see if the given class definition implements
     * {@link PersistenceCapable}.
     */
    private static boolean isEnhanced(byte[] b) {
        ConstantPoolTable table = new ConstantPoolTable(b);
        int idx = table.getEndIndex();

        idx += 6; // skip access, cls, super
        int ifaces = table.readUnsignedShort(idx);
        int clsEntry, utfEntry;
        String name;
        for (int i = 0; i < ifaces; i++) {
            idx += 2;
            clsEntry = table.readUnsignedShort(idx);
            utfEntry = table.readUnsignedShort(table.get(clsEntry));
            name = table.readString(table.get(utfEntry));
            if ("org/apache/openjpa/enhance/PersistenceCapable".equals(name))
                return true;
        }
        return false;
    }
View Full Code Here

    /**
     * Returns the class name in the given .class bytecode.
     */
    private String getFromClass(InputStream in) throws IOException {
        ConstantPoolTable table = new ConstantPoolTable(in);
        int idx = table.getEndIndex();
        idx += 2; // access flags
        int clsEntry = table.readUnsignedShort(idx);
        int utfEntry = table.readUnsignedShort(table.get(clsEntry));
        return table.readString(table.get(utfEntry)).replace('/', '.');
    }
View Full Code Here

    public boolean matches(Resource rsrc) throws IOException {
        if (_annos.length == 0 || !rsrc.getName().endsWith(".class"))
            return false;

        try {
            ConstantPoolTable table = new ConstantPoolTable(rsrc.getContent());
            int idx = table.getEndIndex();
            idx += 6; // skip access, cls, super

            // skip interfaces
            int interfaces = table.readUnsignedShort(idx);
            idx += 2 + interfaces * 2;

            // skip fields and methods
            int fields = table.readUnsignedShort(idx);
            idx += 2;
            for (int i = 0; i < fields; i++)
                idx += skipFieldOrMethod(table, idx);
            int methods = table.readUnsignedShort(idx);
            idx += 2;
            for (int i = 0; i < methods; i++)
                idx += skipFieldOrMethod(table, idx);

            // look for annotation attrs
            int attrs = table.readUnsignedShort(idx);
            idx += 2;
            int name;
            for (int i = 0; i < attrs; i++) {
                name = table.readUnsignedShort(idx);
                idx += 2;
                if ("RuntimeVisibleAnnotations".equals(table.readString
                    (table.get(name))))
                    return matchAnnotations(table, idx + 4);
                idx += 4 + table.readInt(idx);
            }
        } catch (ArrayIndexOutOfBoundsException e) {
            /*
             * This ArrayIndexOutOfBoundsException indicates an incorrectly
             * formed .class file. We will eat the exception, log a trace
View Full Code Here

    /**
     * Analyze the bytecode to see if the given class definition implements
     * {@link PersistenceCapable}.
     */
    private static boolean isEnhanced(byte[] b) {
        ConstantPoolTable table = new ConstantPoolTable(b);
        int idx = table.getEndIndex();

        idx += 6; // skip access, cls, super
        int ifaces = table.readUnsignedShort(idx);
        int clsEntry, utfEntry;
        String name;
        for (int i = 0; i < ifaces; i++) {
            idx += 2;
            clsEntry = table.readUnsignedShort(idx);
            utfEntry = table.readUnsignedShort(table.get(clsEntry));
            name = table.readString(table.get(utfEntry));
            if ("org/apache/openjpa/enhance/PersistenceCapable".equals(name))
                return true;
        }
        return false;
    }
View Full Code Here

    public boolean matches(Resource rsrc) throws IOException {
        if (_annos.length == 0 || !rsrc.getName().endsWith(".class"))
            return false;

        try {
            ConstantPoolTable table = new ConstantPoolTable(rsrc.getContent());
            int idx = table.getEndIndex();
            idx += 6; // skip access, cls, super

            // skip interfaces
            int interfaces = table.readUnsignedShort(idx);
            idx += 2 + interfaces * 2;

            // skip fields and methods
            int fields = table.readUnsignedShort(idx);
            idx += 2;
            for (int i = 0; i < fields; i++)
                idx += skipFieldOrMethod(table, idx);
            int methods = table.readUnsignedShort(idx);
            idx += 2;
            for (int i = 0; i < methods; i++)
                idx += skipFieldOrMethod(table, idx);

            // look for annotation attrs
            int attrs = table.readUnsignedShort(idx);
            idx += 2;
            int name;
            for (int i = 0; i < attrs; i++) {
                name = table.readUnsignedShort(idx);
                idx += 2;
                if ("RuntimeVisibleAnnotations".equals(table.readString
                    (table.get(name))))
                    return matchAnnotations(table, idx + 4);
                idx += 4 + table.readInt(idx);
            }
        } catch (ArrayIndexOutOfBoundsException e) {
            /*
             * This ArrayIndexOutOfBoundsException indicates an incorrectly
             * formed .class file. We will eat the exception, log a trace
View Full Code Here

    /**
     * Returns the class name in the given .class bytecode.
     */
    private String getFromClass(InputStream in) throws IOException {
        ConstantPoolTable table = new ConstantPoolTable(in);
        int idx = table.getEndIndex();
        idx += 2; // access flags
        int clsEntry = table.readUnsignedShort(idx);
        int utfEntry = table.readUnsignedShort(table.get(clsEntry));
        return table.readString(table.get(utfEntry)).replace('/', '.');
    }
View Full Code Here

    /**
     * Analyze the bytecode to see if the given class definition implements
     * {@link PersistenceCapable}.
     */
    private static boolean isEnhanced(byte[] b) {
        ConstantPoolTable table = new ConstantPoolTable(b);
        int idx = table.getEndIndex();

        idx += 6; // skip access, cls, super
        int ifaces = table.readUnsignedShort(idx);
        int clsEntry, utfEntry;
        String name;
        for (int i = 0; i < ifaces; i++) {
            idx += 2;
            clsEntry = table.readUnsignedShort(idx);
            utfEntry = table.readUnsignedShort(table.get(clsEntry));
            name = table.readString(table.get(utfEntry));
            if ("org/apache/openjpa/enhance/PersistenceCapable".equals(name))
                return true;
        }
        return false;
    }
View Full Code Here

    /**
     * Analyze the bytecode to see if the given class definition implements
     * {@link PersistenceCapable}.
     */
    private static boolean isEnhanced(byte[] b) {
        ConstantPoolTable table = new ConstantPoolTable(b);
        int idx = table.getEndIndex();

        idx += 6; // skip access, cls, super
        int ifaces = table.readUnsignedShort(idx);
        int clsEntry, utfEntry;
        String name;
        for (int i = 0; i < ifaces; i++) {
            idx += 2;
            clsEntry = table.readUnsignedShort(idx);
            utfEntry = table.readUnsignedShort(table.get(clsEntry));
            name = table.readString(table.get(utfEntry));
            if ("org/apache/openjpa/enhance/PersistenceCapable".equals(name))
                return true;
        }
        return false;
    }
View Full Code Here

TOP

Related Classes of serp.bytecode.lowlevel.ConstantPoolTable

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.