本文整理汇总了Java中jdk.internal.org.objectweb.asm.MethodVisitor.visitInsn方法的典型用法代码示例。如果您正苦于以下问题:Java MethodVisitor.visitInsn方法的具体用法?Java MethodVisitor.visitInsn怎么用?Java MethodVisitor.visitInsn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.internal.org.objectweb.asm.MethodVisitor
的用法示例。
在下文中一共展示了MethodVisitor.visitInsn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bytesForD
import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
/**
* The bytes for D, a NOT abstract class extending abstract class C without
* supplying an implementation for abstract method m. There is a default
* method in the interface I, but it should lose to the abstract class.
*
* @return
* @throws Exception
*/
public static byte[] bytesForD() throws Exception {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES
| ClassWriter.COMPUTE_MAXS);
MethodVisitor mv;
cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, "p/D", null, "p/C", null);
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, "p/C", "<init>", "()V");
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
cw.visitEnd();
return cw.toByteArray();
}
示例2: createMethodBody
import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
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\")");
}
示例3: swap
import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private static void swap(final MethodVisitor method, final Type above, final Type below) {
if (below.isCategory2()) {
if (above.isCategory2()) {
method.visitInsn(DUP2_X2);
method.visitInsn(POP2);
} else {
method.visitInsn(DUP_X2);
method.visitInsn(POP);
}
} else {
if (above.isCategory2()) {
method.visitInsn(DUP2_X1);
method.visitInsn(POP2);
} else {
method.visitInsn(SWAP);
}
}
}
示例4: ldc
import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public Type ldc(final MethodVisitor method, final Object c) {
if (c == null) {
method.visitInsn(ACONST_NULL);
} else if (c instanceof Undefined) {
return loadUndefined(method);
} else if (c instanceof String) {
method.visitLdcInsn(c);
return STRING;
} else if (c instanceof Handle) {
method.visitLdcInsn(c);
return Type.typeFor(MethodHandle.class);
} else {
throw new UnsupportedOperationException("implementation missing for class " + c.getClass() + " value=" + c);
}
return Type.OBJECT;
}
示例5: add
import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public Type add(final MethodVisitor method, final int programPoint) {
if(programPoint == INVALID_PROGRAM_POINT) {
method.visitInsn(IADD);
} else {
ldc(method, programPoint);
JSType.ADD_EXACT.invoke(method);
}
return INT;
}
示例6: dumpClassFile
import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
public static byte[] dumpClassFile(int cfv, int testDimension264, String arrayDim) throws Exception {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
MethodVisitor mv;
classCName = "classCName_" + cfv + "_" + testDimension264;
cw.visit(cfv, ACC_PUBLIC + ACC_SUPER, classCName, null, "java/lang/Object", null);
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
mv.visitInsn(RETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
{ // classCName main method
mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null);
mv.visitCode();
mv.visitIntInsn(BIPUSH, 1);
mv.visitTypeInsn(ANEWARRAY, arrayDim); // Test ANEWARRAY bytecode with various dimensions
mv.visitInsn(RETURN);
mv.visitMaxs(2, 2);
mv.visitEnd();
}
cw.visitEnd();
return cw.toByteArray();
}
示例7: defineIndyBootstrapMethodBody
import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
void defineIndyBootstrapMethodBody(MethodVisitor mv) {
// Invoke the method whose name is methodName which will throw
// an exception
mv.visitMethodInsn(INVOKESTATIC, "BootstrapMethodErrorTest",
methodName, "()V", false);
mv.visitInsn(ACONST_NULL);
mv.visitInsn(ARETURN);
}
示例8: dump_Overrider
import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
public static void dump_Overrider () throws Exception {
ClassWriter cw = new ClassWriter(0);
MethodVisitor mv;
cw.visit(V1_7, ACC_PUBLIC + ACC_SUPER, "Overrider", null, "HasFinal", null);
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, "HasFinal", "<init>", "()V");
mv.visitInsn(RETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC, "m", "(Ljava/lang/String;)V", null, null);
mv.visitCode();
mv.visitInsn(RETURN);
mv.visitMaxs(0, 2);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null);
mv.visitCode();
mv.visitInsn(RETURN);
mv.visitMaxs(0, 1);
mv.visitEnd();
}
cw.visitEnd();
try (FileOutputStream fos = new FileOutputStream(new File("Overrider.class"))) {
fos.write(cw.toByteArray());
}
}
示例9: genConstructor
import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
/**
* Generate byteccode for no-arg constructor
*/
private void genConstructor(ClassWriter cw) {
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL,
"java/lang/Object",
"<init>",
"()V",
false);
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
示例10: generateTestMethod
import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private static void generateTestMethod(ClassWriter classWriter) {
MethodVisitor mv = classWriter.visitMethod(ACC_PUBLIC,
TestOSRWithNonEmptyStack.METHOD_NAME, "()V", null, null);
Label osrEntryPoint = new Label();
mv.visitCode();
// Push 'this' into stack before OSR entry point to bail out compilation
mv.visitVarInsn(ALOAD, 0);
// Setup loop counter
mv.visitInsn(ICONST_0);
mv.visitVarInsn(ISTORE, 1);
// Begin loop
mv.visitLabel(osrEntryPoint);
// Increment loop counter
mv.visitVarInsn(ILOAD, 1);
mv.visitInsn(ICONST_1);
mv.visitInsn(IADD);
// Duplicate it for loop condition check
mv.visitInsn(DUP);
mv.visitVarInsn(ISTORE, 1);
// Check loop condition
mv.visitLdcInsn(TestOSRWithNonEmptyStack.ITERATIONS);
mv.visitJumpInsn(IF_ICMPLT, osrEntryPoint);
// Pop 'this'.
mv.visitInsn(POP);
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
示例11: dumpP1B
import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
public static byte[] dumpP1B() {
ClassWriter cw = new ClassWriter(0);
MethodVisitor mv;
cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, "P1/B", null, "P1/A", null);
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, "P1/A", "<init>", "()V", false);
mv.visitInsn(RETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
{
mv = cw.visitMethod(0, "m", "()I", null, null);
mv.visitCode();
mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
mv.visitLdcInsn("B.m");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false);
mv.visitIntInsn(BIPUSH, 2);
mv.visitInsn(IRETURN);
mv.visitMaxs(2, 1);
mv.visitEnd();
}
cw.visitEnd();
return cw.toByteArray();
}
示例12: and
import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public Type and(final MethodVisitor method) {
method.visitInsn(IAND);
return INT;
}
示例13: cmp
import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public Type cmp(final MethodVisitor method) {
method.visitInsn(LCMP);
return INT;
}
示例14: arraylength
import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public Type arraylength(final MethodVisitor method) {
method.visitInsn(ARRAYLENGTH);
return INT;
}
示例15: astore
import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void astore(final MethodVisitor method) {
method.visitInsn(DASTORE);
}