本文整理汇总了Java中org.objectweb.asm.MethodVisitor.visitMaxs方法的典型用法代码示例。如果您正苦于以下问题:Java MethodVisitor.visitMaxs方法的具体用法?Java MethodVisitor.visitMaxs怎么用?Java MethodVisitor.visitMaxs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.objectweb.asm.MethodVisitor
的用法示例。
在下文中一共展示了MethodVisitor.visitMaxs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMainMethod
import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private static void createMainMethod(ClassWriter cw) {
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
for (SysProp type : SysProp.values()) {
if (type != SysProp.Z_ERROR) {
dumpProperty(mv, type.sysProp);
}
}
mv.visitInsn(RETURN);
Label l3 = new Label();
mv.visitLabel(l3);
mv.visitLocalVariable("args", "[Ljava/lang/String;", null, l0, l3, 0);
mv.visitMaxs(3, 1);
mv.visitEnd();
}
示例2: generateMethodTest5
import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
/**
* Generate test with an invokedynamic, a static bootstrap method with an extra arg that is a
* MethodHandle of kind invoke interface. The target method is a default method into an interface
* that shadows another default method from a super interface.
*/
private void generateMethodTest5(ClassVisitor cv) {
MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test5", "()V",
null, null);
MethodType mt = MethodType.methodType(CallSite.class, MethodHandles.Lookup.class, String.class,
MethodType.class, MethodHandle.class);
Handle bootstrap = new Handle(Opcodes.H_INVOKESTATIC, Type.getInternalName(InvokeCustom.class),
"bsmCreateCallCallingtargetMethodTest6", mt.toMethodDescriptorString(), false);
mv.visitTypeInsn(Opcodes.NEW, Type.getInternalName(InvokeCustom.class));
mv.visitInsn(Opcodes.DUP);
mv.visitMethodInsn(
Opcodes.INVOKESPECIAL, Type.getInternalName(InvokeCustom.class), "<init>", "()V", false);
mv.visitInvokeDynamicInsn("targetMethodTest6", "(Linvokecustom/I;)V", bootstrap,
new Handle(Opcodes.H_INVOKEINTERFACE, Type.getInternalName(I.class),
"targetMethodTest6", "()V", true));
mv.visitInsn(Opcodes.RETURN);
mv.visitMaxs(-1, -1);
}
示例3: generateMethodTest7
import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
/**
* Generate test with an invokedynamic, a static bootstrap method with an extra arg that is a
* MethodHandle of kind invoke interface. The target method is a method into an interface
* that is shadowed by another definition into a sub interfaces.
*/
private void generateMethodTest7(ClassVisitor cv) {
MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test7", "()V",
null, null);
MethodType mt = MethodType.methodType(CallSite.class, MethodHandles.Lookup.class, String.class,
MethodType.class, MethodHandle.class);
Handle bootstrap = new Handle(Opcodes.H_INVOKESTATIC, Type.getInternalName(InvokeCustom.class),
"bsmCreateCallCallingtargetMethodTest8", mt.toMethodDescriptorString(), false);
mv.visitTypeInsn(Opcodes.NEW, Type.getInternalName(InvokeCustom.class));
mv.visitInsn(Opcodes.DUP);
mv.visitMethodInsn(
Opcodes.INVOKESPECIAL, Type.getInternalName(InvokeCustom.class), "<init>", "()V", false);
mv.visitInvokeDynamicInsn("targetMethodTest8", "(Linvokecustom/J;)V", bootstrap,
new Handle(Opcodes.H_INVOKEINTERFACE, Type.getInternalName(J.class),
"targetMethodTest8", "()V", true));
mv.visitInsn(Opcodes.RETURN);
mv.visitMaxs(-1, -1);
}
示例4: applyServiceInjectionToSetter
import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
public void applyServiceInjectionToSetter(PropertyMetaData property, Method setter) throws Exception {
// GENERATE public void <setter>(<type> value) { <field> == value }
String methodDescriptor = Type.getMethodDescriptor(setter);
Type serviceType = Type.getType(property.getType());
String propFieldName = propFieldName(property);
MethodVisitor methodVisitor = visitor.visitMethod(Opcodes.ACC_PUBLIC, setter.getName(), methodDescriptor, signature(setter), EMPTY_STRINGS);
methodVisitor.visitCode();
// this.field = value
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
methodVisitor.visitVarInsn(Opcodes.ALOAD, 1);
methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, generatedType.getInternalName(), propFieldName, serviceType.getDescriptor());
// return
methodVisitor.visitInsn(Opcodes.RETURN);
methodVisitor.visitMaxs(0, 0);
methodVisitor.visitEnd();
}
示例5: visitConstructor
import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private static void visitConstructor(ClassWriter cw) {
MethodVisitor mv;
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitInsn(RETURN);
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
示例6: addInvokeMethod
import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private void addInvokeMethod() {
MethodVisitor methodVisitor = cv.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, "invokeMethod", RETURN_OBJECT_FROM_STRING_OBJECT, null, null);
methodVisitor.visitCode();
// this.getMetaClass()
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, className, "getMetaClass", RETURN_META_CLASS, false);
// invokeMethod(this, name, args)
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
methodVisitor.visitVarInsn(Opcodes.ALOAD, 1);
methodVisitor.visitVarInsn(Opcodes.ALOAD, 2);
methodVisitor.visitMethodInsn(Opcodes.INVOKEINTERFACE, META_CLASS_TYPE.getInternalName(), "invokeMethod", RETURN_OBJECT_FROM_OBJECT_STRING_OBJECT, true);
// return
methodVisitor.visitInsn(Opcodes.ARETURN);
methodVisitor.visitMaxs(4, 3);
methodVisitor.visitEnd();
}
示例7: generateMethodTest6
import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
/**
* Generate test with an invokedynamic, a static bootstrap method with an extra arg that is a
* MethodHandle of kind invoke interface. The target method is a default method into an interface
* that is at the end of a chain of interfaces.
*/
private void generateMethodTest6(ClassVisitor cv) {
MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test6", "()V",
null, null);
MethodType mt = MethodType.methodType(CallSite.class, MethodHandles.Lookup.class, String.class,
MethodType.class, MethodHandle.class);
Handle bootstrap = new Handle(Opcodes.H_INVOKESTATIC, Type.getInternalName(InvokeCustom.class),
"bsmCreateCallCallingtargetMethodTest7", mt.toMethodDescriptorString(), false);
mv.visitTypeInsn(Opcodes.NEW, Type.getInternalName(InvokeCustom.class));
mv.visitInsn(Opcodes.DUP);
mv.visitMethodInsn(
Opcodes.INVOKESPECIAL, Type.getInternalName(InvokeCustom.class), "<init>", "()V", false);
mv.visitInvokeDynamicInsn("targetMethodTest7", "(Linvokecustom/J;)V", bootstrap,
new Handle(Opcodes.H_INVOKEINTERFACE, Type.getInternalName(J.class),
"targetMethodTest7", "()V", true));
mv.visitInsn(Opcodes.RETURN);
mv.visitMaxs(-1, -1);
}
示例8: generateClass
import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private static byte[] generateClass(Class<? extends TileEntity> baseClass, String className, String contentId)
{
ClassWriter cw = new ClassWriter(0);
cw.visit(V1_7, ACC_PUBLIC + ACC_SUPER, className, null, Type.getInternalName(baseClass), null);
// Constructor
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitVarInsn(ALOAD, 0);
mv.visitLdcInsn(contentId);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(baseClass), "<init>", "(Ljava/lang/String;)V", false);
mv.visitInsn(RETURN);
mv.visitMaxs(2, 1);
mv.visitEnd();
return cw.toByteArray();
}
示例9: addGetProperty
import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private void addGetProperty() {
MethodVisitor methodVisitor = cv.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, "getProperty", RETURN_OBJECT_FROM_STRING, null, null);
methodVisitor.visitCode();
// this.getMetaClass()
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, className, "getMetaClass", RETURN_META_CLASS, false);
// getProperty(this, name)
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
methodVisitor.visitVarInsn(Opcodes.ALOAD, 1);
methodVisitor.visitMethodInsn(Opcodes.INVOKEINTERFACE, META_CLASS_TYPE.getInternalName(), "getProperty", RETURN_OBJECT_FROM_OBJECT_STRING, true);
// return
methodVisitor.visitInsn(Opcodes.ARETURN);
methodVisitor.visitMaxs(3, 2);
methodVisitor.visitEnd();
}
示例10: apply
import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void apply(MethodVisitor mv) {
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESTATIC, "com/lhh/lkdb/LKDBModelManager", "insertToDB", "(Lcom/lhh/lkdb/ILKDBModel;)Z", false);
mv.visitInsn(IRETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
示例11: visitDefaultConstructor
import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
public static void visitDefaultConstructor(ClassWriter cw, String classTypeDescriptor) {
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
mv.visitInsn(RETURN);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLocalVariable("this", classTypeDescriptor, null, l0, l1, 0);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
示例12: insertConstructor
import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
static private void insertConstructor(ClassWriter cw) {
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, ReflectASMConst.PACKAGE_NAME + "FieldAccess", "<init>", "()V");
mv.visitInsn(RETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
示例13: visitBlockStructured
import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private static void visitBlockStructured(ClassWriter cw, boolean normalReturnError, boolean tooMany) {
String name = (tooMany ? "tooMany" : "tooFew") + "Exits" + (normalReturnError ? "" : "Exceptional");
// Generate too many or too few exits down the either the normal or exceptional return
// paths
int exceptionalExitCount = normalReturnError ? 1 : (tooMany ? 2 : 0);
int normalExitCount = normalReturnError ? (tooMany ? 2 : 0) : 1;
MethodVisitor mv;
mv = cw.visitMethod(ACC_PUBLIC, name, "(Ljava/lang/Object;Ljava/lang/Object;)Z", null, null);
mv.visitCode();
Label l0 = new Label();
Label l1 = new Label();
Label l2 = new Label();
mv.visitTryCatchBlock(l0, l1, l2, null);
Label l3 = new Label();
mv.visitTryCatchBlock(l2, l3, l2, null);
Label l4 = new Label();
Label l5 = new Label();
Label l6 = new Label();
mv.visitTryCatchBlock(l4, l5, l6, null);
Label l7 = new Label();
mv.visitTryCatchBlock(l2, l7, l6, null);
Label l8 = new Label();
mv.visitLabel(l8);
mv.visitVarInsn(ALOAD, 1);
mv.visitInsn(DUP);
mv.visitVarInsn(ASTORE, 3);
mv.visitInsn(MONITORENTER);
mv.visitLabel(l4);
mv.visitVarInsn(ALOAD, 2);
mv.visitInsn(DUP);
mv.visitVarInsn(ASTORE, 4);
mv.visitInsn(MONITORENTER);
mv.visitLabel(l0);
mv.visitVarInsn(ALOAD, 2);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "equals", "(Ljava/lang/Object;)Z", false);
mv.visitVarInsn(ALOAD, 4);
mv.visitInsn(MONITOREXIT);
mv.visitLabel(l1);
for (int i = 0; i < normalExitCount; i++) {
mv.visitVarInsn(ALOAD, 3);
mv.visitInsn(MONITOREXIT);
}
mv.visitLabel(l5);
mv.visitInsn(IRETURN);
mv.visitLabel(l2);
mv.visitFrame(Opcodes.F_FULL, 5, new Object[]{INNER_CLASS_NAME_INTERNAL, "java/lang/Object", "java/lang/Object", "java/lang/Object",
"java/lang/Object"}, 1, new Object[]{"java/lang/Throwable"});
mv.visitVarInsn(ALOAD, 4);
mv.visitInsn(MONITOREXIT);
mv.visitLabel(l3);
mv.visitInsn(ATHROW);
mv.visitLabel(l6);
mv.visitFrame(Opcodes.F_FULL, 4, new Object[]{INNER_CLASS_NAME_INTERNAL, "java/lang/Object", "java/lang/Object", "java/lang/Object"}, 1,
new Object[]{"java/lang/Throwable"});
for (int i = 0; i < exceptionalExitCount; i++) {
mv.visitVarInsn(ALOAD, 3);
mv.visitInsn(MONITOREXIT);
}
mv.visitLabel(l7);
mv.visitInsn(ATHROW);
Label l9 = new Label();
mv.visitLabel(l9);
mv.visitMaxs(2, 5);
mv.visitEnd();
}
示例14: addStaticStringConstantGetters
import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private void addStaticStringConstantGetters() {
for (Map.Entry<String, String> constant : missingStaticStringConstantGetters.entrySet()) {
MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC,
constant.getKey(),
Type.getMethodDescriptor(Type.getType(String.class)), null, null);
mv.visitCode();
mv.visitLdcInsn(constant.getValue());
mv.visitInsn(Opcodes.ARETURN);
mv.visitMaxs(1, 0);
mv.visitEnd();
}
}
示例15: addGetter
import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private void addGetter(String methodName, String methodDescriptor, MethodCodeBody body) throws Exception {
MethodVisitor methodVisitor = visitor.visitMethod(Opcodes.ACC_PUBLIC, methodName, methodDescriptor, null, EMPTY_STRINGS);
methodVisitor.visitCode();
body.add(methodVisitor);
methodVisitor.visitInsn(Opcodes.ARETURN);
methodVisitor.visitMaxs(0, 0);
methodVisitor.visitEnd();
}