本文整理汇总了Java中org.objectweb.asm.tree.InvokeDynamicInsnNode类的典型用法代码示例。如果您正苦于以下问题:Java InvokeDynamicInsnNode类的具体用法?Java InvokeDynamicInsnNode怎么用?Java InvokeDynamicInsnNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InvokeDynamicInsnNode类属于org.objectweb.asm.tree包,在下文中一共展示了InvokeDynamicInsnNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import org.objectweb.asm.tree.InvokeDynamicInsnNode; //导入依赖的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));
}
示例2: findInvokeDynamic
import org.objectweb.asm.tree.InvokeDynamicInsnNode; //导入依赖的package包/类
private int findInvokeDynamic() {
AtomicInteger total = new AtomicInteger();
classNodes().forEach(classNode -> {
classNode.methods.forEach(methodNode -> {
for (int i = 0; i < methodNode.instructions.size(); i++) {
AbstractInsnNode abstractInsnNode = methodNode.instructions.get(i);
if (abstractInsnNode instanceof InvokeDynamicInsnNode) {
InvokeDynamicInsnNode dyn = (InvokeDynamicInsnNode) abstractInsnNode;
if (dyn.bsmArgs.length > 0 && dyn.bsmArgs[0] instanceof String) {
total.incrementAndGet();
}
}
}
});
});
return total.get();
}
示例3: naryOperation
import org.objectweb.asm.tree.InvokeDynamicInsnNode; //导入依赖的package包/类
@Override
public ConstValue naryOperation(final AbstractInsnNode insn,
final List<? extends ConstValue> values) {
int opcode = insn.getOpcode();
if (opcode == Opcodes.MULTIANEWARRAY) {
return new ConstValue(1);
} else if (opcode == Opcodes.INVOKEDYNAMIC) {
return new ConstValue(Type.getReturnType(
((InvokeDynamicInsnNode) insn).desc).getSize());
} else {
int size = Type.getReturnType(((MethodInsnNode) insn).desc)
.getSize();
Object cst = InvocationInterpreter.getInstance().execute(
(MethodInsnNode) insn, values);
return new ConstValue(size, cst);
}
}
示例4: naryOperation
import org.objectweb.asm.tree.InvokeDynamicInsnNode; //导入依赖的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));
}
}
示例5: naryOperation
import org.objectweb.asm.tree.InvokeDynamicInsnNode; //导入依赖的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);
}
示例6: patchMethod
import org.objectweb.asm.tree.InvokeDynamicInsnNode; //导入依赖的package包/类
public void patchMethod(MethodNode methodNode, String patchName, String clazzName) {
methodNode.desc = methodNode.desc.replace(patchName, clazzName);
for (Iterator<AbstractInsnNode> iterator = methodNode.instructions.iterator(); iterator.hasNext();) {
AbstractInsnNode insn = iterator.next();
if (insn instanceof TypeInsnNode) {
TypeInsnNode type = (TypeInsnNode) insn;
type.desc = replace(type.desc, patchName, clazzName);
} else if (insn instanceof FieldInsnNode) {
FieldInsnNode field = (FieldInsnNode) insn;
field.owner = replace(field.owner, patchName, clazzName);
} else if (insn instanceof MethodInsnNode) {
MethodInsnNode method = (MethodInsnNode) insn;
if (method.owner.equals(patchName) && method.getOpcode() == INVOKEVIRTUAL)
method.setOpcode(INVOKESPECIAL);
method.owner = replace(method.owner, patchName, clazzName);
} else if (insn instanceof InvokeDynamicInsnNode) {
InvokeDynamicInsnNode dynamic = (InvokeDynamicInsnNode) insn;
String patchDesc = ASMHelper.getClassDesc(patchName), clazzDesc = ASMHelper.getClassDesc(clazzName);
dynamic.desc = replace(dynamic.desc, patchDesc, clazzDesc);
for (int i = 0; i < dynamic.bsmArgs.length; i++)
if (dynamic.bsmArgs[i] instanceof Handle) {
Handle handle = (Handle) dynamic.bsmArgs[i];
dynamic.bsmArgs[i] = new Handle(handle.getTag(), replace(handle.getOwner(), patchName, clazzName),
handle.getName(), replace(handle.getDesc(), patchDesc, clazzDesc), handle.isInterface());
}
} else if (insn instanceof FrameNode) {
FrameNode frame = (FrameNode) insn;
if (frame.local != null)
frame.local.replaceAll((o -> o instanceof String ? replace((String) o, patchName, clazzName) : o));
if (frame.stack != null)
frame.stack.replaceAll((o -> o instanceof String ? replace((String) o, patchName, clazzName) : o));
}
}
}
示例7: naryOperation
import org.objectweb.asm.tree.InvokeDynamicInsnNode; //导入依赖的package包/类
@Override
public ConstValue naryOperation(AbstractInsnNode insn, List<? extends ConstValue> values) {
int opcode = insn.getOpcode();
if (opcode == MULTIANEWARRAY) {
return ConstValue.ONE_SLOT;
} else {
String desc = (opcode == INVOKEDYNAMIC) ? ((InvokeDynamicInsnNode) insn).desc
: ((MethodInsnNode) insn).desc;
return ConstValue.slot(Type.getReturnType(desc).getSize());
}
}
示例8: handle
import org.objectweb.asm.tree.InvokeDynamicInsnNode; //导入依赖的package包/类
@Override
public void handle(AbstractInsnNode node) throws IncorrectNodeException {
super.handle(node);
LOG.debug(logNode(node));
checkType(node, InvokeDynamicInsnNode.class);
InvokeDynamicInsnNode invokeNode = (InvokeDynamicInsnNode) node;
mState.getActiveStack().push(new LambdaExpression(invokeNode.name, invokeNode.desc, invokeNode.bsm, invokeNode.bsmArgs));
}
示例9: cloneInvokeNode
import org.objectweb.asm.tree.InvokeDynamicInsnNode; //导入依赖的package包/类
/**
* Clones an invokevirtual/invokespecial/invokeinterface/invokedynamic node and returns it as an instruction list.
* @param insnNode instruction to clone
* @throws NullPointerException if any argument is {@code null}
* @throws IllegalArgumentException if node isn't of invoke type
* @return instruction list with cloned instruction
*/
public static InsnList cloneInvokeNode(AbstractInsnNode insnNode) {
Validate.notNull(insnNode);
Validate.isTrue(insnNode instanceof MethodInsnNode || insnNode instanceof InvokeDynamicInsnNode);
InsnList ret = new InsnList();
ret.add(insnNode.clone(new HashMap<>()));
return ret;
}
示例10: visitInvokeDynamicInsn
import org.objectweb.asm.tree.InvokeDynamicInsnNode; //导入依赖的package包/类
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) {
final InvokeDynamicInsnNode mnode = new InvokeDynamicInsnNode(name, desc, bsm, bsmArgs);
if (needsFrameGuard(INVOKEDYNAMIC, bsm.getOwner(), name, desc)) {
Label label = new Label();
super.visitLabel(label);
labels.add(label);
nodes.add(mnode);
}
instructions.add(mnode);
}
示例11: findCallSiteInvocationInsertionIndex
import org.objectweb.asm.tree.InvokeDynamicInsnNode; //导入依赖的package包/类
int findCallSiteInvocationInsertionIndex(final MethodInsnNode mnode) {
int inSelected = -1;
for (AbstractInsnNode otherIns = mnode; otherIns != null && inSelected < 0; ) {
otherIns = otherIns.getNext();
if (otherIns instanceof MethodInsnNode || otherIns instanceof InvokeDynamicInsnNode) {
inSelected = nodes.indexOf(otherIns);
}
}
return inSelected;
}
示例12: naryOperation
import org.objectweb.asm.tree.InvokeDynamicInsnNode; //导入依赖的package包/类
@Override
public BasicValue naryOperation(final AbstractInsnNode insn,
final List<? extends BasicValue> values) throws AnalyzerException {
int opcode = insn.opcode();
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));
}
}
示例13: naryOperation
import org.objectweb.asm.tree.InvokeDynamicInsnNode; //导入依赖的package包/类
@Override
public SourceValue naryOperation(final AbstractInsnNode insn,
final List<? extends SourceValue> values) {
int size;
int opcode = insn.opcode();
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);
}
示例14: invokedynamic
import org.objectweb.asm.tree.InvokeDynamicInsnNode; //导入依赖的package包/类
public CodeBlock invokedynamic(final String name, final String descriptor,
final Handle bootstrapMethod, final Object... bootstrapArguments)
{
instructionList.add(new InvokeDynamicInsnNode(name, descriptor,
bootstrapMethod, bootstrapArguments));
return this;
}
示例15: visitInvokeDynamicInsn
import org.objectweb.asm.tree.InvokeDynamicInsnNode; //导入依赖的package包/类
public CodeBlock visitInvokeDynamicInsn(final String name,
final String desc, final Handle bootstrapMethod,
final Object... bootstrapArguments)
{
instructionList.add(new InvokeDynamicInsnNode(name, desc,
bootstrapMethod, bootstrapArguments));
return this;
}