本文整理了Java中org.objectweb.asm.tree.TypeInsnNode
类的一些代码示例,展示了TypeInsnNode
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TypeInsnNode
类的具体详情如下:
包路径:org.objectweb.asm.tree.TypeInsnNode
类名称:TypeInsnNode
[英]A node that represents a type instruction. A type instruction is an instruction that takes a type descriptor as parameter.
[中]表示类型指令的节点。类型指令是以类型描述符为参数的指令。
代码示例来源:origin: jphp-group/jphp
public void writePushParameters(Collection<Memory> memories) {
writePushSmallInt(memories.size());
code.add(new TypeInsnNode(ANEWARRAY, Type.getInternalName(Memory.class)));
stackPop();
stackPush(Memory.Type.REFERENCE);
int i = 0;
for (Memory param : memories) {
writePushDup();
writePushSmallInt(i);
writePushMemory(param);
writePopBoxing(true, false);
code.add(new InsnNode(AASTORE));
stackPop();
stackPop();
stackPop();
i++;
}
}
代码示例来源:origin: jooby-project/jooby
|| getOrCreateKotlinClass().test(node)) {
String owner = Type.getReturnType(node.desc).getClassName();
AbstractInsnNode prev = node.getPrevious();
if (prev instanceof FieldInsnNode && ((MethodInsnNode) n).name.equals("toEnum")) {
toType = loadType(loader, ((Type) cst).getClassName());
AbstractInsnNode next = node.getNext();
if (next instanceof MethodInsnNode) {
String joobyKt = ((MethodInsnNode) next).owner;
} else if (n instanceof TypeInsnNode) {
TypeInsnNode typeInsn = (TypeInsnNode) n;
if (typeInsn.getOpcode() == Opcodes.CHECKCAST) {
return loadType(loader, typeInsn.desc);
代码示例来源:origin: linkedin/parseq
static String getDescriptionForTypeInsnNode(TypeInsnNode typeInsnNode) {
AbstractInsnNode nextInsn = typeInsnNode.getNext();
StringJoiner argsDesc = new StringJoiner(",", "(", ")");
while (nextInsn != null) {
if (nextInsn instanceof LdcInsnNode) {
argsDesc.add("_");
} else if (nextInsn.getOpcode() == Opcodes.DUP) {
//ignore
} else {
break;
}
nextInsn = nextInsn.getNext();
}
if (typeInsnNode.getOpcode() == Opcodes.NEW) {
return "new " + Util.extractSimpleName(typeInsnNode.desc, "/") + argsDesc.toString();
}
return "";
}
}
代码示例来源:origin: mjanicek/rembulan
LabelNode end = new LabelNode();
il.add(begin);
il.add(new VarInsnNode(ALOAD, 2));
il.add(new TypeInsnNode(CHECKCAST, Type.getInternalName(DefaultSavedState.class)));
il.add(new VarInsnNode(ASTORE, 3));
il.add(new VarInsnNode(ALOAD, 0)); // this
il.add(new MethodInsnNode(
il.add(new MethodInsnNode(
il.add(new InsnNode(DUP));
il.add(new InsnNode(AALOAD));
if (i == 0 && context.isVararg()) {
il.add(new TypeInsnNode(CHECKCAST, ASMUtils.arrayTypeFor(Object.class).getInternalName()));
il.add(new InsnNode(SWAP));
il.add(new TypeInsnNode(NEW, Type.getInternalName(NonsuspendableFunctionException.class)));
代码示例来源:origin: robolectric/robolectric
instructions.add(new TypeInsnNode(Opcodes.ANEWARRAY, "java/lang/Object"));
instructions.add(new TypeInsnNode(Opcodes.CHECKCAST, remappedType));
break;
case VOID:
break;
case Type.LONG:
instructions.add(new TypeInsnNode(Opcodes.CHECKCAST, Type.getInternalName(Long.class)));
instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, Type.getInternalName(Long.class), "longValue", Type.getMethodDescriptor(Type.LONG_TYPE), false));
break;
case Type.FLOAT:
instructions.add(new TypeInsnNode(Opcodes.CHECKCAST, Type.getInternalName(Float.class)));
case Type.DOUBLE:
instructions.add(new TypeInsnNode(Opcodes.CHECKCAST, Type.getInternalName(Double.class)));
case Type.BOOLEAN:
instructions.add(new TypeInsnNode(Opcodes.CHECKCAST, Type.getInternalName(Boolean.class)));
case Type.INT:
instructions.add(new TypeInsnNode(Opcodes.CHECKCAST, Type.getInternalName(Integer.class)));
case Type.SHORT:
instructions.add(new TypeInsnNode(Opcodes.CHECKCAST, Type.getInternalName(Short.class)));
case Type.BYTE:
instructions.add(new TypeInsnNode(Opcodes.CHECKCAST, Type.getInternalName(Byte.class)));
代码示例来源:origin: EvoSuite/evosuite
@Override
protected AbstractInsnNode transformMethodInsnNode(MethodNode mn,
MethodInsnNode methodNode) {
if (methodNode.owner.equals(Type.getInternalName(BooleanHelper.class)))
return methodNode;
if (!(methodNode.getPrevious().getOpcode() == Opcodes.ICONST_1 || methodNode.getPrevious().getOpcode() == Opcodes.ICONST_0)) {
MethodInsnNode booleanHelperInvoke = new MethodInsnNode(
Opcodes.INVOKESTATIC,
Type.getInternalName(BooleanHelper.class),
Type.getMethodDescriptor(Type.BOOLEAN_TYPE,
new Type[] { Type.INT_TYPE }));
mn.instructions.insertBefore(methodNode,
booleanHelperInvoke);
InsnList insnlist = new InsnList();
insnlist.add(booleanHelperPushParameter);
insnlist.add(booleanHelperPopParameter);
if (objectNeedCast) {
TypeInsnNode tin = new TypeInsnNode(
Opcodes.CHECKCAST,
types[i].getInternalName());
代码示例来源:origin: org.multiverse/multiverse-alpha-unborn
int tranlocalVar = indexOfTranlocalVariable(methodNode.name, methodNode.desc);
InsnList newInstructions = new InsnList();
newInstructions.add(startLabelNode);
newInstructions.add(new LineNumberNode(debugInfo.beginLine, startLabelNode));
newInstructions.add(new InsnNode(DUP2_X1));
newInstructions.add(new InsnNode(POP2));
newInstructions.add(new InsnNode(SWAP));
originalFieldInsnNode.owner, originalFieldInsnNode.name);
newInstructions.add(new VarInsnNode(ALOAD, tranlocalVar));
newInstructions.add(new VarInsnNode(ALOAD, tranlocalVar));
newInstructions.add(new VarInsnNode(ALOAD, transactionVar));
newInstructions.add(new TypeInsnNode(CHECKCAST, ownerMetadata.getTranlocalName()));
newInstructions.add(new MethodInsnNode(
newInstructions.add(new TypeInsnNode(CHECKCAST, ownerMetadata.getTranlocalName()));
代码示例来源:origin: com.android.tools.build/builder
private static InsnList throwExceptionsList(MethodNode methodNode, ClassNode classNode) {
try {
String runtimeException = Type.getInternalName(RuntimeException.class);
Constructor<RuntimeException> constructor =
RuntimeException.class.getConstructor(String.class);
InsnList instructions = new InsnList();
instructions.add(
new TypeInsnNode(Opcodes.NEW, runtimeException));
instructions.add(new InsnNode(Opcodes.DUP));
String className = classNode.name.replace('/', '.');
instructions.add(new LdcInsnNode("Method " + methodNode.name + " in " + className
+ " not mocked. "
+ "See http://g.co/androidstudio/not-mocked for details."));
instructions.add(new MethodInsnNode(
Opcodes.INVOKESPECIAL,
runtimeException,
CONSTRUCTOR,
Type.getType(constructor).getDescriptor(),
false));
instructions.add(new InsnNode(Opcodes.ATHROW));
return instructions;
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
}
代码示例来源:origin: org.multiverse/multiverse-alpha-unborn
private InsnList fixInstructions(MethodNode originalMethod, CloneMap cloneMap) {
InsnList instructions = new InsnList();
for (int k = 0; k < originalMethod.instructions.size(); k++) {
AbstractInsnNode originalInsn = originalMethod.instructions.get(k);
switch (originalInsn.getOpcode()) {
ClassMetadata ownerMetadata = metadataRepository.loadClassMetadata(classLoader, fieldInsn.owner);
FieldMetadata fieldMetadata = ownerMetadata.getFieldMetadata(fieldInsn.name);
Type originalFieldType = Type.getType(fieldMetadata.getDesc());
instructions.add(new InsnNode(DUP2_X1));
instructions.add(new InsnNode(POP2));
instructions.add(new InsnNode(SWAP));
String referenceName = Type.getType(referenceDesc).getInternalName();
instructions.add(new FieldInsnNode(
if (originalFieldType.getSort() == Type.ARRAY || originalFieldType.getSort() == Type.OBJECT) {
String objectDesc = Type.getDescriptor(Object.class);
MethodInsnNode methodInsn = new MethodInsnNode(
INVOKEVIRTUAL,
referenceName,
if (!originalFieldType.equals(Type.getType(Object.class))) {
instructions.add(new TypeInsnNode(CHECKCAST, originalFieldType.getInternalName()));
代码示例来源:origin: robolectric/robolectric
static void box(final Type type, ListIterator<AbstractInsnNode> instructions) {
if (type.getSort() == OBJECT || type.getSort() == ARRAY) {
return;
}
if (Type.VOID_TYPE.equals(type)) {
instructions.add(new InsnNode(Opcodes.ACONST_NULL));
} else {
Type boxed = getBoxedType(type);
instructions.add(new TypeInsnNode(Opcodes.NEW, boxed.getInternalName()));
if (type.getSize() == 2) {
// Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o
instructions.add(new InsnNode(Opcodes.DUP_X2));
instructions.add(new InsnNode(Opcodes.DUP_X2));
instructions.add(new InsnNode(Opcodes.POP));
} else {
// p -> po -> opo -> oop -> o
instructions.add(new InsnNode(Opcodes.DUP_X1));
instructions.add(new InsnNode(Opcodes.SWAP));
}
instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, boxed.getInternalName(),
"<init>", "(" + type.getDescriptor() + ")V", false));
}
}
代码示例来源:origin: ItzSomebody/Radon
MethodNode methodNode = methodWrapper.methodNode;
for (AbstractInsnNode insn : methodNode.instructions.toArray()) {
if (insn instanceof MethodInsnNode) {
MethodInsnNode methodInsnNode = (MethodInsnNode) insn;
if (!"<init>".equals(methodInsnNode.name)) {
boolean isStatic = (methodInsnNode.getOpcode() == INVOKESTATIC);
String newSig = isStatic ? methodInsnNode.desc : methodInsnNode.desc.replace("(",
"(Ljava/lang/Object;");
Type returnType = Type.getReturnType(methodInsnNode.desc);
Type[] args = Type.getArgumentTypes(newSig);
for (int i = 0; i < args.length; i++) {
Type arg = args[i];
if (arg.getSort() == Type.OBJECT) {
args[i] = Type.getType("Ljava/lang/Object;");
);
methodNode.instructions.set(insn, indy);
if (returnType.getSort() == Type.ARRAY) {
methodNode.instructions.insert(indy, new TypeInsnNode(CHECKCAST,
returnType.getInternalName()));
代码示例来源:origin: org.multiverse/multiverse-alpha-unborn
result.instructions = new InsnList();
result.instructions.add(startLabelNode);
result.instructions.add(new VarInsnNode(ALOAD, 0));
result.instructions.add(new VarInsnNode(ALOAD, transactionVarIndex));
getDescriptor(AlphaTranlocal.class));
result.instructions.add(new MethodInsnNode(
INVOKEINTERFACE,
getInternalName(AlphaTransaction.class),
"openForRead",
openForReadDesc));
result.instructions.add(new TypeInsnNode(
CHECKCAST,
tranlocalName));
MethodInsnNode invokeInsn = new MethodInsnNode(
getInvokeOpcode(methodNode),
classNode.name,
int returnOpCode = Type.getReturnType(methodNode.desc).getOpcode(IRETURN);
result.instructions.add(new InsnNode(returnOpCode));
代码示例来源:origin: org.activecomponents.jadex/jadex-kernel-bdiv3
int foundcon = -1;
for(int i=0; i<l.size(); i++)
AbstractInsnNode n = l.get(i);
+SUtil.firstToUpperCase(name), Type.getMethodDescriptor(Type.VOID_TYPE), null, null);
mnode.instructions.add(clone);
cur = cur.getNext();
init.add(new VarInsnNode(Opcodes.ALOAD, 0));
init.add(new LdcInsnNode(Type.getType("L"+iclname+";")));
init.add(new LdcInsnNode(args.length));
init.add(new TypeInsnNode(Opcodes.ANEWARRAY, "java/lang/Class"));
for(int i=0; i<args.length; i++)
init.add( new LdcInsnNode(args.length));
init.add(new TypeInsnNode(Opcodes.ANEWARRAY, "java/lang/Object"));
for(int i=0; i<args.length; i++)
init.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "jadex/bdiv3/features/impl/BDIAgentFeature", "addInitArgs", "(Ljava/lang/Object;Ljava/lang/Class;[Ljava/lang/Class;[Ljava/lang/Object;)V"));
l.insertBefore(l.get(foundcon+1), init);
代码示例来源:origin: ItzSomebody/Radon
MethodNode methodNode = methodWrapper.methodNode;
for (AbstractInsnNode insn : methodNode.instructions.toArray()) {
if (insn instanceof MethodInsnNode && insn.getOpcode() != INVOKESPECIAL) {
MethodInsnNode methodInsnNode = (MethodInsnNode) insn;
boolean isStatic = (methodInsnNode.getOpcode() == Opcodes.INVOKESTATIC);
Type returnType = Type.getReturnType(methodInsnNode.desc);
int opcode = (isStatic) ? 0 : 1;
encrypt(methodInsnNode.name, 2993),
encrypt(methodInsnNode.desc, 8372));
methodNode.instructions.set(insn, indy);
if (returnType.getSort() == Type.ARRAY) {
methodNode.instructions.insert(indy, new TypeInsnNode(CHECKCAST,
returnType.getInternalName()));
代码示例来源:origin: org.multiverse/multiverse-alpha-unborn
InsnList extraInstructions = new InsnList();
for (FieldNode fieldNode : (List<FieldNode>) classNode.fields) {
FieldMetadata fieldMetadata = classMetadata.getFieldMetadata(fieldNode.name);
extraInstructions.add(new VarInsnNode(ALOAD, 0));
String referenceName = Type.getType(referenceDesc).getInternalName();
extraInstructions.add(new TypeInsnNode(NEW, referenceName));
extraInstructions.add(new InsnNode(DUP));
extraInstructions.add(
new MethodInsnNode(INVOKESPECIAL, referenceName, "<init>", "()V"));
extraInstructions.add(new FieldInsnNode(
代码示例来源:origin: jphp-group/jphp
node.access = ACC_STATIC;
node.name = Constants.STATIC_INIT_METHOD;
node.desc = Type.getMethodDescriptor(Type.getType(void.class));
node.instructions.add(new TypeInsnNode(ANEWARRAY, Type.getInternalName(TraceInfo.class)));
expressionCompiler.stackPush(Memory.Type.REFERENCE);
expressionCompiler.writePushCreateTraceInfo(traceInfo.getStartLine(), traceInfo.getStartPosition());
node.instructions.add(new InsnNode(AASTORE));
expressionCompiler.stackPop();
expressionCompiler.stackPop();
node.instructions.add(new TypeInsnNode(ANEWARRAY, Type.getInternalName(Memory.class)));
expressionCompiler.stackPush(Memory.Type.REFERENCE);
expressionCompiler.writePopBoxing(true, false);
node.instructions.add(new InsnNode(AASTORE));
expressionCompiler.stackPop();
expressionCompiler.stackPop();
node.instructions.add(new TypeInsnNode(ANEWARRAY, Type.getInternalName(Memory[].class)));
expressionCompiler.stackPush(Memory.Type.REFERENCE);
node.instructions.add(new InsnNode(AASTORE));
expressionCompiler.stackPop();
expressionCompiler.stackPop();
代码示例来源:origin: inesc-id-esw/jvstm
if (an.desc.equals(PAR_NEST.getDescriptor())) {
execMethod.maxLocals++;
InsnList preamble = new InsnList();
preamble.add(new TypeInsnNode(NEW, ARRAY_LIST.getInternalName()));
preamble.add(new InsnNode(DUP));
preamble.add(new MethodInsnNode(INVOKESPECIAL, ARRAY_LIST.getInternalName(), "<init>", "()V"));
preamble.add(new VarInsnNode(ASTORE, listIndex));
Iterator<AbstractInsnNode> execInstIter = execMethod.instructions.iterator();
midterm.add(new VarInsnNode(ASTORE, localVariablesIdx.get(callablesManipulated)));
midterm.add(new VarInsnNode(ALOAD, listIndex));
midterm.add(new VarInsnNode(ALOAD, localVariablesIdx.get(callablesManipulated)));
midterm.add(new MethodInsnNode(INVOKEVIRTUAL, ARRAY_LIST.getInternalName(), "add", "(Ljava/lang/Object;)Z"));
if (methodInstr.getNext().getOpcode() != POP) {
midterm.add(new InsnNode(POP));
finish.add(new MethodInsnNode(INVOKEVIRTUAL, cn.name, combinerMethod.name, combinerMethod.desc));
finish.add(new InsnNode(ARETURN));
代码示例来源:origin: org.activecomponents.jadex/jadex-kernel-bdiv3
Type ret = Type.getReturnType(mn.desc);
if(ret.getClassName().equals("byte"))
nl.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "jadex/bdiv3/features/impl/BDIAgentFeature", "getAbstractBeliefValue", "(Ljadex/bridge/IInternalAccess;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;"));
nl.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Number"));
nl.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/lang/Number", "intValue", "()I"));
nl.add(new InsnNode(Opcodes.I2B));
nl.add(new InsnNode(Opcodes.IRETURN));
nl.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "jadex/bdiv3/features/impl/BDIAgentFeature", "getAbstractBeliefValue", "(Ljadex/bridge/IInternalAccess;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;"));
nl.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Number"));
nl.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/lang/Number", "intValue", "()I"));
nl.add(new InsnNode(Opcodes.I2S));
nl.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Number"));
nl.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Character"));
nl.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Boolean"));
nl.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Number"));
nl.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Number"));
nl.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Number"));
nl.add(new TypeInsnNode(Opcodes.CHECKCAST, ret.getInternalName()));
代码示例来源:origin: org.activecomponents.jadex/jadex-kernel-bdiv3
if(name.indexOf(Type.getInternalName(IBDIAgent.class))!=-1)
MethodNode mnode = new MethodNode(Opcodes.ACC_PUBLIC, m.getName(), Type.getMethodDescriptor(m), null, null);
Type ret = Type.getReturnType(mnode.desc);
InsnList nl = new InsnList();
nl.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "jadex/bdiv3/features/impl/BDIAgentFeature", "getBDIAgentFeature", "(Ljadex/bridge/IInternalAccess;)Ljadex/bdiv3/features/IBDIAgentFeature;", false));
nl.add(new VarInsnNode(Opcodes.ILOAD, i+cnt));
nl.add(new VarInsnNode(Opcodes.LLOAD, i+cnt++));
nl.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, "jadex/bdiv3/features/IBDIAgentFeature", mnode.name, mnode.desc, true));
nl.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, "jadex/bridge/IInternalAccess", mnode.name, mnode.desc, true));
nl.add(new InsnNode(Opcodes.IRETURN));
nl.add(new InsnNode(Opcodes.LRETURN));
nl.add(new InsnNode(Opcodes.FRETURN));
String t = ret.toString().length()>1? ret.getInternalName(): ret.toString();
nl.add(new TypeInsnNode(Opcodes.CHECKCAST, t));
nl.add(new InsnNode(Opcodes.ARETURN));
代码示例来源:origin: EvoSuite/evosuite
ListIterator<AbstractInsnNode> iter = methodNode.instructions.iterator();
wInstructions.add(ins);
if(typeIns.getOpcode() == Opcodes.NEW || typeIns.getOpcode() == Opcodes.NEWARRAY)
final Type returnType = Type.getReturnType(methodNode.desc);
if(returnType.equals(Type.VOID_TYPE))
final Type[] argTypes = Type.getArgumentTypes(methodNode.desc);
for(int i = 0; i < argTypes.length; i++)
wInstructions.add(new InsnNode(Opcodes.ACONST_NULL));
wInstructions.add(new VarInsnNode(Opcodes.ASTORE, varReturnValue));
wInstructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
var++;
wInstructions.add(new FrameNode(Opcodes.F_SAME1, 0 ,null, 1, new Object[] {"java/lang/Throwable"}));
wInstructions.add(new VarInsnNode(Opcodes.ASTORE, --var));
wInstructions.add(new VarInsnNode(Opcodes.ALOAD, var));
wInstructions.add(new InsnNode(Opcodes.ATHROW));
wInstructions.add(new InsnNode(Opcodes.RETURN));
内容来源于网络,如有侵权,请联系作者删除!