本文整理汇总了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);
}
}
}
}
}
}
}
}
示例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;
}
示例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};
}
示例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());
}
}
示例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);
});
}
示例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;
}
}
示例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;
}
示例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;
}
}
}
}
}
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
}