当前位置: 首页>>代码示例>>Java>>正文


Java MethodVisitor.visitInvokeDynamicInsn方法代码示例

本文整理汇总了Java中org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn方法的典型用法代码示例。如果您正苦于以下问题:Java MethodVisitor.visitInvokeDynamicInsn方法的具体用法?Java MethodVisitor.visitInvokeDynamicInsn怎么用?Java MethodVisitor.visitInvokeDynamicInsn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.objectweb.asm.MethodVisitor的用法示例。


在下文中一共展示了MethodVisitor.visitInvokeDynamicInsn方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateMethodTest2

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
/**
 *  Generate test with an invokedynamic, a static bootstrap method without extra args and
 *  args to the target method.
 */
private void generateMethodTest2(ClassVisitor cv) {
  MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test2", "()V",
      null, null);
  MethodType mt = MethodType.methodType(
          CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class);
  Handle bootstrap = new Handle( Opcodes.H_INVOKESTATIC, Type.getInternalName(InvokeCustom.class),
      "bsmLookupStatic", mt.toMethodDescriptorString(), false);
  mv.visitLdcInsn(new Boolean(true));
  mv.visitLdcInsn(new Byte((byte) 127));
  mv.visitLdcInsn(new Character('c'));
  mv.visitLdcInsn(new Short((short) 1024));
  mv.visitLdcInsn(new Integer(123456));
  mv.visitLdcInsn(new Float(1.2f));
  mv.visitLdcInsn(new Long(123456789));
  mv.visitLdcInsn(new Double(3.5123456789));
  mv.visitLdcInsn("String");
  mv.visitInvokeDynamicInsn("targetMethodTest2", "(ZBCSIFJDLjava/lang/String;)V", bootstrap);
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(-1, -1);
}
 
开发者ID:inferjay,项目名称:r8,代码行数:25,代码来源:TestGenerator.java

示例2: generateMethodTest4

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 invokespecial.
 */
private void generateMethodTest4(ClassVisitor cv) {
  MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test4", "()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),
      "bsmCreateCallSite", 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("targetMethodTest5", "(Linvokecustom/InvokeCustom;)V", bootstrap,
      new Handle( Opcodes.H_INVOKESPECIAL, Type.getInternalName(Super.class),
          "targetMethodTest5", "()V", false));
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(-1, -1);
}
 
开发者ID:inferjay,项目名称:r8,代码行数:22,代码来源:TestGenerator.java

示例3: 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

示例4: 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

示例5: 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

示例6: generateMethodTest8

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 virtual. The target method is a method into an interface that is
 *  not shadowed by an implementation into a classes implementing the interface.
 */
private void generateMethodTest8(ClassVisitor cv) {
  MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test8", "()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),
      "bsmCreateCallCallingtargetMethodTest9", 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("targetMethodTest9", "(Linvokecustom/InvokeCustom;)V", bootstrap,
      new Handle(Opcodes.H_INVOKEVIRTUAL, Type.getInternalName(InvokeCustom.class),
          "targetMethodTest9", "()V", false));
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(-1, -1);
}
 
开发者ID:inferjay,项目名称:r8,代码行数:23,代码来源:TestGenerator.java

示例7: generateMethodTest9

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 virtual. The target method is a method into a class implementing
 *  an abstract method and that shadows a default method from an interface.
 */
private void generateMethodTest9(ClassVisitor cv) {
  MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test9", "()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),
      "bsmCreateCallCallingtargetMethodTest10", 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("targetMethodTest10", "(Linvokecustom/InvokeCustom;)V", bootstrap,
      new Handle(Opcodes.H_INVOKEVIRTUAL, Type.getInternalName(InvokeCustom.class),
          "targetMethodTest10", "()V", false));
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(-1, -1);
}
 
开发者ID:inferjay,项目名称:r8,代码行数:23,代码来源:TestGenerator.java

示例8: generateMethodTest10

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 get static. The method handle read a static field from a class.
 */
private void generateMethodTest10(ClassVisitor cv) {
  MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test10", "()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),
      "bsmCreateCallCallingtargetMethod", mt.toMethodDescriptorString(), false);
  mv.visitFieldInsn(Opcodes.GETSTATIC,
      "java/lang/System",
      "out",
      "Ljava/io/PrintStream;");
  mv.visitInvokeDynamicInsn("staticField1", "()Ljava/lang/String;", bootstrap,
      new Handle(Opcodes.H_GETSTATIC, Type.getInternalName(InvokeCustom.class),
          "staticField1", "Ljava/lang/String;", false));
  mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
      "java/io/PrintStream",
      "println",
      "(Ljava/lang/String;)V", false);
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(-1, -1);
}
 
开发者ID:inferjay,项目名称:r8,代码行数:26,代码来源:TestGenerator.java

示例9: generateMethodTest12

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 get instance. The method handle read an instance field from a class.
 */
private void generateMethodTest12(ClassVisitor cv) {
  MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test12", "()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),
      "bsmCreateCallCallingtargetMethod", mt.toMethodDescriptorString(), false);
  mv.visitFieldInsn(Opcodes.GETSTATIC,
      "java/lang/System",
      "out",
      "Ljava/io/PrintStream;");
  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("instanceField1", "(Linvokecustom/InvokeCustom;)Ljava/lang/String;",
      bootstrap, new Handle(Opcodes.H_GETFIELD, Type.getInternalName(InvokeCustom.class),
          "instanceField1", "Ljava/lang/String;", false));
  mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
      "java/io/PrintStream",
      "println",
      "(Ljava/lang/String;)V", false);
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(-1, -1);
}
 
开发者ID:inferjay,项目名称:r8,代码行数:30,代码来源:TestGenerator.java

示例10: generateMethodTest1

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
/**
 *  Generate test with an invokedynamic, a static bootstrap method without extra args and no arg
 *  to the target method.
 */
private void generateMethodTest1(ClassVisitor cv) {
  MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test1", "()V",
          null, null);
  MethodType mt =
      MethodType.methodType(
          CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class);
  Handle bootstrap = new Handle( Opcodes.H_INVOKESTATIC, Type.getInternalName(InvokeCustom.class),
      "bsmLookupStatic", mt.toMethodDescriptorString(), false);
  mv.visitInvokeDynamicInsn("targetMethodTest1", "()V", bootstrap);
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(-1, -1);
}
 
开发者ID:inferjay,项目名称:r8,代码行数:17,代码来源:TestGenerator.java

示例11: generateMethodTest3

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
/**
 *  Generate test with an invokedynamic, a static bootstrap method with extra args and no arg
 *  to the target method.
 */
private void generateMethodTest3(ClassVisitor cv) {
  MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test3", "()V",
      null, null);
  MethodType mt = MethodType.methodType(
          CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class, int.class,
      long.class, float.class, double.class);
  Handle bootstrap = new Handle( Opcodes.H_INVOKESTATIC, Type.getInternalName(InvokeCustom.class),
      "bsmLookupStaticWithExtraArgs", mt.toMethodDescriptorString(), false);
  mv.visitInvokeDynamicInsn("targetMethodTest3", "()V", bootstrap, new Integer(1),
      new Long(123456789), new Float(123.456), new Double(123456.789123));
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(-1, -1);
}
 
开发者ID:inferjay,项目名称:r8,代码行数:18,代码来源:TestGenerator.java

示例12: generateMethodTest11

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 put static. The method handle write a static field in a class and then
 * print its value.
 */
private void generateMethodTest11(ClassVisitor cv) {
  MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test11", "()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),
      "bsmCreateCallCallingtargetMethod", mt.toMethodDescriptorString(), false);
  mv.visitLdcInsn("Write static field");
  mv.visitInvokeDynamicInsn("staticField1", "(Ljava/lang/String;)V", bootstrap,
      new Handle(Opcodes.H_PUTSTATIC, Type.getInternalName(InvokeCustom.class),
          "staticField1", "Ljava/lang/String;", false));
  mv.visitFieldInsn(Opcodes.GETSTATIC,
      "java/lang/System",
      "out",
      "Ljava/io/PrintStream;");
  mv.visitFieldInsn(Opcodes.GETSTATIC,
      Type.getInternalName(InvokeCustom.class),
      "staticField1",
      "Ljava/lang/String;");
  mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
      "java/io/PrintStream",
      "println",
      "(Ljava/lang/String;)V", false);
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(-1, -1);
}
 
开发者ID:inferjay,项目名称:r8,代码行数:32,代码来源:TestGenerator.java

示例13: generateMethodTest13

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 put instance. The method handle write an instance field in a class and
 * then print its value.
 */
private void generateMethodTest13(ClassVisitor cv) {
  MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test13", "()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),
      "bsmCreateCallCallingtargetMethod", 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.visitVarInsn(Opcodes.ASTORE, 0);
  mv.visitVarInsn(Opcodes.ALOAD, 0);
  mv.visitLdcInsn("Write instance field");
  mv.visitInvokeDynamicInsn("instanceField1", "(Linvokecustom/InvokeCustom;Ljava/lang/String;)V",
      bootstrap, new Handle(Opcodes.H_PUTFIELD, Type.getInternalName(InvokeCustom.class),
          "instanceField1", "Ljava/lang/String;", false));
  mv.visitFieldInsn(Opcodes.GETSTATIC,
      "java/lang/System",
      "out",
      "Ljava/io/PrintStream;");
  mv.visitVarInsn(Opcodes.ALOAD, 0);
  mv.visitFieldInsn(Opcodes.GETFIELD,
      Type.getInternalName(InvokeCustom.class),
      "instanceField1",
      "Ljava/lang/String;");
  mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
      "java/io/PrintStream",
      "println",
      "(Ljava/lang/String;)V", false);
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(-1, -1);
}
 
开发者ID:inferjay,项目名称:r8,代码行数:39,代码来源:TestGenerator.java

示例14: accept

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void accept(final MethodVisitor mv) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    acceptAnnotations(mv);
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:6,代码来源:InvokeDynamicInsnNode.java


注:本文中的org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。