List of usage examples for org.objectweb.asm Opcodes INVOKESTATIC
int INVOKESTATIC
To view the source code for org.objectweb.asm Opcodes INVOKESTATIC.
Click Source Link
From source file:org.coldswap.util.AutoBoxing.java
License:Open Source License
private static InsnList boxLong() { InsnList il = new InsnList(); il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;")); return il;/*from w ww. j a v a2 s . c o m*/ }
From source file:org.coldswap.util.AutoBoxing.java
License:Open Source License
private static InsnList boxFloat() { InsnList il = new InsnList(); il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;")); return il;// w w w. j a v a 2 s . co m }
From source file:org.coldswap.util.AutoBoxing.java
License:Open Source License
private static InsnList boxDouble() { InsnList il = new InsnList(); il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;")); return il;/*w ww . j a va2s . co m*/ }
From source file:org.compass.core.util.reflection.asm.AsmReflectionFieldGenerator.java
License:Apache License
private static void boxIfNeeded(MethodVisitor mv, Field field) { if (!field.getType().isPrimitive()) return;/*from w ww. j a v a 2 s .c om*/ Type type = Type.getType(field.getType()); switch (type.getSort()) { case Type.BOOLEAN: mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;"); break; case Type.INT: mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;"); break; case Type.SHORT: mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;"); break; case Type.LONG: mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;"); break; case Type.FLOAT: mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;"); break; case Type.DOUBLE: mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;"); break; case Type.BYTE: mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;"); break; case Type.CHAR: mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;"); break; } }
From source file:org.compass.core.util.reflection.asm.AsmReflectionMethodGenerator.java
License:Apache License
/** * Creates the method invoking wrapper method. *///from w w w . j a va2 s.c o m private static void createMethod(Class clazz, String name, Method refMethod, ClassWriter cw, String methodName, String desc, boolean argsParams, boolean returnValue, Class... parameterTypes) { MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_VARARGS, methodName, desc, null, null); boolean isStatic = Modifier.isStatic(refMethod.getModifiers()); boolean isInteface = Modifier.isInterface(refMethod.getDeclaringClass().getModifiers()); final int invokeCode; if (isStatic) { invokeCode = Opcodes.INVOKESTATIC; } else { invokeCode = isInteface ? Opcodes.INVOKEINTERFACE : Opcodes.INVOKEVIRTUAL; mv.visitVarInsn(Opcodes.ALOAD, 1); mv.visitTypeInsn(Opcodes.CHECKCAST, Type.getInternalName(clazz)); } if (argsParams) { for (int i = 0; i < parameterTypes.length; ++i) { mv.visitVarInsn(Opcodes.ALOAD, 2); mv.visitIntInsn(Opcodes.BIPUSH, i); mv.visitInsn(Opcodes.AALOAD); prepareParameter(mv, Type.getType(parameterTypes[i])); } } else { for (int i = 0; i < parameterTypes.length; ++i) { mv.visitVarInsn(Opcodes.ALOAD, i + 2); prepareParameter(mv, Type.getType(parameterTypes[i])); } } mv.visitMethodInsn(invokeCode, Type.getInternalName(clazz), name, Type.getMethodDescriptor(refMethod)); if (returnValue) { prepareResult(mv, refMethod); mv.visitInsn(Opcodes.ARETURN); } else { mv.visitInsn(Opcodes.RETURN); } mv.visitMaxs(1, 1); // ignored since ClassWriter set as ClassWriter.COMPUTE_MAXS mv.visitEnd(); }
From source file:org.compass.core.util.reflection.asm.AsmReflectionMethodGenerator.java
License:Apache License
private static void callBoxer(MethodVisitor mv, String desc) { mv.visitMethodInsn(Opcodes.INVOKESTATIC, Boxer.INTERNAL_NAME, "box", desc); }
From source file:org.decojer.cavaj.readers.asm.ReadMethodVisitor.java
License:Open Source License
@Override public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc, final boolean itf) { if (owner == null || name == null || desc == null) { log.warn(getM() + ": Cannot read invoke operation with method name '" + owner + "." + name + "' and descriptor '" + desc + "'!"); return;/*from w w w. j a v a2 s . c o m*/ } switch (opcode) { /********** * INVOKE * **********/ case Opcodes.INVOKEINTERFACE: case Opcodes.INVOKESPECIAL: // Constructor or supermethod (any super) or private method callout. case Opcodes.INVOKESTATIC: case Opcodes.INVOKEVIRTUAL: { final T ownerT = getDu().getT(owner); if (opcode == Opcodes.INVOKEINTERFACE) { ownerT.setInterface(true); // static also possible in interface since JVM 8 } assert opcode != Opcodes.INVOKEINTERFACE || itf; final M refM = ownerT.getM(name, desc); refM.setStatic(opcode == Opcodes.INVOKESTATIC); add(new INVOKE(this.ops.size(), opcode, this.line, refM, opcode == Opcodes.INVOKESPECIAL)); break; } default: log.warn(getM() + ": Unknown method insn opcode '" + opcode + "'!"); } }
From source file:org.devinprogress.YAIF.Transformer.ASMHelper.java
public static void InsertInvokeStaticAfter(MethodNode mn, AbstractInsnNode n, String targetClass, String targetMethod, String desc) { mn.instructions.insert(n,// ww w. j a v a 2 s . c o m new MethodInsnNode(Opcodes.INVOKESTATIC, targetClass.replace('.', '/'), targetMethod, desc, false)); }
From source file:org.devinprogress.YAIF.Transformer.ASMTransformer.java
public static void insertWrapperStartup(MethodNode mn) { //Add TextField Wrapper //org.devinprogress.YAIF.YetAnotherInputFix.SetupTextFieldWrapper(this.displayWidth, this.displayHeight); //before ForgeHooksClient.createDisplay(); //At method startGame() ()V //ALOAD 0/* w w w . ja v a 2s .c o m*/ //GETFIELD net/minecraft/client/Minecraft.displayWidth : I //ALOAD 0 //GETFIELD net/minecraft/client/Minecraft.displayHeight : I //INVOKESTATIC org/devinprogress/YAIF/YetAnotherInputFix.SetupTextFieldWrapper (II)V //Be careful of the Exception Labels!!! //Insert before INVOKESTATIC net/minecraftforge/client/ForgeHooksClient.createDisplay ()V //10th INVOKESTATIC AbstractInsnNode n = ASMHelper.getNthInsnNode(mn, Opcodes.INVOKESTATIC, 10); String WidthName = YetAnotherInputFix.ObfuscatedEnv ? "d" : "displayWidth"; String HeightName = YetAnotherInputFix.ObfuscatedEnv ? "e" : "displayHeight"; if (!((MethodInsnNode) n).desc.equals("()V")) {//Here must be something wrong! System.out.println(new String("tryTransformMinecraft() Error, landmark desc not match.")); return; } mn.instructions.insertBefore(n, new VarInsnNode(Opcodes.ALOAD, 0)); mn.instructions.insertBefore(n, new FieldInsnNode(Opcodes.GETFIELD, obfedClassName.replace('.', '/'), WidthName, "I")); mn.instructions.insertBefore(n, new VarInsnNode(Opcodes.ALOAD, 0)); mn.instructions.insertBefore(n, new FieldInsnNode(Opcodes.GETFIELD, obfedClassName.replace('.', '/'), HeightName, "I")); mn.instructions.insertBefore(n, new MethodInsnNode(Opcodes.INVOKESTATIC, "org/devinprogress/YAIF/YetAnotherInputFix", "SetupTextFieldWrapper", "(II)V", false)); // Codes are braced by existed TryCatchBlock mn.maxStack += 1; }
From source file:org.devinprogress.YAIF.Transformer.ASMTransformer.java
public static void hookGuiTextFocusChange(MethodNode mn) { //Hook to GuiTextField onFocusChange //org.devinprogress.YAIF.YetAnotherInputFix.TextFieldFocusChange(this, p_146195_1_); //At the beginning/ending of setFocused (Z)V //ALOAD 0//from w ww . j a v a 2 s . c o m //ILOAD 1 //INVOKESTATIC org/devinprogress/YAIF/YetAnotherInputFix.TextFieldFocusChange // (Lnet/minecraft/client/gui/GuiTextField;Z)V for for version 1.7.2 //Remember to use the obfuscated name for Lnet/minecraft/client/gui/GuiTextField; AbstractInsnNode n = mn.instructions.getFirst(); mn.instructions.insertBefore(n, new VarInsnNode(Opcodes.ALOAD, 0)); mn.instructions.insertBefore(n, new VarInsnNode(Opcodes.ILOAD, 1)); mn.instructions.insertBefore(n, new MethodInsnNode(Opcodes.INVOKESTATIC, "org/devinprogress/YAIF/YetAnotherInputFix", "TextFieldFocusChange", "(L" + obfedClassName.replace('.', '/') + ";Z)V", false)); }