當前位置: 首頁>>代碼示例>>Java>>正文


Java MethodVisitor.visitMaxs方法代碼示例

本文整理匯總了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();
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:18,代碼來源:JavaInstallationProbe.java

示例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);
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:23,代碼來源:TestGenerator.java

示例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);
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:23,代碼來源:TestGenerator.java

示例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();
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:20,代碼來源:AsmBackedClassGenerator.java

示例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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:UnbalancedMonitorsTest.java

示例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();
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:20,代碼來源:MixInLegacyTypesClassLoader.java

示例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);
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:23,代碼來源:TestGenerator.java

示例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();
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:17,代碼來源:TileEntityRegistry.java

示例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();
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:19,代碼來源:MixInLegacyTypesClassLoader.java

示例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();
}
 
開發者ID:MeetYouDevs,項目名稱:LKDBHelper-ORM-Android,代碼行數:9,代碼來源:InsertToDBApply.java

示例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();
}
 
開發者ID:Javalbert,項目名稱:faster-than-reflection,代碼行數:15,代碼來源:AsmUtils.java

示例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();
}
 
開發者ID:HankXV,項目名稱:Limitart,代碼行數:11,代碼來源:FieldAccess.java

示例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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:67,代碼來源:UnbalancedMonitorsTest.java

示例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();
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:13,代碼來源:MixInLegacyTypesClassLoader.java

示例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();
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:9,代碼來源:AsmBackedClassGenerator.java


注:本文中的org.objectweb.asm.MethodVisitor.visitMaxs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。