本文整理匯總了Java中org.objectweb.asm.commons.GeneratorAdapter.arrayStore方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneratorAdapter.arrayStore方法的具體用法?Java GeneratorAdapter.arrayStore怎麽用?Java GeneratorAdapter.arrayStore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.objectweb.asm.commons.GeneratorAdapter
的用法示例。
在下文中一共展示了GeneratorAdapter.arrayStore方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createClassArray
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
private static void createClassArray(GeneratorAdapter mv, List<Type> args) {
// create an array of objects capable of containing all the parameters and optionally the "this"
createLocals(mv, args);
// we need to maintain the stack index when loading parameters from, as for long and double
// values, it uses 2 stack elements, all others use only 1 stack element.
int stackIndex = 0;
for (int arrayIndex = 0; arrayIndex < args.size(); arrayIndex++) {
Type arg = args.get(arrayIndex);
// duplicate the array of objects reference, it will be used to store the value in.
mv.dup();
// index in the array of objects to store the boxed parameter.
mv.push(arrayIndex);
// Pushes the appropriate local variable on the stack
redirectLocal(mv, arg);
// mv.visitLdcInsn(Type.getType(arg.getDescriptor()));
// potentially box up intrinsic types.
// mv.box(arg);
mv.arrayStore(Type.getType(Class.class));
// stack index must progress according to the parameter type we just processed.
// stackIndex += arg.getSize();
}
}
示例2: loadVariableArray
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
* Given an array on the stack, it loads it with the values of the given variables stating at
* offset.
*/
static void loadVariableArray(
GeneratorAdapter mv,
List<LocalVariable> variables, int offset) {
// we need to maintain the stack index when loading parameters from, as for long and double
// values, it uses 2 stack elements, all others use only 1 stack element.
for (int i = offset; i < variables.size(); i++) {
LocalVariable variable = variables.get(i);
// duplicate the array of objects reference, it will be used to store the value in.
mv.dup();
// index in the array of objects to store the boxed parameter.
mv.push(i);
// Pushes the appropriate local variable on the stack
mv.visitVarInsn(variable.type.getOpcode(Opcodes.ILOAD), variable.var);
// potentially box up intrinsic types.
mv.box(variable.type);
// store it in the array
mv.arrayStore(Type.getType(Object.class));
}
}
示例3: writeMissingMessageWithHash
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
void writeMissingMessageWithHash(GeneratorAdapter mv, String visitedClassName) {
mv.newInstance(INSTANT_RELOAD_EXCEPTION_TYPE);
mv.dup();
mv.push("int switch could not find %d in %s");
mv.push(3);
mv.newArray(OBJECT_TYPE);
mv.dup();
mv.push(0);
visitInt();
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();
}
示例4: redirect
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
* Adds the instructions to do a generic redirection.
* <p/>
* Note that the generated bytecode does not have a direct translation to code, but as an
* example, the following code block gets inserted.
* <code>
* if ($change != null) {
* $change.access$dispatch($name, new object[] { arg0, ... argsN })
* $anyCodeInsertedbyRestore
* }
* $originalMethodBody
* </code>
*
* @param mv the method visitor to add the instructions to.
* @param change the local variable containing the alternate implementation.
* @param args the type of the local variable that need to be forwarded.
*/
void redirect(GeneratorAdapter mv, int change, List<Type> args) {
// code to check if a new implementation of the current class is available.
Label l0 = new Label();
mv.loadLocal(change);
mv.visitJumpInsn(Opcodes.IFNULL, l0);
mv.loadLocal(change);
mv.push(name);
// create an array of objects capable of containing all the parameters and optionally the "this"
createLocals(mv, args);
// we need to maintain the stack index when loading parameters from, as for long and double
// values, it uses 2 stack elements, all others use only 1 stack element.
int stackIndex = 0;
for (int arrayIndex = 0; arrayIndex < args.size(); arrayIndex++) {
Type arg = args.get(arrayIndex);
// duplicate the array of objects reference, it will be used to store the value in.
mv.dup();
// index in the array of objects to store the boxed parameter.
mv.push(arrayIndex);
// Pushes the appropriate local variable on the stack
redirectLocal(mv, stackIndex, arg);
// potentially box up intrinsic types.
mv.box(arg);
mv.arrayStore(Type.getType(Object.class));
// stack index must progress according to the parameter type we just processed.
stackIndex += arg.getSize();
}
// now invoke the generic dispatch method.
mv.invokeInterface(IncrementalVisitor.CHANGE_TYPE, Method.getMethod("Object access$dispatch(String, Object[])"));
// Restore the state after the redirection
restore(mv, args);
// jump label for classes without any new implementation, just invoke the original
// method implementation.
mv.visitLabel(l0);
}
示例5: writeMissingMessageWithHash
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
* 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
*
* @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();
}
示例6: emitArgsAsArray
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
static void emitArgsAsArray(IPersistentVector args, ObjExpr objx, GeneratorAdapter gen){
gen.push(args.count());
gen.newArray(OBJECT_TYPE);
for(int i = 0; i < args.count(); i++)
{
gen.dup();
gen.push(i);
((Expr) args.nth(i)).emit(C.EXPRESSION, objx, gen);
gen.arrayStore(OBJECT_TYPE);
}
}
示例7: emitListAsObjectArray
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
void emitListAsObjectArray(Object value, GeneratorAdapter gen){
gen.push(((List) value).size());
gen.newArray(OBJECT_TYPE);
int i = 0;
for(Iterator it = ((List) value).iterator(); it.hasNext(); i++)
{
gen.dup();
gen.push(i);
emitValue(it.next(), gen);
gen.arrayStore(OBJECT_TYPE);
}
}
示例8: transform
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Override
@Unsafe(Unsafe.ASM_API)
public byte[] transform(String name, String transformedName, byte[] basicClass) {
String srgName = this.srgName;
if (!AlchemyEngine.isRuntimeDeobfuscationEnabled())
srgName = DeobfuscatingRemapper.instance().mapMethodName(transformedName, this.srgName, desc);
AlchemyTransformerManager.transform("<proxy>" + name + "|" + transformedName + "#" + proxyMethod.name + proxyMethod.signature
+ "\n-> " + target + "#" + srgName + desc);
ClassReader reader = new ClassReader(basicClass);
ClassWriter writer = ASMHelper.newClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
ClassNode node = new ClassNode(ASM5);
reader.accept(node, 0);
MethodNode oldMethod = null, newMethod = new MethodNode(proxyMethod.access, proxyMethod.name, proxyMethod.desc, proxyMethod.signature,
proxyMethod.exceptions.toArray(new String[proxyMethod.exceptions.size()]));
for (MethodNode method : node.methods)
if (method.name.equals(proxyMethod.name) && method.desc.equals(proxyMethod.desc)) {
oldMethod = method;
GeneratorAdapter adapter = new GeneratorAdapter(newMethod, method.access, method.name, method.desc);
Type owner = Type.getType(ASMHelper.getClassDesc(target));
Method targetMethod = new Method(srgName, desc);
switch (opcode) {
case INVOKESTATIC:
adapter.loadArgs();
adapter.invokeStatic(owner, targetMethod);
break;
case INVOKEVIRTUAL:
adapter.loadArgs();
adapter.invokeVirtual(owner, targetMethod);
break;
case INVOKESPECIAL:
adapter.invokeStatic(Type.getType(AlchemyEngine.class), new Method("lookup",
"()Ljava/lang/invoke/MethodHandles$Lookup;"));
adapter.push(srgName);
Type args[] = Type.getArgumentTypes(desc);
adapter.visitFieldInsn(GETSTATIC, "java/lang/Void", "TYPE", "Ljava/lang/Class;");
adapter.push(args.length);
adapter.newArray(Type.getType(Class.class));
for (Type arg : args) {
adapter.dup();
adapter.push(arg);
adapter.arrayStore(Type.getType(Class.class));
}
adapter.invokeStatic(Type.getType(MethodType.class), new Method("methodType",
"(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/invoke/MethodType;"));
adapter.push(owner);
adapter.dupX2();
adapter.invokeVirtual(Type.getType(MethodHandles.Lookup.class), new Method("findSpecial",
"(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/Class;)Ljava/lang/invoke/MethodHandle;"));
adapter.loadArgs();
adapter.invokeVirtual(Type.getType(MethodHandle.class), new Method("invoke", proxyMethod.desc));
break;
case INVOKEINTERFACE:
adapter.loadArgs();
adapter.invokeInterface(owner, targetMethod);
break;
default:
AlchemyRuntimeException.onException(new RuntimeException("Unsupported opcode: " + opcode));
}
adapter.returnValue();
adapter.endMethod();
break;
}
node.methods.remove(oldMethod);
node.methods.add(newMethod);
node.accept(writer);
return writer.toByteArray();
}