本文整理匯總了Java中org.objectweb.asm.commons.GeneratorAdapter.newArray方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneratorAdapter.newArray方法的具體用法?Java GeneratorAdapter.newArray怎麽用?Java GeneratorAdapter.newArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.objectweb.asm.commons.GeneratorAdapter
的用法示例。
在下文中一共展示了GeneratorAdapter.newArray方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
示例2: newVariableArray
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
* Pushes an array on the stack that contains the value of all the given variables.
*/
static void newVariableArray(
GeneratorAdapter mv,
List<LocalVariable> variables) {
mv.push(variables.size());
mv.newArray(Type.getType(Object.class));
loadVariableArray(mv, variables, 0);
}
示例3: 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();
}
示例4: 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);
}
}
示例5: 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);
}
}
示例6: createLocals
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
* Creates and pushes to the stack the array to hold all the parameters to redirect, and
* optionally this.
*/
protected static void createLocals(GeneratorAdapter mv, List<Type> args) {
mv.push(args.size());
mv.newArray(Type.getType(Class.class));
}
示例7: createLocals
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
* Creates and pushes to the stack the array to hold all the parameters to redirect, and
* optionally this.
*/
protected void createLocals(GeneratorAdapter mv, List<Type> args) {
mv.push(args.size());
mv.newArray(Type.getType(Object.class));
}
示例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();
}