本文整理匯總了Java中org.objectweb.asm.commons.GeneratorAdapter.invokeStatic方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneratorAdapter.invokeStatic方法的具體用法?Java GeneratorAdapter.invokeStatic怎麽用?Java GeneratorAdapter.invokeStatic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.objectweb.asm.commons.GeneratorAdapter
的用法示例。
在下文中一共展示了GeneratorAdapter.invokeStatic方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visitEnd
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void visitEnd() {
if (!done && found) {
done = true;
try {
GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC, new Method(LOG_INTERNAL_METHOD, LOG_METHOD_SIGNATURE), LOG_METHOD_SIGNATURE, new Type[] {}, this);
Label start = mg.mark();
mg.invokeStatic(LOG_INTERNAL_TYPE, Method.getMethod(LOG_INTERNAL_CLASS.getMethod(LOG_METHOD_NAME)));
mg.returnValue();
Label end = mg.mark();
mg.catchException(start, end, JAVA_LANG_THROWABLE_TYPE);
mg.returnValue();
mg.endMethod();
} catch (NoSuchMethodException nsme) {
System.err.println("Unable to find Agent.rlogCallChain method");
System.err.println("M:"+nsme);
nsme.printStackTrace();
}
}
super.visitEnd();
}
示例2: visitEnd
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void visitEnd() {
if (!foundClinit && instrument()) {
// didn't find <clinit> so lets make one
try {
GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, new Method(CLINIT_NAME, CLINIT_SIGNATURE), CLINIT_SIGNATURE, new Type[] {}, this);
Label start = mg.mark();
mg.push(className);
mg.invokeStatic(LOG_INTERNAL_TYPE, Method.getMethod(LOG_INTERNAL_CLASS.getMethod(LOG_METHOD_NAME, String.class)));
Label end = mg.mark();
mg.returnValue();
mg.catchException(start, end, JAVA_LANG_THROWABLE_TYPE);
mg.returnValue();
mg.endMethod();
} catch (NoSuchMethodException nsme) {
System.out.println("Unable to find Agent.reportClass method");
}
}
super.visitEnd();
}
示例3: establishCallback
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public static void establishCallback(ClassNode cn, MethodNode mn) {
if (!mn.desc.startsWith("()")) {
MethodNode blank = new MethodNode();
Method method = new Method(mn.name, mn.desc);
GeneratorAdapter adapter = new GeneratorAdapter(mn.access, method, blank);
adapter.visitCode();
adapter.push(cn.name + "." + mn.name + " " + mn.desc);
adapter.loadArgArray();
adapter.invokeStatic(Type.getType(CallFactory.class), new Method("testInvoke",
"(Ljava/lang/String;[Ljava/lang/Object;)V"));
for (AbstractInsnNode ain : mn.instructions.toArray()) {
if (ain instanceof VarInsnNode) {
mn.instructions.insertBefore(ain, blank.instructions);
return;
}
}
}
}
示例4: emit
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
if(targetClass != null && field != null)
{
target.emit(C.EXPRESSION, objx, gen);
gen.visitLineNumber(line, gen.mark());
gen.checkCast(getType(targetClass));
gen.getField(getType(targetClass), fieldName, Type.getType(field.getType()));
//if(context != C.STATEMENT)
HostExpr.emitBoxReturn(objx, gen, field.getType());
if(context == C.STATEMENT)
{
gen.pop();
}
}
else
{
target.emit(C.EXPRESSION, objx, gen);
gen.visitLineNumber(line, gen.mark());
gen.push(fieldName);
gen.push(requireField);
gen.invokeStatic(REFLECTOR_TYPE, invokeNoArgInstanceMember);
if(context == C.STATEMENT)
gen.pop();
}
}
示例5: emitAssign
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitAssign(C context, ObjExpr objx, GeneratorAdapter gen,
Expr val){
if(targetClass != null && field != null)
{
target.emit(C.EXPRESSION, objx, gen);
gen.checkCast(getType(targetClass));
val.emit(C.EXPRESSION, objx, gen);
gen.visitLineNumber(line, gen.mark());
gen.dupX1();
HostExpr.emitUnboxArg(objx, gen, field.getType());
gen.putField(getType(targetClass), fieldName, Type.getType(field.getType()));
}
else
{
target.emit(C.EXPRESSION, objx, gen);
gen.push(fieldName);
val.emit(C.EXPRESSION, objx, gen);
gen.visitLineNumber(line, gen.mark());
gen.invokeStatic(REFLECTOR_TYPE, setInstanceFieldMethod);
}
if(context == C.STATEMENT)
gen.pop();
}
示例6: emit
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
boolean allKeysConstant = true;
boolean allConstantKeysUnique = true;
IPersistentSet constantKeys = PersistentHashSet.EMPTY;
for(int i = 0; i < keyvals.count(); i+=2)
{
Expr k = (Expr) keyvals.nth(i);
if(k instanceof LiteralExpr)
{
Object kval = k.eval();
if (constantKeys.contains(kval))
allConstantKeysUnique = false;
else
constantKeys = (IPersistentSet)constantKeys.cons(kval);
}
else
allKeysConstant = false;
}
MethodExpr.emitArgsAsArray(keyvals, objx, gen);
if((allKeysConstant && allConstantKeysUnique) || (keyvals.count() <= 2))
gen.invokeStatic(RT_TYPE, mapUniqueKeysMethod);
else
gen.invokeStatic(RT_TYPE, mapMethod);
if(context == C.STATEMENT)
gen.pop();
}
示例7: emitUnboxed
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen){
Method ms = new Method("invokeStatic", getReturnType(), paramtypes);
if(variadic)
{
for(int i = 0; i < paramclasses.length - 1; i++)
{
Expr e = (Expr) args.nth(i);
if(maybePrimitiveType(e) == paramclasses[i])
{
((MaybePrimitiveExpr) e).emitUnboxed(C.EXPRESSION, objx, gen);
}
else
{
e.emit(C.EXPRESSION, objx, gen);
HostExpr.emitUnboxArg(objx, gen, paramclasses[i]);
}
}
IPersistentVector restArgs = RT.subvec(args,paramclasses.length - 1,args.count());
MethodExpr.emitArgsAsArray(restArgs,objx,gen);
gen.invokeStatic(Type.getType(ArraySeq.class), Method.getMethod("clojure.lang.ArraySeq create(Object[])"));
}
else
MethodExpr.emitTypedArgs(objx, gen, paramclasses, args);
gen.invokeStatic(target, ms);
}
示例8: trace
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
protected static void trace( GeneratorAdapter mv, int argsNumber) {
StringBuilder methodSignature = new StringBuilder("void trace(String");
for (int i = 0; i < argsNumber - 1; i++) {
methodSignature.append(", String");
}
methodSignature.append(")");
mv.invokeStatic(Type.getObjectType(PACKAGE + "/AndroidInstantRuntime"),
Method.getMethod(methodSignature.toString()));
}
示例9: trace
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
protected static void trace(GeneratorAdapter mv, String s1,
String s2, String s3) {
mv.push(s1);
mv.push(s2);
mv.push(s3);
mv.invokeStatic(Type.getType(PACKAGE + ".AndroidInstantRuntime"),
Method.getMethod("void trace(String, String, String)"));
}
示例10: emitThenForHashes
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
private void emitThenForHashes(ObjExpr objx, GeneratorAdapter gen, Expr test, Expr then, Label defaultLabel, boolean emitUnboxed){
expr.emit(C.EXPRESSION, objx, gen);
test.emit(C.EXPRESSION, objx, gen);
if(testType == hashIdentityKey)
{
gen.visitJumpInsn(IF_ACMPNE, defaultLabel);
}
else
{
gen.invokeStatic(UTIL_TYPE, equivMethod);
gen.ifZCmp(GeneratorAdapter.EQ, defaultLabel);
}
emitExpr(objx, gen, then, emitUnboxed);
}
示例11: emitThenForInts
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
private void emitThenForInts(ObjExpr objx, GeneratorAdapter gen, Type exprType, Expr test, Expr then, Label defaultLabel, boolean emitUnboxed){
if (exprType == null)
{
expr.emit(C.EXPRESSION, objx, gen);
test.emit(C.EXPRESSION, objx, gen);
gen.invokeStatic(UTIL_TYPE, equivMethod);
gen.ifZCmp(GeneratorAdapter.EQ, defaultLabel);
emitExpr(objx, gen, then, emitUnboxed);
}
else if (exprType == Type.LONG_TYPE)
{
((NumberExpr)test).emitUnboxed(C.EXPRESSION, objx, gen);
expr.emitUnboxed(C.EXPRESSION, objx, gen);
gen.ifCmp(Type.LONG_TYPE, GeneratorAdapter.NE, defaultLabel);
emitExpr(objx, gen, then, emitUnboxed);
}
else if (exprType == Type.INT_TYPE
|| exprType == Type.SHORT_TYPE
|| exprType == Type.BYTE_TYPE)
{
if (isShiftMasked())
{
((NumberExpr)test).emitUnboxed(C.EXPRESSION, objx, gen);
expr.emitUnboxed(C.EXPRESSION, objx, gen);
gen.cast(exprType, Type.LONG_TYPE);
gen.ifCmp(Type.LONG_TYPE, GeneratorAdapter.NE, defaultLabel);
}
// else direct match
emitExpr(objx, gen, then, emitUnboxed);
}
else
{
gen.goTo(defaultLabel);
}
}
示例12: emitExprForHashes
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
private void emitExprForHashes(ObjExpr objx, GeneratorAdapter gen){
expr.emit(C.EXPRESSION, objx, gen);
gen.invokeStatic(UTIL_TYPE,hashMethod);
emitShiftMask(gen);
}
示例13: emitUnboxArg
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public static void emitUnboxArg(ObjExpr objx, GeneratorAdapter gen, Class paramType){
if(paramType.isPrimitive())
{
if(paramType == boolean.class)
{
gen.checkCast(BOOLEAN_TYPE);
gen.invokeVirtual(BOOLEAN_TYPE, booleanValueMethod);
// Label falseLabel = gen.newLabel();
// Label endLabel = gen.newLabel();
// gen.ifNull(falseLabel);
// gen.push(1);
// gen.goTo(endLabel);
// gen.mark(falseLabel);
// gen.push(0);
// gen.mark(endLabel);
}
else if(paramType == char.class)
{
gen.checkCast(CHAR_TYPE);
gen.invokeVirtual(CHAR_TYPE, charValueMethod);
}
else
{
// System.out.println("NOT fnexpr for defn var: " + var + "init: " + init.getClass());
Method m = null;
gen.checkCast(NUMBER_TYPE);
if(RT.booleanCast(RT.UNCHECKED_MATH.deref()))
{
if(paramType == int.class)
m = Method.getMethod("int uncheckedIntCast(Object)");
else if(paramType == float.class)
m = Method.getMethod("float uncheckedFloatCast(Object)");
else if(paramType == double.class)
m = Method.getMethod("double uncheckedDoubleCast(Object)");
else if(paramType == long.class)
m = Method.getMethod("long uncheckedLongCast(Object)");
else if(paramType == byte.class)
m = Method.getMethod("byte uncheckedByteCast(Object)");
else if(paramType == short.class)
m = Method.getMethod("short uncheckedShortCast(Object)");
}
else
{
if(paramType == int.class)
m = Method.getMethod("int intCast(Object)");
else if(paramType == float.class)
m = Method.getMethod("float floatCast(Object)");
else if(paramType == double.class)
m = Method.getMethod("double doubleCast(Object)");
else if(paramType == long.class)
m = Method.getMethod("long longCast(Object)");
else if(paramType == byte.class)
m = Method.getMethod("byte byteCast(Object)");
else if(paramType == short.class)
m = Method.getMethod("short shortCast(Object)");
}
gen.invokeStatic(RT_TYPE, m);
}
}
else
{
gen.checkCast(Type.getType(paramType));
}
}
示例14: emitBoxReturn
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public static void emitBoxReturn(ObjExpr objx, GeneratorAdapter gen, Class returnType){
if(returnType.isPrimitive())
{
if(returnType == boolean.class)
{
Label falseLabel = gen.newLabel();
Label endLabel = gen.newLabel();
gen.ifZCmp(GeneratorAdapter.EQ, falseLabel);
gen.getStatic(BOOLEAN_OBJECT_TYPE, "TRUE", BOOLEAN_OBJECT_TYPE);
gen.goTo(endLabel);
gen.mark(falseLabel);
gen.getStatic(BOOLEAN_OBJECT_TYPE, "FALSE", BOOLEAN_OBJECT_TYPE);
// NIL_EXPR.emit(C.EXPRESSION, fn, gen);
gen.mark(endLabel);
}
else if(returnType == void.class)
{
NIL_EXPR.emit(C.EXPRESSION, objx, gen);
}
else if(returnType == char.class)
{
gen.invokeStatic(CHAR_TYPE, charValueOfMethod);
}
else
{
if(returnType == int.class)
{
gen.invokeStatic(INTEGER_TYPE, intValueOfMethod);
// gen.visitInsn(I2L);
// gen.invokeStatic(NUMBERS_TYPE, Method.getMethod("Number num(long)"));
}
else if(returnType == float.class)
{
gen.invokeStatic(FLOAT_TYPE, floatValueOfMethod);
// gen.visitInsn(F2D);
// gen.invokeStatic(DOUBLE_TYPE, doubleValueOfMethod);
}
else if(returnType == double.class)
gen.invokeStatic(DOUBLE_TYPE, doubleValueOfMethod);
else if(returnType == long.class)
gen.invokeStatic(NUMBERS_TYPE, Method.getMethod("Number num(long)"));
else if(returnType == byte.class)
gen.invokeStatic(BYTE_TYPE, byteValueOfMethod);
else if(returnType == short.class)
gen.invokeStatic(SHORT_TYPE, shortValueOfMethod);
}
}
}
示例15: emitBody
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
static void emitBody(ObjExpr objx, GeneratorAdapter gen, Class retClass, Expr body) {
MaybePrimitiveExpr be = (MaybePrimitiveExpr) body;
if(Util.isPrimitive(retClass) && be.canEmitPrimitive())
{
Class bc = maybePrimitiveType(be);
if(bc == retClass)
be.emitUnboxed(C.RETURN, objx, gen);
else if(retClass == long.class && bc == int.class)
{
be.emitUnboxed(C.RETURN, objx, gen);
gen.visitInsn(I2L);
}
else if(retClass == double.class && bc == float.class)
{
be.emitUnboxed(C.RETURN, objx, gen);
gen.visitInsn(F2D);
}
else if(retClass == int.class && bc == long.class)
{
be.emitUnboxed(C.RETURN, objx, gen);
gen.invokeStatic(RT_TYPE, Method.getMethod("int intCast(long)"));
}
else if(retClass == float.class && bc == double.class)
{
be.emitUnboxed(C.RETURN, objx, gen);
gen.visitInsn(D2F);
}
else
throw new IllegalArgumentException("Mismatched primitive return, expected: "
+ retClass + ", had: " + be.getJavaClass());
}
else
{
body.emit(C.RETURN, objx, gen);
if(retClass == void.class)
{
gen.pop();
}
else
gen.unbox(Type.getType(retClass));
}
}