List of usage examples for org.objectweb.asm.commons Method getMethod
public static Method getMethod(final String method)
From source file:com.android.build.gradle.internal.incremental.IncrementalVisitor.java
License:Apache License
protected static void trace(@NonNull GeneratorAdapter mv, @Nullable String s) { mv.push(s);/* ww w. j a va 2 s . c om*/ mv.invokeStatic(Type.getObjectType(RUNTIME_PACKAGE + "/AndroidInstantRuntime"), Method.getMethod("void trace(String)")); }
From source file:com.android.build.gradle.internal.incremental.IncrementalVisitor.java
License:Apache License
@SuppressWarnings("unused") protected static void trace(@NonNull GeneratorAdapter mv, @Nullable String s1, @Nullable String s2) { mv.push(s1);/*from w w w . j a va 2s . c o m*/ mv.push(s2); mv.invokeStatic(Type.getObjectType(RUNTIME_PACKAGE + "/AndroidInstantRuntime"), Method.getMethod("void trace(String, String)")); }
From source file:com.android.build.gradle.internal.incremental.IncrementalVisitor.java
License:Apache License
@SuppressWarnings("unused") protected static void trace(@NonNull GeneratorAdapter mv, @Nullable String s1, @Nullable String s2, @Nullable String s3) {//from w w w . j av a 2s . com mv.push(s1); mv.push(s2); mv.push(s3); mv.invokeStatic(Type.getObjectType(RUNTIME_PACKAGE + "/AndroidInstantRuntime"), Method.getMethod("void trace(String, String, String)")); }
From source file:com.android.build.gradle.internal.incremental.IncrementalVisitor.java
License:Apache License
protected static void trace(@NonNull GeneratorAdapter mv, @Nullable String s1, @Nullable String s2, @Nullable String s3, @Nullable String s4) { mv.push(s1);/*from w w w . java2 s . co m*/ mv.push(s2); mv.push(s3); mv.push(s4); mv.invokeStatic(Type.getObjectType(RUNTIME_PACKAGE + "/AndroidInstantRuntime"), Method.getMethod("void trace(String, String, String, String)")); }
From source file:com.android.build.gradle.internal.incremental.IncrementalVisitor.java
License:Apache License
protected static void trace(@NonNull GeneratorAdapter mv, int argsNumber) { StringBuilder methodSignature = new StringBuilder("void trace(String"); for (int i = 0; i < argsNumber - 1; i++) { methodSignature.append(", String"); }/*from w ww . j a va2 s .c o m*/ methodSignature.append(")"); mv.invokeStatic(Type.getObjectType(RUNTIME_PACKAGE + "/AndroidInstantRuntime"), Method.getMethod(methodSignature.toString())); }
From source file:com.android.build.gradle.internal.incremental.MethodRedirection.java
License:Apache License
@Override protected void doRedirect(@NonNull GeneratorAdapter mv, int change) { // Push the three arguments mv.loadLocal(change);/* www .jav a 2s . c o m*/ mv.push(name); ByteCodeUtils.newVariableArray(mv, ByteCodeUtils.toLocalVariables(types)); // now invoke the generic dispatch method. mv.invokeInterface(IncrementalVisitor.CHANGE_TYPE, Method.getMethod("Object access$dispatch(String, Object[])")); }
From source file:com.android.build.gradle.internal.incremental.StringSwitch.java
License:Apache License
void visitHashMethod(GeneratorAdapter mv) { mv.invokeVirtual(STRING_TYPE, Method.getMethod("int hashCode()")); }
From source file:com.android.build.gradle.internal.incremental.StringSwitch.java
License:Apache License
/** * Emit code for a string if-else block. * * if (s.equals("collided_method1")) { * visit(s);/*from w ww . ja v a 2 s . c om*/ * } else if (s.equals("collided_method2")) { * visit(s); * } * * In the most common case of just one string, this degenerates to: * * visit(s) * */ private void visitx(GeneratorAdapter mv, List<String> strings) { if (strings.size() == 1) { visitCase(strings.get(0)); return; } for (String string : strings) { Label label = new Label(); visitString(); mv.visitLdcInsn(string); mv.invokeVirtual(STRING_TYPE, Method.getMethod("boolean equals(Object)")); mv.visitJumpInsn(Opcodes.IFEQ, label); visitCase(string); mv.visitLabel(label); } visitDefault(); }
From source file:com.android.build.gradle.internal.incremental.StringSwitch.java
License:Apache License
/** * Generates a standard error exception with message similar to: * * String switch could not find 'equals.(Ljava/lang/Object;)Z' with hashcode 0 * in com/example/basic/GrandChild//from w ww. ja v a 2 s.co m * * @param mv The generator adaptor used to emit the lookup switch code. * @param visitedClassName The abstract string trie structure. */ void writeMissingMessageWithHash(GeneratorAdapter mv, String visitedClassName) { mv.newInstance(INSTANT_RELOAD_EXCEPTION_TYPE); mv.dup(); mv.push("String switch could not find '%s' with hashcode %s in %s"); mv.push(3); mv.newArray(OBJECT_TYPE); mv.dup(); mv.push(0); visitString(); mv.arrayStore(OBJECT_TYPE); mv.dup(); mv.push(1); visitString(); visitHashMethod(mv); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false); mv.arrayStore(OBJECT_TYPE); mv.dup(); mv.push(2); mv.push(visitedClassName); mv.arrayStore(OBJECT_TYPE); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/String", "format", "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;", false); mv.invokeConstructor(INSTANT_RELOAD_EXCEPTION_TYPE, Method.getMethod("void <init> (String)")); mv.throwException(); }
From source file:com.android.build.gradle.internal2.incremental.ConstructorRedirection.java
License:Apache License
@Override protected void doRedirect(GeneratorAdapter mv, int change) { mv.loadLocal(change);/*from ww w . j a v a 2 s . c o m*/ mv.push("init$args." + constructor.args.desc); Type arrayType = Type.getType("[Ljava/lang/Object;"); // init$args args (including this) + locals mv.push(types.size() + 1); mv.newArray(Type.getType(Object.class)); int array = mv.newLocal(arrayType); mv.dup(); mv.storeLocal(array); // "this" is not ready yet, use null instead. mv.dup(); mv.push(0); mv.visitInsn(Opcodes.ACONST_NULL); mv.arrayStore(Type.getType(Object.class)); // Set the arguments in positions 1..(n-1); ByteCodeUtils.loadVariableArray(mv, ByteCodeUtils.toLocalVariables(types), 1); // Skip the this value // Add the locals array at the last position. mv.dup(); // The index of the last position of the array. mv.push(types.size()); // Create the array with all the local variables declared up to this point. ByteCodeUtils.newVariableArray(mv, constructor.variables.subList(0, constructor.localsAtLoadThis)); mv.arrayStore(Type.getType(Object.class)); mv.invokeInterface(IncrementalVisitor.CHANGE_TYPE, Method.getMethod("Object access$dispatch(String, Object[])")); mv.visitTypeInsn(Opcodes.CHECKCAST, "[Ljava/lang/Object;"); //// At this point, init$args has been called and the result Object is on the stack. //// The value of that Object is Object[] with exactly n + 2 elements. //// The first element is the resulting local variables //// The second element is a string with the qualified name of the constructor to call. //// The remaining elements are the constructor arguments. // Keep a reference to the new locals array mv.dup(); mv.push(0); mv.arrayLoad(Type.getType("[Ljava/lang/Object;")); mv.visitTypeInsn(Opcodes.CHECKCAST, "[Ljava/lang/Object;"); mv.storeLocal(array); // Call super constructor // Put this behind the returned array mv.visitVarInsn(Opcodes.ALOAD, 0); mv.swap(); // Push a null for the marker parameter. mv.visitInsn(Opcodes.ACONST_NULL); // Invoke the constructor mv.visitMethodInsn(Opcodes.INVOKESPECIAL, constructor.owner, ByteCodeUtils.CONSTRUCTOR, DISPATCHING_THIS_SIGNATURE, false); // { // // FIXME: Opcodes.INVOKESPECIAL??????this?,????? // mv.visitVarInsn(Opcodes.ALOAD, 0); // // List<LocalVariable> variables = ByteCodeUtils.toLocalVariables(types); // for (int i = 1; i < variables.size(); i++) { // LocalVariable variable = variables.get(i); // // Duplicates the array on the stack; // mv.loadLocal(array); // // Sets up the index // mv.push(i + 1); // // Gets the Object value // mv.arrayLoad(Type.getType(Object.class)); // mv.unbox(variable.type); // } // mv.visitMethodInsn(Opcodes.INVOKESPECIAL, constructor.owner, ByteCodeUtils.CONSTRUCTOR, constructor.originConstructor.desc, false); // } // Dispatch to init$body mv.loadLocal(change); mv.push("init$body." + constructor.body.desc); mv.loadLocal(array); // Now "this" can be set mv.dup(); mv.push(0); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.arrayStore(Type.getType(Object.class)); mv.invokeInterface(IncrementalVisitor.CHANGE_TYPE, Method.getMethod("Object access$dispatch(String, Object[])")); mv.pop(); }