本文整理汇总了Java中org.objectweb.asm.Opcodes.INVOKEVIRTUAL属性的典型用法代码示例。如果您正苦于以下问题:Java Opcodes.INVOKEVIRTUAL属性的具体用法?Java Opcodes.INVOKEVIRTUAL怎么用?Java Opcodes.INVOKEVIRTUAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.objectweb.asm.Opcodes
的用法示例。
在下文中一共展示了Opcodes.INVOKEVIRTUAL属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doVisitMethodInsn
private void doVisitMethodInsn(int opcode, final String owner,
final String name, final String desc, final boolean itf) {
switch (opcode) {
case Opcodes.INVOKESPECIAL:
invokespecial(owner, name, desc, itf);
break;
case Opcodes.INVOKEVIRTUAL:
invokevirtual(owner, name, desc, itf);
break;
case Opcodes.INVOKESTATIC:
invokestatic(owner, name, desc, itf);
break;
case Opcodes.INVOKEINTERFACE:
invokeinterface(owner, name, desc);
break;
default:
throw new IllegalArgumentException();
}
}
示例2: visitMethodInsn
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
DexType ownerType = application.getTypeFromName(owner);
DexMethod method = application.getMethod(ownerType, name, desc);
switch (opcode) {
case Opcodes.INVOKEVIRTUAL:
registry.registerInvokeVirtual(method);
break;
case Opcodes.INVOKESTATIC:
registry.registerInvokeStatic(method);
break;
case Opcodes.INVOKEINTERFACE:
registry.registerInvokeInterface(method);
break;
case Opcodes.INVOKESPECIAL:
if (name.equals(Constants.INSTANCE_INITIALIZER_NAME) || ownerType == clazz) {
registry.registerInvokeDirect(method);
} else {
registry.registerInvokeSuper(method);
}
break;
default:
throw new Unreachable("Unexpected opcode " + opcode);
}
}
示例3: invokeType
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());
}
}
示例4: visit
/**
* Output call instructions, outputing the correct opcode for the type of
* call.
*
* @param instruction Call instruction.
* @return <code>null</code>
*/
@Override
public Void visit(Call instruction) {
Method m = instruction.getMethod();
ClassNode c = m.getOwner();
int opcode;
switch(instruction.getSort()) {
case INTERFACE: opcode = Opcodes.INVOKEINTERFACE; break;
case VIRTUAL: opcode = Opcodes.INVOKEVIRTUAL; break;
case SPECIAL: opcode = Opcodes.INVOKESPECIAL; break;
case STATIC: opcode = Opcodes.INVOKESTATIC; break;
default: throw new RuntimeException("Unknown call type");
}
mv.visitMethodInsn(opcode, c.getName(), m.getName(), m.getDescriptor());
return null;
}
示例5: addWhereAmI
private void addWhereAmI() {
// 0: new #2; //class java/lang/Exception
// 3: dup
// 4: invokespecial #3; //Method java/lang/Exception."<init>":()V
// 7: invokevirtual #4; //Method
// java/lang/Exception.printStackTrace:()V
// 10: return
// super.visitTypeInsn(Opcodes.NEW, type);
String exClass = Type.getInternalName(Exception.class);
super.visitTypeInsn(Opcodes.NEW, exClass);
super.visitInsn(Opcodes.DUP);
super.visitMethodInsn(Opcodes.INVOKESPECIAL, exClass, "<init>",
"()V");
super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, exClass,
"printStackTrace", "()V");
}
示例6: doVisitMethodInsn
private void doVisitMethodInsn(int opcode, final String owner,
final String name, final String desc, final boolean itf) {
checkStartCode();
checkEndCode();
checkOpcode(opcode, 5);
if (opcode != Opcodes.INVOKESPECIAL || !"<init>".equals(name)) {
checkMethodIdentifier(version, name, "name");
}
checkInternalName(owner, "owner");
checkMethodDesc(desc);
if (opcode == Opcodes.INVOKEVIRTUAL && itf) {
throw new IllegalArgumentException(
"INVOKEVIRTUAL can't be used with interfaces");
}
if (opcode == Opcodes.INVOKEINTERFACE && !itf) {
throw new IllegalArgumentException(
"INVOKEINTERFACE can't be used with classes");
}
if (opcode == Opcodes.INVOKESPECIAL && itf
&& (version & 0xFFFF) < Opcodes.V1_8) {
throw new IllegalArgumentException(
"INVOKESPECIAL can't be used with interfaces prior to Java 8");
}
// Calling super.visitMethodInsn requires to call the correct version
// depending on this.api (otherwise infinite loops can occur). To
// simplify and to make it easier to automatically remove the backward
// compatibility code, we inline the code of the overridden method here.
if (mv != null) {
mv.visitMethodInsn(opcode, owner, name, desc, itf);
}
++insnCount;
}
示例7: CanvasHook
public CanvasHook() {
super(new Regex(
new Instruction(Opcodes.GOTO, false),
new Instruction(Opcodes.GETSTATIC, true),
new Instruction(Opcodes.CHECKCAST, false),
new Instruction(Opcodes.ALOAD, false),
new Instruction(Opcodes.GETFIELD, false),
new Instruction(Opcodes.LDC, false),
new Instruction(Opcodes.INVOKEVIRTUAL, true),
new Instruction(Opcodes.GOTO, false)
));
}
示例8: visitInsn
@Override
public void visitInsn(int opcode) {
if(opcode == Opcodes.RETURN) {
// Load this.
super.visitVarInsn(Opcodes.ALOAD, 0);
// Execute drill init.
super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, className, SignatureHolder.DRILL_INIT_METHOD, "()V", false);
}
super.visitInsn(opcode);
}
示例9: overclockRenderer
private static void overclockRenderer(ClassNode node, boolean isObfuscated)
{
// We're attempting to turn this line from Minecraft.runGameLoop:
// this.updateDisplay();
// into this:
// TimeHelper.updateDisplay();
// TimeHelper's method then decides whether or not to pass the call on to Minecraft.updateDisplay().
final String methodName = isObfuscated ? "as" : "runGameLoop";
final String methodDescriptor = "()V"; // No params, returns void.
System.out.println("MALMO: Found Minecraft, attempting to transform it");
for (MethodNode method : node.methods)
{
if (method.name.equals(methodName) && method.desc.equals(methodDescriptor))
{
System.out.println("MALMO: Found Minecraft.runGameLoop() method, attempting to transform it");
for (AbstractInsnNode instruction : method.instructions.toArray())
{
if (instruction.getOpcode() == Opcodes.INVOKEVIRTUAL)
{
MethodInsnNode visitMethodNode = (MethodInsnNode)instruction;
if (visitMethodNode.name.equals(isObfuscated ? "h" : "updateDisplay"))
{
visitMethodNode.owner = "com/microsoft/Malmo/Utils/TimeHelper";
if (isObfuscated)
{
visitMethodNode.name = "updateDisplay";
}
visitMethodNode.setOpcode(Opcodes.INVOKESTATIC);
method.instructions.remove(visitMethodNode.getPrevious()); // ALOAD 0 not needed for static invocation.
System.out.println("MALMO: Hooked into call to Minecraft.updateDisplay()");
}
}
}
}
}
}
示例10: visitMethodInsn
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
if (opcode == Opcodes.INVOKEVIRTUAL &&
JAVA_LANG_OBJECT.equals(owner) &&
NOTIFY_SIGNATURE.equals(desc) &&
(NOTIFY_METHOD.equals(name) || NOTIFY_ALL_METHOD.equals(name))) {
super.dup();
super.visitMethodInsn(Opcodes.INVOKESTATIC, className, LOG_INTERNAL_NOTIFY_METHOD, LOG_OBJECT_SIGNATURE);
}
super.visitMethodInsn(opcode, owner, name, desc);
}
示例11: visitMethodInsn
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc,
boolean itf) {
Type receiver = Type.getObjectType(owner);
if (incompatibleChange != InstantRunVerifierStatus.INCOMPATIBLE) {
if (opcode == Opcodes.INVOKEVIRTUAL && blackListedMethods.containsKey(receiver)) {
for (Method method : blackListedMethods.get(receiver)) {
if (method.getName().equals(name) && method.getDescriptor().equals(desc)) {
incompatibleChange = InstantRunVerifierStatus.INCOMPATIBLE;
}
}
}
}
super.visitMethodInsn(opcode, owner, name, desc, itf);
}
示例12: canThrow
private boolean canThrow(AbstractInsnNode insn) {
switch (insn.getOpcode()) {
case Opcodes.AALOAD:
case Opcodes.AASTORE:
case Opcodes.ANEWARRAY:
// ARETURN does not throw in its dex image.
case Opcodes.ARRAYLENGTH:
case Opcodes.ATHROW:
case Opcodes.BALOAD:
case Opcodes.BASTORE:
case Opcodes.CALOAD:
case Opcodes.CASTORE:
case Opcodes.CHECKCAST:
case Opcodes.DALOAD:
case Opcodes.DASTORE:
// DRETURN does not throw in its dex image.
case Opcodes.FALOAD:
case Opcodes.FASTORE:
// FRETURN does not throw in its dex image.
case Opcodes.GETFIELD:
case Opcodes.GETSTATIC:
case Opcodes.IALOAD:
case Opcodes.IASTORE:
case Opcodes.IDIV:
case Opcodes.INSTANCEOF:
case Opcodes.INVOKEDYNAMIC:
case Opcodes.INVOKEINTERFACE:
case Opcodes.INVOKESPECIAL:
case Opcodes.INVOKESTATIC:
case Opcodes.INVOKEVIRTUAL:
case Opcodes.IREM:
// IRETURN does not throw in its dex image.
case Opcodes.LALOAD:
case Opcodes.LASTORE:
case Opcodes.LDIV:
case Opcodes.LREM:
// LRETURN does not throw in its dex image.
case Opcodes.MONITORENTER:
case Opcodes.MONITOREXIT:
case Opcodes.MULTIANEWARRAY:
case Opcodes.NEW:
case Opcodes.NEWARRAY:
case Opcodes.PUTFIELD:
case Opcodes.PUTSTATIC:
// RETURN does not throw in its dex image.
case Opcodes.SALOAD:
case Opcodes.SASTORE:
return true;
case Opcodes.LDC: {
// const-class and const-string* may throw in dex.
LdcInsnNode ldc = (LdcInsnNode) insn;
return ldc.cst instanceof String || ldc.cst instanceof Type;
}
default:
return false;
}
}
示例13: InvokeVirtualInstruction
public InvokeVirtualInstruction(String methodSignature, boolean capture) {
super(Opcodes.INVOKEVIRTUAL, capture);
this.methodSignature = methodSignature;
}