Package org.jboss.classfilewriter

Examples of org.jboss.classfilewriter.InvalidBytecodeException


        return new StackState(ret, constPool);
    }

    public StackState dupX2() {
        if (contents.size() < 3) {
            throw new InvalidBytecodeException("cannot dup_x1, stack does not have enough items");
        }
        StackEntry type = top();
        if (type.getType() == StackEntryType.TOP) {
            throw new InvalidBytecodeException("Cannot dup_x1 wide type");
        }
        ArrayList<StackEntry> ret = new ArrayList<StackEntry>(1 + contents.size());
        for (int i = 0; i < contents.size(); ++i) {
            if (i == contents.size() - 3) {
                ret.add(top());
View Full Code Here


        return new StackState(ret, constPool);
    }

    public StackState dup2() {
        if (contents.size() <2) {
            throw new InvalidBytecodeException("cannot dup2, stack size is " + contents.size() + " " + toString());
        }
        StackEntry t1 = top();
        StackEntry t2 = top_1();
        if (t2.getType() == StackEntryType.TOP) {
            throw new InvalidBytecodeException("Cannot dup2 when second type on stack is wide: " + toString());
        }
        return newStack(t2, t1);
    }
View Full Code Here

        return newStack(t2, t1);
    }

    public StackState dup2X1() {
        if (contents.size() < 3) {
            throw new InvalidBytecodeException("cannot dup2X1, stack size is " + contents.size() + " " + toString());
        }
        StackEntry t1 = top();
        StackEntry t2 = top_1();
        StackEntry t3 = top_2();
        if (t2.getType() == StackEntryType.TOP) {
            throw new InvalidBytecodeException("Cannot dup2X1 when second type on stack is wide: " + toString());
        }
        if (t3.getType() == StackEntryType.TOP) {
            throw new InvalidBytecodeException("Cannot dup2X2 when third type on stack is wide: " + toString());
        }
        ArrayList<StackEntry> ret = new ArrayList<StackEntry>(2 + contents.size());
        for (int i = 0; i < contents.size(); ++i) {
            if (i == contents.size() - 3) {
                ret.add(t2);
View Full Code Here

        return new StackState(ret, constPool);
    }

    public StackState dup2X2() {
        if (contents.size() < 4) {
            throw new InvalidBytecodeException("cannot dup2X2, stack size is " + contents.size() + " " + toString());
        }
        StackEntry t1 = top();
        StackEntry t2 = top_1();
        StackEntry t4 = top_3();
        if (t2.getType() == StackEntryType.TOP) {
            throw new InvalidBytecodeException("Cannot dup2X2 when second type on stack is wide: " + toString());
        }
        if (t4.getType() == StackEntryType.TOP) {
            throw new InvalidBytecodeException("Cannot dup2X2 when fourth type on stack is wide: " + toString());
        }
        ArrayList<StackEntry> ret = new ArrayList<StackEntry>(2 + contents.size());
        for (int i = 0; i < contents.size(); ++i) {
            if (i == contents.size() - 4) {
                ret.add(t2);
View Full Code Here

                    newContents.add(stackEntry);
                }
            }
            return new StackState(newContents, constPool);
        } else {
            throw new InvalidBytecodeException("Object at position " + initializedValueStackPosition
                    + " is not an unitialized object. " + toString());
        }
    }
View Full Code Here

    // Instruction methods, in alphabetical order

    public void aaload() {
        assertTypeOnStack(StackEntryType.INT, "aaload requires int on top of stack");
        if (!getStack().top_1().getDescriptor().startsWith("[")) {
            throw new InvalidBytecodeException("aaload needs an array in position 2 on the stack");
        }
        writeByte(Opcode.AALOAD);
        currentOffset++;
        advanceFrame(currentFrame.pop2push1("Ljava/lang/Object;"));
    }
View Full Code Here

    public void aastore() {
        assertTypeOnStack(StackEntryType.OBJECT, "aastore requires reference type on top of stack");
        assertTypeOnStack(1, StackEntryType.INT, "aastore requires an int on position 2 stack");
        if (!getStack().top_2().getDescriptor().startsWith("[")) {
            throw new InvalidBytecodeException("aaload needs an array in position 3 on the stack");
        }
        writeByte(Opcode.AASTORE);
        currentOffset++;
        advanceFrame(currentFrame.pop3());
    }
View Full Code Here

    }

    public void aload(int no) {
        LocalVariableState locals = getLocalVars();
        if (locals.size() <= no) {
            throw new InvalidBytecodeException("Cannot load variable at " + no + ". Local Variables: " + locals.toString());
        }
        StackEntry entry = locals.get(no);
        if (entry.getType() != StackEntryType.OBJECT && entry.getType() != StackEntryType.NULL
                && entry.getType() != StackEntryType.UNINITIALIZED_THIS
                && entry.getType() != StackEntryType.UNITITIALIZED_OBJECT) {
            throw new InvalidBytecodeException("Invalid local variable at location " + no + " Local Variables "
                    + locals.toString());
        }

        if (no > 0xFF) {
            // wide version
View Full Code Here

    }

    public void dload(int no) {
        LocalVariableState locals = getLocalVars();
        if (locals.size() <= no) {
            throw new InvalidBytecodeException("Cannot load variable at " + no + ". Local Variables: " + locals.toString());
        }
        StackEntry entry = locals.get(no);
        if (entry.getType() != StackEntryType.DOUBLE) {
            throw new InvalidBytecodeException("Invalid local variable at location " + no + " Local Variables "
                    + locals.toString());
        }

        if (no > 0xFF) {
            // wide version
View Full Code Here

    /**
     * Marks the current code location as the exception handler and adds the handler to the exception handler table;
     */
    public void exceptionHandlerStart(ExceptionHandler handler) {
        if (handler.getEnd() == 0) {
            throw new InvalidBytecodeException(
                    "handler end location must be initialised via exceptionHandlerEnd before calling exceptionHandlerAdd");
        }
        handler.setHandler(currentOffset);
        exceptionTable.add(handler);
        mergeStackFrames(new StackFrame(new StackState(handler.getExceptionType(), constPool), handler.getFrame()
View Full Code Here

TOP

Related Classes of org.jboss.classfilewriter.InvalidBytecodeException

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.