本文整理汇总了Java中jdk.internal.org.objectweb.asm.tree.MethodInsnNode类的典型用法代码示例。如果您正苦于以下问题:Java MethodInsnNode类的具体用法?Java MethodInsnNode怎么用?Java MethodInsnNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MethodInsnNode类属于jdk.internal.org.objectweb.asm.tree包,在下文中一共展示了MethodInsnNode类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkNoForName
import jdk.internal.org.objectweb.asm.tree.MethodInsnNode; //导入依赖的package包/类
private static void checkNoForName(MethodNode m) throws Exception {
Iterator<AbstractInsnNode> it = m.instructions.iterator();
while (it.hasNext()) {
AbstractInsnNode n = it.next();
if (n instanceof MethodInsnNode) {
MethodInsnNode met = (MethodInsnNode) n;
if (met.name.equals("forName")
&& met.owner.equals("java/lang/Class")
&& met.desc.equals("(Ljava/lang/String;)Ljava/lang/Class;")) {
throw new Exception("forName not removed in " + m.name);
}
}
}
for (TryCatchBlockNode tcb : m.tryCatchBlocks) {
if (tcb.type.equals(ClassNotFoundException.class.getName().replaceAll("\\.", "/"))) {
throw new Exception("ClassNotFoundException Block not removed for " + m.name);
}
}
}
示例2: naryOperation
import jdk.internal.org.objectweb.asm.tree.MethodInsnNode; //导入依赖的package包/类
@Override
public BasicValue naryOperation(final AbstractInsnNode insn,
final List<? extends BasicValue> values) throws AnalyzerException {
int opcode = insn.getOpcode();
if (opcode == MULTIANEWARRAY) {
return newValue(Type.getType(((MultiANewArrayInsnNode) insn).desc));
} else if (opcode == INVOKEDYNAMIC) {
return newValue(Type
.getReturnType(((InvokeDynamicInsnNode) insn).desc));
} else {
return newValue(Type.getReturnType(((MethodInsnNode) insn).desc));
}
}
示例3: naryOperation
import jdk.internal.org.objectweb.asm.tree.MethodInsnNode; //导入依赖的package包/类
@Override
public SourceValue naryOperation(final AbstractInsnNode insn,
final List<? extends SourceValue> values) {
int size;
int opcode = insn.getOpcode();
if (opcode == MULTIANEWARRAY) {
size = 1;
} else {
String desc = (opcode == INVOKEDYNAMIC) ? ((InvokeDynamicInsnNode) insn).desc
: ((MethodInsnNode) insn).desc;
size = Type.getReturnType(desc).getSize();
}
return new SourceValue(size, insn);
}
示例4: canThrowCheckedException
import jdk.internal.org.objectweb.asm.tree.MethodInsnNode; //导入依赖的package包/类
public static boolean canThrowCheckedException(ReflectionOptimizer.TypeResolver cch,
ClassNode classNode, MethodNode m, TryCatchBlockNode bn) throws Exception {
int istart = m.instructions.indexOf(bn.start);
int iend = m.instructions.indexOf(bn.end);
for (int i = istart; i < iend - 1; i++) {
AbstractInsnNode instr = m.instructions.get(i);
if (instr instanceof MethodInsnNode) {
MethodInsnNode meth = (MethodInsnNode) instr;
ClassReader reader = cch.resolve(classNode, m, meth.owner);
if (reader != null) {
ClassNode cn = new ClassNode();
reader.accept(cn, ClassReader.EXPAND_FRAMES);
for (MethodNode method : cn.methods) {
if (method.name.equals(meth.name)) {
for (String e : method.exceptions) {
if (e.equals(bn.type)) {
return true;
}
}
}
}
} else {
return true;
}
}
}
return false;
}
示例5: checkForName
import jdk.internal.org.objectweb.asm.tree.MethodInsnNode; //导入依赖的package包/类
private static void checkForName(MethodNode m) throws Exception {
Iterator<AbstractInsnNode> it = m.instructions.iterator();
boolean found = false;
while (it.hasNext()) {
AbstractInsnNode n = it.next();
if (n instanceof MethodInsnNode) {
MethodInsnNode met = (MethodInsnNode) n;
if (met.name.equals("forName")
&& met.owner.equals("java/lang/Class")
&& met.desc.equals("(Ljava/lang/String;)Ljava/lang/Class;")) {
found = true;
break;
}
}
}
if (!found) {
throw new Exception("forName removed but shouldn't have");
}
found = false;
for (TryCatchBlockNode tcb : m.tryCatchBlocks) {
if (tcb.type.equals(ClassNotFoundException.class.getName().replaceAll("\\.", "/"))) {
found = true;
break;
}
}
if (!found) {
throw new Exception("tryCatchBlocks removed but shouldn't have");
}
}
示例6: naryOperation
import jdk.internal.org.objectweb.asm.tree.MethodInsnNode; //导入依赖的package包/类
@Override
public BasicValue naryOperation(final AbstractInsnNode insn, final List<? extends BasicValue> values)
throws AnalyzerException
{
int opcode = insn.getOpcode();
if (opcode == MULTIANEWARRAY) {
return newValue(Type.getType(((MultiANewArrayInsnNode) insn).desc));
} else if (opcode == INVOKEDYNAMIC){
return newValue(Type.getReturnType(((InvokeDynamicInsnNode) insn).desc));
} else {
return newValue(Type.getReturnType(((MethodInsnNode) insn).desc));
}
}
示例7: naryOperation
import jdk.internal.org.objectweb.asm.tree.MethodInsnNode; //导入依赖的package包/类
@Override
public SourceValue naryOperation(final AbstractInsnNode insn, final List<? extends SourceValue> values) {
int size;
int opcode = insn.getOpcode();
if (opcode == MULTIANEWARRAY) {
size = 1;
} else {
String desc = (opcode == INVOKEDYNAMIC)?
((InvokeDynamicInsnNode) insn).desc:
((MethodInsnNode) insn).desc;
size = Type.getReturnType(desc).getSize();
}
return new SourceValue(size, insn);
}
示例8: replaceWithClassConstant
import jdk.internal.org.objectweb.asm.tree.MethodInsnNode; //导入依赖的package包/类
public static Data replaceWithClassConstant(ClassNode cn, MethodNode m,
TypeResolver cch)
throws Exception {
Iterator<AbstractInsnNode> it = m.instructions.iterator();
LdcInsnNode insNode = null;
Map<LdcInsnNode, LdcInsnNode> replacement = new IdentityHashMap<>();
Data data = new Data();
while (it.hasNext()) {
AbstractInsnNode n = it.next();
if (n instanceof LdcInsnNode) {
LdcInsnNode ldc = (LdcInsnNode) n;
if (ldc.cst instanceof String) {
insNode = ldc;
}
} else {
if (n instanceof MethodInsnNode && insNode != null) {
MethodInsnNode met = (MethodInsnNode) n;
if (met.name.equals("forName")
&& met.owner.equals("java/lang/Class")
&& met.desc.equals("(Ljava/lang/String;)Ljava/lang/Class;")) {
// Can we load the type?
Type type = null;
String binaryName = insNode.cst.toString().replaceAll("\\.", "/");
String unaryClassName = binaryName;
int arrayIndex = binaryName.lastIndexOf("[");
if (arrayIndex >= 0) {
int objIndex = unaryClassName.indexOf("L");
if (objIndex >= 0) {
unaryClassName = unaryClassName.substring(objIndex + 1);
unaryClassName = unaryClassName.substring(0,
unaryClassName.length() - 1);
} else {
//primitive, this is just fine.
type = Type.getObjectType(binaryName);
}
}
if (type == null) {
if (cch.resolve(cn, m, unaryClassName) != null) {
type = Type.getObjectType(binaryName);
}
}
if (type != null) {
replacement.put(insNode, new LdcInsnNode(type));
it.remove();
data.removedInstructions += 1;
}
} else {
insNode = null;
}
// Virtual node, not taken into account
} else if (!(n instanceof LabelNode) && !(n instanceof LineNumberNode)) {
insNode = null;
}
}
}
for (Map.Entry<LdcInsnNode, LdcInsnNode> entry : replacement.entrySet()) {
m.instructions.set(entry.getKey(), entry.getValue());
}
if (!replacement.isEmpty()) {
String[] types = {"java/lang/ClassNotFoundException"};
data.removedInstructions += deleteExceptionHandlers(cch, data, cn, m, types);
}
return data;
}