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


Java Handle類代碼示例

本文整理匯總了Java中org.objectweb.asm.Handle的典型用法代碼示例。如果您正苦於以下問題:Java Handle類的具體用法?Java Handle怎麽用?Java Handle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Handle類屬於org.objectweb.asm包,在下文中一共展示了Handle類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: visitInvokeDynamicInsn

import org.objectweb.asm.Handle; //導入依賴的package包/類
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
        Object... bsmArgs) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    if (constructor) {
        Type[] types = Type.getArgumentTypes(desc);
        for (int i = 0; i < types.length; i++) {
            popValue();
            if (types[i].getSize() == 2) {
                popValue();
            }
        }

        Type returnType = Type.getReturnType(desc);
        if (returnType != Type.VOID_TYPE) {
            pushValue(OTHER);
            if (returnType.getSize() == 2) {
                pushValue(OTHER);
            }
        }
    }
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:23,代碼來源:AdviceAdapter.java

示例2: visitInvokeDynamicInsn

import org.objectweb.asm.Handle; //導入依賴的package包/類
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
        Object... bsmArgs) {
    buf.setLength(0);
    buf.append(this.name).append(".visitInvokeDynamicInsn(");
    appendConstant(name);
    buf.append(", ");
    appendConstant(desc);
    buf.append(", ");
    appendConstant(bsm);
    buf.append(", new Object[]{");
    for (int i = 0; i < bsmArgs.length; ++i) {
        appendConstant(bsmArgs[i]);
        if (i != bsmArgs.length - 1) {
            buf.append(", ");
        }
    }
    buf.append("});\n");
    text.add(buf.toString());
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:21,代碼來源:ASMifier.java

示例3: visitInvokeDynamicInsn

import org.objectweb.asm.Handle; //導入依賴的package包/類
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
        Object... bsmArgs) {
    checkStartCode();
    checkEndCode();
    checkMethodIdentifier(version, name, "name");
    checkMethodDesc(desc);
    if (bsm.getTag() != Opcodes.H_INVOKESTATIC
            && bsm.getTag() != Opcodes.H_NEWINVOKESPECIAL) {
        throw new IllegalArgumentException("invalid handle tag "
                + bsm.getTag());
    }
    for (int i = 0; i < bsmArgs.length; i++) {
        checkLDCConstant(bsmArgs[i]);
    }
    super.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    ++insnCount;
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:19,代碼來源:CheckMethodAdapter.java

示例4: build

import org.objectweb.asm.Handle; //導入依賴的package包/類
private void build(InvokeDynamicInsnNode insn, IRBuilder builder) {
  // Bootstrap method
  Handle bsmHandle = insn.bsm;
  if (bsmHandle.getTag() != Opcodes.H_INVOKESTATIC &&
      bsmHandle.getTag() != Opcodes.H_NEWINVOKESPECIAL) {
    throw new Unreachable(
        "Bootstrap handle is not yet supported: tag == " + bsmHandle.getTag());
  }
  // Resolve the bootstrap method.
  DexMethodHandle bootstrapMethod = getMethodHandle(application, bsmHandle);

  // Decode static bootstrap arguments
  List<DexValue> bootstrapArgs = new ArrayList<>();
  for (Object arg : insn.bsmArgs) {
    bootstrapArgs.add(decodeBootstrapArgument(arg));
  }

  // Construct call site
  DexCallSite callSite = application
      .getCallSite(insn.name, insn.desc, bootstrapMethod, bootstrapArgs);

  buildInvoke(insn.desc, null /* Not needed */,
      false /* Receiver is passed explicitly */, builder,
      (types, registers) -> builder.addInvokeCustom(callSite, types, registers));
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:26,代碼來源:JarSourceCode.java

示例5: decodeHandle

import org.objectweb.asm.Handle; //導入依賴的package包/類
Handle decodeHandle(final String val) throws SAXException {
    try {
        int dotIndex = val.indexOf('.');
        int descIndex = val.indexOf('(', dotIndex + 1);
        int tagIndex = val.lastIndexOf('(');
        int itfIndex = val.indexOf(' ', tagIndex + 1);
        
        boolean itf = itfIndex != -1;
        int tag = Integer.parseInt(
                      val.substring(tagIndex + 1,
                            itf? val.length() - 1: itfIndex));
        String owner = val.substring(0, dotIndex);
        String name = val.substring(dotIndex + 1, descIndex);
        String desc = val.substring(descIndex, tagIndex - 1);
        return new Handle(tag, owner, name, desc, itf);

    } catch (RuntimeException e) {
        throw new SAXException("Malformed handle " + val, e);
    }
}
 
開發者ID:acmerli,項目名稱:fastAOP,代碼行數:21,代碼來源:ASMContentHandler.java

示例6: newInvokeDynamic

import org.objectweb.asm.Handle; //導入依賴的package包/類
public Constant newInvokeDynamic(String name, String desc, Handle bsm,
        Object... bsmArgs) {
    key5.set(name, desc, bsm, bsmArgs);
    Constant result = get(key5);
    if (result == null) {
        newNameType(name, desc);
        newHandle(bsm.getTag(), bsm.getOwner(), bsm.getName(),
                bsm.getDesc(), bsm.isInterface());
        for (int i = 0; i < bsmArgs.length; i++) {
            newConst(bsmArgs[i]);
        }
        result = new Constant(key5);
        put(result);
    }
    return result;
}
 
開發者ID:acmerli,項目名稱:fastAOP,代碼行數:17,代碼來源:ConstantPool.java

示例7: generateMethodTest2

import org.objectweb.asm.Handle; //導入依賴的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

示例8: generateMethodTest4

import org.objectweb.asm.Handle; //導入依賴的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

示例9: generateMethodTest5

import org.objectweb.asm.Handle; //導入依賴的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

示例10: generateMethodTest6

import org.objectweb.asm.Handle; //導入依賴的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

示例11: generateMethodTest7

import org.objectweb.asm.Handle; //導入依賴的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

示例12: generateMethodTest12

import org.objectweb.asm.Handle; //導入依賴的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

示例13: isCallToInterface

import org.objectweb.asm.Handle; //導入依賴的package包/類
public static boolean isCallToInterface(Handle handle) {
	assert handle.isInterface() || handle.getTag() != Opcodes.H_INVOKEINTERFACE;

	return handle.isInterface();

	/*return handle.getTag() == Opcodes.H_INVOKEINTERFACE
			|| (handle.getTag() == Opcodes.H_INVOKESPECIAL || handle.getTag() == Opcodes.H_NEWINVOKESPECIAL || handle.getTag() == Opcodes.H_INVOKESTATIC) && handle.isInterface();*/
}
 
開發者ID:sfPlayer1,項目名稱:Matcher,代碼行數:9,代碼來源:Util.java

示例14: visitInvokeDynamicInsn

import org.objectweb.asm.Handle; //導入依賴的package包/類
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) {
	checkState();
	insnIndex++;

	if (mv == null) return;

	Handle target = Util.getTargetHandle(bsm, bsmArgs);

	if (target != null) {
		name = remapper.mapMethodName(target.getOwner(), target.getName(), target.getDesc(), target.isInterface());
	} else {
		String owner = Type.getType(desc).getReturnType().getInternalName();

		name = remapper.mapArbitraryInvokeDynamicMethodName(owner, name);
	}

	boolean copied = false;

	for (int i = 0; i < bsmArgs.length; i++) {
		Object oldArg = bsmArgs[i];
		Object newArg = remapper.mapValue(oldArg);

		if (newArg != oldArg) {
			if (!copied) {
				bsmArgs = Arrays.copyOf(bsmArgs, bsmArgs.length);
				copied = true;
			}

			bsmArgs[i] = newArg;
		}
	}

	mv.visitInvokeDynamicInsn(name, remapper.mapMethodDesc(desc), (Handle) remapper.mapValue(bsm), bsmArgs);
}
 
開發者ID:sfPlayer1,項目名稱:Matcher,代碼行數:36,代碼來源:AsmClassRemapper.java

示例15: visitInvokeDynamicInsn

import org.objectweb.asm.Handle; //導入依賴的package包/類
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
        Object... bsmArgs) {
    for (int i = 0; i < bsmArgs.length; i++) {
        bsmArgs[i] = remapper.mapValue(bsmArgs[i]);
    }
    super.visitInvokeDynamicInsn(
            remapper.mapInvokeDynamicMethodName(name, desc),
            remapper.mapMethodDesc(desc), (Handle) remapper.mapValue(bsm),
            bsmArgs);
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:12,代碼來源:RemappingMethodAdapter.java


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