Java Code Examples for jdk.internal.org.objectweb.asm.MethodVisitor#visitFrame()

The following examples show how to use jdk.internal.org.objectweb.asm.MethodVisitor#visitFrame() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FrameNode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes the given visitor visit this stack map frame.
 *
 * @param mv
 *            a method visitor.
 */
@Override
public void accept(final MethodVisitor mv) {
    switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
        mv.visitFrame(type, local.size(), asArray(local), stack.size(),
                asArray(stack));
        break;
    case Opcodes.F_APPEND:
        mv.visitFrame(type, local.size(), asArray(local), 0, null);
        break;
    case Opcodes.F_CHOP:
        mv.visitFrame(type, local.size(), null, 0, null);
        break;
    case Opcodes.F_SAME:
        mv.visitFrame(type, 0, null, 0, null);
        break;
    case Opcodes.F_SAME1:
        mv.visitFrame(type, 0, null, 1, asArray(stack));
        break;
    }
}
 
Example 2
Source File: FrameNode.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes the given visitor visit this stack map frame.
 *
 * @param mv
 *            a method visitor.
 */
@Override
public void accept(final MethodVisitor mv) {
    switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
        mv.visitFrame(type, local.size(), asArray(local), stack.size(),
                asArray(stack));
        break;
    case Opcodes.F_APPEND:
        mv.visitFrame(type, local.size(), asArray(local), 0, null);
        break;
    case Opcodes.F_CHOP:
        mv.visitFrame(type, local.size(), null, 0, null);
        break;
    case Opcodes.F_SAME:
        mv.visitFrame(type, 0, null, 0, null);
        break;
    case Opcodes.F_SAME1:
        mv.visitFrame(type, 0, null, 1, asArray(stack));
        break;
    }
}
 
Example 3
Source File: FrameNode.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes the given visitor visit this stack map frame.
 *
 * @param mv
 *            a method visitor.
 */
@Override
public void accept(final MethodVisitor mv) {
    switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
        mv.visitFrame(type, local.size(), asArray(local), stack.size(),
                asArray(stack));
        break;
    case Opcodes.F_APPEND:
        mv.visitFrame(type, local.size(), asArray(local), 0, null);
        break;
    case Opcodes.F_CHOP:
        mv.visitFrame(type, local.size(), null, 0, null);
        break;
    case Opcodes.F_SAME:
        mv.visitFrame(type, 0, null, 0, null);
        break;
    case Opcodes.F_SAME1:
        mv.visitFrame(type, 0, null, 1, asArray(stack));
        break;
    }
}
 
Example 4
Source File: FrameNode.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes the given visitor visit this stack map frame.
 *
 * @param mv a method visitor.
 */
@Override
public void accept(final MethodVisitor mv) {
    switch (type) {
        case Opcodes.F_NEW:
        case Opcodes.F_FULL:
            mv.visitFrame(type,
                    local.size(),
                    asArray(local),
                    stack.size(),
                    asArray(stack));
            break;
        case Opcodes.F_APPEND:
            mv.visitFrame(type, local.size(), asArray(local), 0, null);
            break;
        case Opcodes.F_CHOP:
            mv.visitFrame(type, local.size(), null, 0, null);
            break;
        case Opcodes.F_SAME:
            mv.visitFrame(type, 0, null, 0, null);
            break;
        case Opcodes.F_SAME1:
            mv.visitFrame(type, 0, null, 1, asArray(stack));
            break;
    }
}
 
Example 5
Source File: RedefineRunningMethodsWithResolutionErrors.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static void createMethodBody(MethodVisitor mv) {
    Label classExists = new Label();

    // Cache resolution errors
    createLoadNonExistentClassCode(mv, classExists);

    // Redefine our own class and method
    mv.visitMethodInsn(INVOKESTATIC, "RedefineRunningMethodsWithResolutionErrors", "redefine", "()V");

    // Provoke the same error again to make sure the resolution error cache works
    createLoadNonExistentClassCode(mv, classExists);

    // Test passed
    mv.visitInsn(RETURN);

    mv.visitFrame(F_SAME, 0, new Object[0], 0, new Object[0]);
    mv.visitLabel(classExists);

    createThrowRuntimeExceptionCode(mv, "Loaded class that shouldn't exist (\"NonExistentClass\")");
}
 
Example 6
Source File: FrameNode.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes the given visitor visit this stack map frame.
 *
 * @param mv
 *            a method visitor.
 */
@Override
public void accept(final MethodVisitor mv) {
    switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
        mv.visitFrame(type, local.size(), asArray(local), stack.size(),
                asArray(stack));
        break;
    case Opcodes.F_APPEND:
        mv.visitFrame(type, local.size(), asArray(local), 0, null);
        break;
    case Opcodes.F_CHOP:
        mv.visitFrame(type, local.size(), null, 0, null);
        break;
    case Opcodes.F_SAME:
        mv.visitFrame(type, 0, null, 0, null);
        break;
    case Opcodes.F_SAME1:
        mv.visitFrame(type, 0, null, 1, asArray(stack));
        break;
    }
}
 
Example 7
Source File: FrameNode.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes the given visitor visit this stack map frame.
 *
 * @param mv
 *            a method visitor.
 */
@Override
public void accept(final MethodVisitor mv) {
    switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
        mv.visitFrame(type, local.size(), asArray(local), stack.size(),
                asArray(stack));
        break;
    case Opcodes.F_APPEND:
        mv.visitFrame(type, local.size(), asArray(local), 0, null);
        break;
    case Opcodes.F_CHOP:
        mv.visitFrame(type, local.size(), null, 0, null);
        break;
    case Opcodes.F_SAME:
        mv.visitFrame(type, 0, null, 0, null);
        break;
    case Opcodes.F_SAME1:
        mv.visitFrame(type, 0, null, 1, asArray(stack));
        break;
    }
}
 
Example 8
Source File: RedefineRunningMethodsWithResolutionErrors.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void createLoadNonExistentClassCode(MethodVisitor mv, Label classExists) {
    Label tryLoadBegin = new Label();
    Label tryLoadEnd = new Label();
    Label catchLoadBlock = new Label();
    mv.visitTryCatchBlock(tryLoadBegin, tryLoadEnd, catchLoadBlock, "java/lang/NoClassDefFoundError");

    // Try to load a class that does not exist to provoke resolution errors
    mv.visitLabel(tryLoadBegin);
    mv.visitMethodInsn(INVOKESTATIC, "NonExistentClass", "nonExistentMethod", "()V");
    mv.visitLabel(tryLoadEnd);

    // No NoClassDefFoundError means NonExistentClass existed, which shouldn't happen
    mv.visitJumpInsn(GOTO, classExists);

    mv.visitFrame(F_SAME1, 0, new Object[0], 1, new Object[] { "java/lang/NoClassDefFoundError" });
    mv.visitLabel(catchLoadBlock);

    // Ignore the expected NoClassDefFoundError
    mv.visitInsn(POP);
}
 
Example 9
Source File: RedefineRunningMethodsWithResolutionErrors.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void createMethodBody(MethodVisitor mv) {
    Label classExists = new Label();

    // Cache resolution errors
    createLoadNonExistentClassCode(mv, classExists);

    // Redefine our own class and method
    mv.visitMethodInsn(INVOKESTATIC, "RedefineRunningMethodsWithResolutionErrors", "redefine", "()V");

    // Provoke the same error again to make sure the resolution error cache works
    createLoadNonExistentClassCode(mv, classExists);

    // Test passed
    mv.visitInsn(RETURN);

    mv.visitFrame(F_SAME, 0, new Object[0], 0, new Object[0]);
    mv.visitLabel(classExists);

    createThrowRuntimeExceptionCode(mv, "Loaded class that shouldn't exist (\"NonExistentClass\")");
}
 
Example 10
Source File: FrameNode.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes the given visitor visit this stack map frame.
 *
 * @param mv
 *            a method visitor.
 */
@Override
public void accept(final MethodVisitor mv) {
    switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
        mv.visitFrame(type, local.size(), asArray(local), stack.size(),
                asArray(stack));
        break;
    case Opcodes.F_APPEND:
        mv.visitFrame(type, local.size(), asArray(local), 0, null);
        break;
    case Opcodes.F_CHOP:
        mv.visitFrame(type, local.size(), null, 0, null);
        break;
    case Opcodes.F_SAME:
        mv.visitFrame(type, 0, null, 0, null);
        break;
    case Opcodes.F_SAME1:
        mv.visitFrame(type, 0, null, 1, asArray(stack));
        break;
    }
}
 
Example 11
Source File: FrameNode.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes the given visitor visit this stack map frame.
 *
 * @param mv
 *            a method visitor.
 */
@Override
public void accept(final MethodVisitor mv) {
    switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
        mv.visitFrame(type, local.size(), asArray(local), stack.size(),
                asArray(stack));
        break;
    case Opcodes.F_APPEND:
        mv.visitFrame(type, local.size(), asArray(local), 0, null);
        break;
    case Opcodes.F_CHOP:
        mv.visitFrame(type, local.size(), null, 0, null);
        break;
    case Opcodes.F_SAME:
        mv.visitFrame(type, 0, null, 0, null);
        break;
    case Opcodes.F_SAME1:
        mv.visitFrame(type, 0, null, 1, asArray(stack));
        break;
    }
}
 
Example 12
Source File: RedefineRunningMethodsWithResolutionErrors.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static void createLoadNonExistentClassCode(MethodVisitor mv, Label classExists) {
    Label tryLoadBegin = new Label();
    Label tryLoadEnd = new Label();
    Label catchLoadBlock = new Label();
    mv.visitTryCatchBlock(tryLoadBegin, tryLoadEnd, catchLoadBlock, "java/lang/NoClassDefFoundError");

    // Try to load a class that does not exist to provoke resolution errors
    mv.visitLabel(tryLoadBegin);
    mv.visitMethodInsn(INVOKESTATIC, "NonExistentClass", "nonExistentMethod", "()V");
    mv.visitLabel(tryLoadEnd);

    // No NoClassDefFoundError means NonExistentClass existed, which shouldn't happen
    mv.visitJumpInsn(GOTO, classExists);

    mv.visitFrame(F_SAME1, 0, new Object[0], 1, new Object[] { "java/lang/NoClassDefFoundError" });
    mv.visitLabel(catchLoadBlock);

    // Ignore the expected NoClassDefFoundError
    mv.visitInsn(POP);
}
 
Example 13
Source File: FrameNode.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes the given visitor visit this stack map frame.
 *
 * @param mv
 *            a method visitor.
 */
@Override
public void accept(final MethodVisitor mv) {
    switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
        mv.visitFrame(type, local.size(), asArray(local), stack.size(),
                asArray(stack));
        break;
    case Opcodes.F_APPEND:
        mv.visitFrame(type, local.size(), asArray(local), 0, null);
        break;
    case Opcodes.F_CHOP:
        mv.visitFrame(type, local.size(), null, 0, null);
        break;
    case Opcodes.F_SAME:
        mv.visitFrame(type, 0, null, 0, null);
        break;
    case Opcodes.F_SAME1:
        mv.visitFrame(type, 0, null, 1, asArray(stack));
        break;
    }
}
 
Example 14
Source File: FrameNode.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes the given visitor visit this stack map frame.
 *
 * @param mv
 *            a method visitor.
 */
@Override
public void accept(final MethodVisitor mv) {
    switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
        mv.visitFrame(type, local.size(), asArray(local), stack.size(),
                asArray(stack));
        break;
    case Opcodes.F_APPEND:
        mv.visitFrame(type, local.size(), asArray(local), 0, null);
        break;
    case Opcodes.F_CHOP:
        mv.visitFrame(type, local.size(), null, 0, null);
        break;
    case Opcodes.F_SAME:
        mv.visitFrame(type, 0, null, 0, null);
        break;
    case Opcodes.F_SAME1:
        mv.visitFrame(type, 0, null, 1, asArray(stack));
        break;
    }
}
 
Example 15
Source File: RedefineRunningMethodsWithResolutionErrors.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void createLoadNonExistentClassCode(MethodVisitor mv, Label classExists) {
    Label tryLoadBegin = new Label();
    Label tryLoadEnd = new Label();
    Label catchLoadBlock = new Label();
    mv.visitTryCatchBlock(tryLoadBegin, tryLoadEnd, catchLoadBlock, "java/lang/NoClassDefFoundError");

    // Try to load a class that does not exist to provoke resolution errors
    mv.visitLabel(tryLoadBegin);
    mv.visitMethodInsn(INVOKESTATIC, "NonExistentClass", "nonExistentMethod", "()V");
    mv.visitLabel(tryLoadEnd);

    // No NoClassDefFoundError means NonExistentClass existed, which shouldn't happen
    mv.visitJumpInsn(GOTO, classExists);

    mv.visitFrame(F_SAME1, 0, new Object[0], 1, new Object[] { "java/lang/NoClassDefFoundError" });
    mv.visitLabel(catchLoadBlock);

    // Ignore the expected NoClassDefFoundError
    mv.visitInsn(POP);
}
 
Example 16
Source File: RedefineRunningMethodsWithResolutionErrors.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void createMethodBody(MethodVisitor mv) {
    Label classExists = new Label();

    // Cache resolution errors
    createLoadNonExistentClassCode(mv, classExists);

    // Redefine our own class and method
    mv.visitMethodInsn(INVOKESTATIC, "RedefineRunningMethodsWithResolutionErrors", "redefine", "()V");

    // Provoke the same error again to make sure the resolution error cache works
    createLoadNonExistentClassCode(mv, classExists);

    // Test passed
    mv.visitInsn(RETURN);

    mv.visitFrame(F_SAME, 0, new Object[0], 0, new Object[0]);
    mv.visitLabel(classExists);

    createThrowRuntimeExceptionCode(mv, "Loaded class that shouldn't exist (\"NonExistentClass\")");
}
 
Example 17
Source File: FrameNode.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes the given visitor visit this stack map frame.
 *
 * @param mv
 *            a method visitor.
 */
@Override
public void accept(final MethodVisitor mv) {
    switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
        mv.visitFrame(type, local.size(), asArray(local), stack.size(),
                asArray(stack));
        break;
    case Opcodes.F_APPEND:
        mv.visitFrame(type, local.size(), asArray(local), 0, null);
        break;
    case Opcodes.F_CHOP:
        mv.visitFrame(type, local.size(), null, 0, null);
        break;
    case Opcodes.F_SAME:
        mv.visitFrame(type, 0, null, 0, null);
        break;
    case Opcodes.F_SAME1:
        mv.visitFrame(type, 0, null, 1, asArray(stack));
        break;
    }
}
 
Example 18
Source File: FrameNode.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Makes the given visitor visit this stack map frame.
 *
 * @param mv
 *            a method visitor.
 */
@Override
public void accept(final MethodVisitor mv) {
    switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
        mv.visitFrame(type, local.size(), asArray(local), stack.size(),
                asArray(stack));
        break;
    case Opcodes.F_APPEND:
        mv.visitFrame(type, local.size(), asArray(local), 0, null);
        break;
    case Opcodes.F_CHOP:
        mv.visitFrame(type, local.size(), null, 0, null);
        break;
    case Opcodes.F_SAME:
        mv.visitFrame(type, 0, null, 0, null);
        break;
    case Opcodes.F_SAME1:
        mv.visitFrame(type, 0, null, 1, asArray(stack));
        break;
    }
}
 
Example 19
Source File: RedefineRunningMethodsWithResolutionErrors.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void createLoadNonExistentClassCode(MethodVisitor mv, Label classExists) {
    Label tryLoadBegin = new Label();
    Label tryLoadEnd = new Label();
    Label catchLoadBlock = new Label();
    mv.visitTryCatchBlock(tryLoadBegin, tryLoadEnd, catchLoadBlock, "java/lang/NoClassDefFoundError");

    // Try to load a class that does not exist to provoke resolution errors
    mv.visitLabel(tryLoadBegin);
    mv.visitMethodInsn(INVOKESTATIC, "NonExistentClass", "nonExistentMethod", "()V");
    mv.visitLabel(tryLoadEnd);

    // No NoClassDefFoundError means NonExistentClass existed, which shouldn't happen
    mv.visitJumpInsn(GOTO, classExists);

    mv.visitFrame(F_SAME1, 0, new Object[0], 1, new Object[] { "java/lang/NoClassDefFoundError" });
    mv.visitLabel(catchLoadBlock);

    // Ignore the expected NoClassDefFoundError
    mv.visitInsn(POP);
}
 
Example 20
Source File: RedefineRunningMethodsWithResolutionErrors.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void createMethodBody(MethodVisitor mv) {
    Label classExists = new Label();

    // Cache resolution errors
    createLoadNonExistentClassCode(mv, classExists);

    // Redefine our own class and method
    mv.visitMethodInsn(INVOKESTATIC, "RedefineRunningMethodsWithResolutionErrors", "redefine", "()V");

    // Provoke the same error again to make sure the resolution error cache works
    createLoadNonExistentClassCode(mv, classExists);

    // Test passed
    mv.visitInsn(RETURN);

    mv.visitFrame(F_SAME, 0, new Object[0], 0, new Object[0]);
    mv.visitLabel(classExists);

    createThrowRuntimeExceptionCode(mv, "Loaded class that shouldn't exist (\"NonExistentClass\")");
}