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


Java MethodInsnNode類代碼示例

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


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

示例1: stringEncryptionTransformer

import org.objectweb.asm.tree.MethodInsnNode; //導入依賴的package包/類
private static void stringEncryptionTransformer(ClassNode classNode) {
    if (classNode.superName.equals("org/bukkit/plugin/java/JavaPlugin") || classNode.superName.equals("net/md_5/bungee/api/plugin/Plugin")) {
        for (MethodNode methodNode : classNode.methods) {
            InsnList nodes = methodNode.instructions;
            for (int i = 0; i < nodes.size(); i++) {
                AbstractInsnNode instruction = nodes.get(i);
                if (instruction instanceof LdcInsnNode) {
                    if (instruction.getNext() instanceof MethodInsnNode) {
                        LdcInsnNode ldc = (LdcInsnNode) instruction;
                        MethodInsnNode methodinsnnode = (MethodInsnNode) ldc.getNext();
                        if (ldc.cst instanceof String) {
                            if (methodinsnnode.name.equalsIgnoreCase("\u0972") && methodinsnnode.desc.equalsIgnoreCase("(Ljava/lang/String;)Ljava/lang/String;")) {
                                methodNode.instructions.remove(methodinsnnode);
                                ldc.cst = decryptionArray((String)ldc.cst);
                            }
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:23,代碼來源:InjectorRemover.java

示例2: toNumericalValue

import org.objectweb.asm.tree.MethodInsnNode; //導入依賴的package包/類
public static InsnList toNumericalValue(String what) {
  Objects.requireNonNull(what);
  InsnList il = new InsnList();

  il.add(new LdcInsnNode(what));
  il.add(new MethodInsnNode(
      INVOKESTATIC,
      Type.getInternalName(Conversions.class),
      "toNumericalValue",
      Type.getMethodDescriptor(
          Type.getType(Number.class),
          Type.getType(Object.class),
          Type.getType(String.class)),
      false));

  return il;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:18,代碼來源:ConversionMethods.java

示例3: getMethodTransformers

import org.objectweb.asm.tree.MethodInsnNode; //導入依賴的package包/類
@Override
public MethodTransformer[] getMethodTransformers() {
	MethodTransformer loadWorldTransformer = new MethodTransformer() {
		public String getMethodName() {return CoreLoader.isObfuscated ? "a" : "loadWorld";}
		public String getDescName() {return "(L" + (CoreLoader.isObfuscated ? "bnq" : Type.getInternalName(WorldClient.class)) + ";Ljava/lang/String;)V";}
		
		public void transform(ClassNode classNode, MethodNode method, boolean obfuscated) {
			CLTLog.info("Found method: " + method.name + " " + method.desc);
			CLTLog.info("begining at start of method " + getMethodName());
			
			//TransformerUtil.onWorldLoad(WorldClient worldClientIn)
			InsnList toInsert = new InsnList();
			toInsert.add(new VarInsnNode(ALOAD, 1)); //worldClientIn
			toInsert.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(TransformerUtil.class),
					"onWorldLoad", "(L" + Type.getInternalName(WorldClient.class) + ";)V", false));
			method.instructions.insertBefore(method.instructions.getFirst(), toInsert);
		}
	};
	
	return new MethodTransformer[] {loadWorldTransformer};
}
 
開發者ID:18107,項目名稱:MC-Ray-Tracer,代碼行數:22,代碼來源:MinecraftTransformer.java

示例4: invokeType

import org.objectweb.asm.tree.MethodInsnNode; //導入依賴的package包/類
private Invoke.Type invokeType(MethodInsnNode method) {
  switch (method.getOpcode()) {
    case Opcodes.INVOKEVIRTUAL:
      if (isCallToPolymorphicSignatureMethod(method)) {
        return Invoke.Type.POLYMORPHIC;
      }
      return Invoke.Type.VIRTUAL;
    case Opcodes.INVOKESTATIC:
      return Invoke.Type.STATIC;
    case Opcodes.INVOKEINTERFACE:
      return Invoke.Type.INTERFACE;
    case Opcodes.INVOKESPECIAL: {
      DexType owner = application.getTypeFromName(method.owner);
      if (owner == clazz || method.name.equals(Constants.INSTANCE_INITIALIZER_NAME)) {
        return Invoke.Type.DIRECT;
      } else {
        return Invoke.Type.SUPER;
      }
    }
    default:
      throw new Unreachable("Unexpected MethodInsnNode opcode: " + method.getOpcode());
  }
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:24,代碼來源:JarSourceCode.java

示例5: build

import org.objectweb.asm.tree.MethodInsnNode; //導入依賴的package包/類
private void build(MethodInsnNode insn, IRBuilder builder) {
  // Resolve the target method of the invoke.
  DexMethod method = application.getMethod(insn.owner, insn.name, insn.desc);

  buildInvoke(
      insn.desc,
      Type.getObjectType(insn.owner),
      insn.getOpcode() != Opcodes.INVOKESTATIC,
      builder,
      (types, registers) -> {
        Invoke.Type invokeType = invokeType(insn);
        DexProto callSiteProto = null;
        DexMethod targetMethod = method;
        if (invokeType == Invoke.Type.POLYMORPHIC) {
          targetMethod = application.getMethod(
              insn.owner, insn.name, METHODHANDLE_INVOKE_OR_INVOKEEXACT_DESC);
          callSiteProto = application.getProto(insn.desc);
        }
        builder.addInvoke(invokeType, targetMethod, callSiteProto, types, registers);
      });
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:22,代碼來源:JarSourceCode.java

示例6: checkArrayArgs

import org.objectweb.asm.tree.MethodInsnNode; //導入依賴的package包/類
private void checkArrayArgs(MethodNode methodNode, Frame<BasicValue> logMessageFrame, Frame<BasicValue> arraySizeFrame,
                            int lineNumber, MethodInsnNode methodInsn, int messageIndex, int arrayIndex) {
    BasicValue arraySizeObject = getStackValue(arraySizeFrame, methodInsn, arrayIndex);
    if (arraySizeObject instanceof ArraySizeBasicValue == false) {
        wrongUsageCallback.accept(new WrongLoggerUsage(className, methodNode.name, methodInsn.name, lineNumber,
            "Could not determine size of array"));
        return;
    }
    ArraySizeBasicValue arraySize = (ArraySizeBasicValue) arraySizeObject;
    PlaceHolderStringBasicValue logMessageLength = checkLogMessageConsistency(methodNode, logMessageFrame, lineNumber, methodInsn,
        messageIndex, arraySize.minValue);
    if (logMessageLength == null) {
        return;
    }
    if (arraySize.minValue != arraySize.maxValue) {
        wrongUsageCallback.accept(new WrongLoggerUsage(className, methodNode.name, methodInsn.name, lineNumber,
            "Multiple parameter arrays with conflicting sizes"));
        return;
    }
    assert logMessageLength.minValue == logMessageLength.maxValue && arraySize.minValue == arraySize.maxValue;
    if (logMessageLength.minValue != arraySize.minValue) {
        wrongUsageCallback.accept(new WrongLoggerUsage(className, methodNode.name, methodInsn.name, lineNumber,
            "Expected " + logMessageLength.minValue + " arguments but got " + arraySize.minValue));
        return;
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:27,代碼來源:ESLoggerUsageChecker.java

示例7: checkLogMessageConsistency

import org.objectweb.asm.tree.MethodInsnNode; //導入依賴的package包/類
private PlaceHolderStringBasicValue checkLogMessageConsistency(MethodNode methodNode, Frame<BasicValue> logMessageFrame,
                                                               int lineNumber, MethodInsnNode methodInsn, int messageIndex,
                                                               int argsSize) {
    BasicValue logMessageLengthObject = getStackValue(logMessageFrame, methodInsn, messageIndex);
    if (logMessageLengthObject instanceof PlaceHolderStringBasicValue == false) {
        if (argsSize > 0) {
            wrongUsageCallback.accept(new WrongLoggerUsage(className, methodNode.name, methodInsn.name, lineNumber,
                "First argument must be a string constant so that we can statically ensure proper place holder usage"));
        } else {
            // don't check logger usage for logger.warn(someObject)
        }
        return null;
    }
    PlaceHolderStringBasicValue logMessageLength = (PlaceHolderStringBasicValue) logMessageLengthObject;
    if (logMessageLength.minValue != logMessageLength.maxValue) {
        wrongUsageCallback.accept(new WrongLoggerUsage(className, methodNode.name, methodInsn.name, lineNumber,
            "Multiple log messages with conflicting number of place holders"));
        return null;
    }
    return logMessageLength;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:22,代碼來源:ESLoggerUsageChecker.java

示例8: replaceInvokeSpecial

import org.objectweb.asm.tree.MethodInsnNode; //導入依賴的package包/類
private void replaceInvokeSpecial(ClassNode clazz, List<MethodNode> toReplace)
{
    for (MethodNode method : clazz.methods)
    {
        for (Iterator<AbstractInsnNode> it = method.instructions.iterator(); it.hasNext();)
        {
            AbstractInsnNode insn = it.next();
            if (insn.getOpcode() == INVOKESPECIAL)
            {
                MethodInsnNode mInsn = (MethodInsnNode) insn;
                for (MethodNode n : toReplace)
                {
                    if (n.name.equals(mInsn.name) && n.desc.equals(mInsn.desc))
                    {
                        mInsn.setOpcode(INVOKEVIRTUAL);
                        break;
                    }
                }
            }
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:23,代碼來源:AccessTransformer.java

示例9: transform

import org.objectweb.asm.tree.MethodInsnNode; //導入依賴的package包/類
@Override
public void transform(ClassNode clazz, MethodNode method, InsnMatcher matcher) {
	method.tryCatchBlocks.clear();
	method.localVariables.clear();
	method.instructions.clear();

	/* this.loginHandlerList.put(SteamIdAsString, loginHandler); */
	method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
	method.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "com/wurmonline/server/steam/SteamHandler", "loginHandlerList", "Ljava/util/Map;"));
	method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1));
	method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 2));
	method.instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, "java/util/Map", "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", true));
	method.instructions.add(new InsnNode(Opcodes.POP));

	/* return true; */
	method.instructions.add(new InsnNode(Opcodes.ICONST_1));
	method.instructions.add(new InsnNode(Opcodes.IRETURN));
}
 
開發者ID:jonathanedgecombe,項目名稱:anvil,代碼行數:19,代碼來源:SteamAuthDuplicateTransformer.java

示例10: newTable

import org.objectweb.asm.tree.MethodInsnNode; //導入依賴的package包/類
public static InsnList newTable(int array, int hash) {
  InsnList il = new InsnList();

  il.add(ASMUtils.loadInt(array));
  il.add(ASMUtils.loadInt(hash));

  il.add(new MethodInsnNode(
      INVOKEINTERFACE,
      selfTpe().getInternalName(),
      "newTable",
      Type.getMethodType(
          Type.getType(Table.class),
          Type.INT_TYPE,
          Type.INT_TYPE).getDescriptor(),
      true));

  return il;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:19,代碼來源:ExecutionContextMethods.java

示例11: get

import org.objectweb.asm.tree.MethodInsnNode; //導入依賴的package包/類
public static InsnList get(int index) {
  Check.nonNegative(index);

  InsnList il = new InsnList();

  if (index <= 4) {
    String methodName = "get" + index;
    il.add(new MethodInsnNode(
        INVOKEINTERFACE,
        selfTpe().getInternalName(),
        methodName,
        Type.getMethodType(
            Type.getType(Object.class)).getDescriptor(),
        true));
  } else {
    il.add(ASMUtils.loadInt(index));
    il.add(get());
  }

  return il;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:22,代碼來源:ReturnBufferMethods.java

示例12: resumptionHandler

import org.objectweb.asm.tree.MethodInsnNode; //導入依賴的package包/類
protected InsnList resumptionHandler(LabelNode label) {
  InsnList il = new InsnList();

  il.add(label);
  il.add(ASMUtils.frameSame1(UnresolvedControlThrowable.class));

  il.add(createSnapshot());

  // register snapshot with the control exception
  il.add(new MethodInsnNode(
      INVOKEVIRTUAL,
      Type.getInternalName(UnresolvedControlThrowable.class),
      "resolve",
      Type.getMethodType(
          Type.getType(ResolvedControlThrowable.class),
          Type.getType(Resumable.class),
          Type.getType(Object.class)).getDescriptor(),
      false));

  // rethrow
  il.add(new InsnNode(ATHROW));

  return il;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:25,代碼來源:RunMethod.java

示例13: callDetour

import org.objectweb.asm.tree.MethodInsnNode; //導入依賴的package包/類
private Detour callDetour(ClassNode cn, MethodNode mn, AnnotationNode a) {
  String owner = getFirstParameter(mn);

  if (owner == null) {
    _log.debug("Could not get parameter type for detour " + mn.name + mn.desc);
    return null;
  }

  MethodInsnNode mi = getMethodInstruction(mn, owner, mn.name);
  if (mi == null) {
    _log.debug("Could not get method instruction for detour " + mn.name + mn.desc);
    return null;
  }

  CallDetour detour = new CallDetour(_log);
  detour.matchMethod = mn.name;
  detour.matchDesc = mi.desc;
  detour.owner = owner.replace('/', '.');
  detour.detourOwner = cn.name;
  detour.detourDesc = mn.desc;

  return detour;
}
 
開發者ID:rakutentech,項目名稱:android-perftracking,代碼行數:24,代碼來源:DetourLoader.java

示例14: analyze

import org.objectweb.asm.tree.MethodInsnNode; //導入依賴的package包/類
@SuppressWarnings("unchecked")
boolean analyze() {
	for (final Iterator<AbstractInsnNode> it = methodNode.instructions.iterator(); it
			.hasNext();) {
		//CHECKSTYLE:OFF
		final AbstractInsnNode instruction = it.next();
		//CHECKSTYLE:ON
		if (instruction instanceof MethodInsnNode) {
			final MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
			if (STRING_INTERNAL_NAME.equals(methodInsnNode.owner)
					&& "toString".equals(methodInsnNode.name)) {
				// il n'y a qu'une méthode toString dans la classe String, inutile de vérifier desc
				return true;
			}
		}
	}
	return false;
}
 
開發者ID:evernat,項目名稱:dead-code-detector,代碼行數:19,代碼來源:StringToStringAnalyzer.java

示例15: populateClassGraph

import org.objectweb.asm.tree.MethodInsnNode; //導入依賴的package包/類
public void populateClassGraph() {
  String className = Type.getObjectType(classNode.name).getClassName();
  logger.debug("Creating graph for class {}" , className);
  for (MethodNode methodNode : classNode.methods) {
    String methodName = methodNode.name;
    MethodGraph caller = new MethodGraph(className, methodName);
    InsnList instructions = methodNode.instructions;
    for (int i = 0; i < instructions.size(); i++) {
      AbstractInsnNode insnNode = instructions.get(i);
      if (insnNode.getType() == AbstractInsnNode.METHOD_INSN) {
        MethodInsnNode methodInsnNode = (MethodInsnNode)insnNode;
        String calledOwner = Type.getObjectType(methodInsnNode.owner).getClassName();
        String calledName = methodInsnNode.name;
        MethodGraph called = new MethodGraph(calledOwner, calledName);
        Call call = new Call(caller, called);
        if (!called.getOwner().equals("java.lang.Object") && !called.getName().equals("<init>")) {
          logger.trace("Adding call graph: {}", call.toString());
          GraphHolder.addCallGraph(call);
        }
      }
    }
  }
}
 
開發者ID:fergarrui,項目名稱:custom-bytecode-analyzer,代碼行數:24,代碼來源:ClassCallGraph.java


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