本文整理匯總了Java中org.objectweb.asm.commons.Method.getMethod方法的典型用法代碼示例。如果您正苦於以下問題:Java Method.getMethod方法的具體用法?Java Method.getMethod怎麽用?Java Method.getMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.objectweb.asm.commons.Method
的用法示例。
在下文中一共展示了Method.getMethod方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findCallHierarchy
import org.objectweb.asm.commons.Method; //導入方法依賴的package包/類
/**
* Find call hierarchy of <b>methodSignature</b> of the class <b>className</b> or any subclass
* @param className the full class name. ex: "java/lang/Integer"
* @param methodSignature method signature. ex: "java.lang.Integer methodName(java.lang.Integer)"
* @return a CallHierarchy starting with the parameter method
* @throws IOException if an I/O error has occurred
*/
public CallHierarchy findCallHierarchy( String className, String methodSignature ) throws IOException {
String methodName = "";
String methodDesc = "";
if( methodSignature != null ){
Method method = Method.getMethod(methodSignature);
methodName = method.getName();
methodDesc = method.getDescriptor();
}
CallHierarchy callHierarchy = new CallHierarchy(null, className, methodName, methodDesc);
findCallHierarchy( callHierarchy );
return callHierarchy;
}
示例2: emitMethods
import org.objectweb.asm.commons.Method; //導入方法依賴的package包/類
protected void emitMethods(ClassVisitor cv){
//override of invoke/doInvoke for each method
for(ISeq s = RT.seq(methods); s != null; s = s.next())
{
ObjMethod method = (ObjMethod) s.first();
method.emit(this, cv);
}
if(isVariadic())
{
GeneratorAdapter gen = new GeneratorAdapter(ACC_PUBLIC,
Method.getMethod("int getRequiredArity()"),
null,
null,
cv);
gen.visitCode();
gen.push(variadicMethod.reqParms.count());
gen.returnValue();
gen.endMethod();
}
}
示例3: findCallersOfMethod
import org.objectweb.asm.commons.Method; //導入方法依賴的package包/類
/**
* Find callers of <b>methodSignature</b> of the class <b>className</b> or any subclass
* @param className the full class name. ex: "java/lang/Integer"
* @param methodSignature method signature. ex: "java.lang.Integer methodName(java.lang.Integer)"
* @return a Set with the callers or a empty Set if no one was found
* @throws IOException if an I/O error has occurred
*/
public Set<JavaMethod> findCallersOfMethod( String className, String methodSignature ) throws IOException {
String methodName = "";
String methodDesc = "";
if( methodSignature != null ){
Method method = Method.getMethod(methodSignature);
methodName = method.getName();
methodDesc = method.getDescriptor();
}
return findCallersOfMethod( className, methodName, methodDesc );
}
示例4: RenderPlayerVisitorMethodRotateCorpse
import org.objectweb.asm.commons.Method; //導入方法依賴的package包/類
public RenderPlayerVisitorMethodRotateCorpse(MethodVisitor mv) {
super(Opcodes.ASM5, mv);
try {
method = Method.getMethod(RenderPlayerVisitor.class.getMethod("injectMethod", AbstractClientPlayer.class, float.class));
} catch (Exception e) {
throw Throwables.propagate(e);
}
ASMUtil.asmLogger(ASMLogType.INJECTING, RenderPlayerVisitor.class + "." + method.toString());
}
示例5: EntityRenderVisitorMethodSetupCameraTransform
import org.objectweb.asm.commons.Method; //導入方法依賴的package包/類
public EntityRenderVisitorMethodSetupCameraTransform(MethodVisitor mv) {
super(Opcodes.ASM5, mv);
try {
method = Method.getMethod(EntityRenderVisitor.class.getMethod("injectMethod", float.class, int.class));
} catch (Exception e) {
throw Throwables.propagate(e);
}
ASMUtil.asmLogger(ASMLogType.INJECTING, EntityRenderVisitor.class + "." + method.toString());
}
示例6: AbstractClientPlayerVisitorMethodGetLocationCape
import org.objectweb.asm.commons.Method; //導入方法依賴的package包/類
public AbstractClientPlayerVisitorMethodGetLocationCape(MethodVisitor mv) {
super(Opcodes.ASM5, mv);
try {
method = Method.getMethod(AbstractClientPlayerVisitor.class.getMethod("injectMethod", NetworkPlayerInfo.class));
} catch (Exception e) {
throw Throwables.propagate(e);
}
ASMUtil.asmLogger(ASMLogType.INJECTING, AbstractClientPlayerVisitor.class + "." + method.toString());
}
示例7: InjectorMethodVisitor
import org.objectweb.asm.commons.Method; //導入方法依賴的package包/類
public InjectorMethodVisitor(MethodVisitor mv) {
super(Opcodes.ASM5, mv);
try {
postMethod = Method.getMethod(PlayerRendererHookVisitor.class.getMethod("post", AbstractClientPlayer.class, float.class));
} catch (Throwable t) {
throw Throwables.propagate(t);
}
TeambattleReference.log.info((String.format("Injecting hook %s.%s into EntityPlayerRender.rotateCorpse", PlayerRendererHookVisitor.class, postMethod)));
}
示例8: initClass
import org.objectweb.asm.commons.Method; //導入方法依賴的package包/類
private void initClass() {
classWriter.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, className, null, "java/lang/Object", null);
Method init = Method.getMethod("void <init>()");
GeneratorAdapter gaInit = new GeneratorAdapter(Opcodes.ACC_PUBLIC, init, null, null, classWriter);
gaInit.visitCode();
gaInit.loadThis();
gaInit.invokeConstructor(Type.getType(Object.class), init);
gaInit.returnValue();
gaInit.endMethod();
}
示例9: createRunMethod
import org.objectweb.asm.commons.Method; //導入方法依賴的package包/類
private void createRunMethod() {
Method run = Method.getMethod("int run()");
GeneratorAdapter ga = new GeneratorAdapter((Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC), run, null, null, classWriter);
ga.visitCode();
// BEGIN important part
ga.push(42);
(new FstCompiler(fst, ga)).compile();
// END important part
ga.returnValue();
ga.endMethod();
}
示例10: compileFuncType
import org.objectweb.asm.commons.Method; //導入方法依賴的package包/類
public Class<?> compileFuncType(String cname, Class<?> returnType, Class<?>... paramTypes) {
this.openClass(Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT, cname, konoha.Function.class);
this.mBuilder = this.cBuilder.newMethodBuilder(Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT, returnType, "invoke", paramTypes);
this.mBuilder.endMethod();
Method desc = Method.getMethod("void <init> ()");
this.mBuilder = this.cBuilder.newMethodBuilder(Opcodes.ACC_PUBLIC, desc);
this.mBuilder.loadThis(); // InitMethod.visitVarInsn(ALOAD, 0);
this.mBuilder.invokeConstructor(Type.getType(konoha.Function.class), desc);
this.mBuilder.returnValue();
this.mBuilder.endMethod();
return this.closeClass();
}
示例11: compileFunctionWrapperClass
import org.objectweb.asm.commons.Method; //導入方法依賴的package包/類
public Class<?> compileFunctionWrapperClass(Class<?> superClass, java.lang.reflect.Method staticMethod) {
this.openClass("C" + staticMethod.getName() + "Wrapper" + unique, superClass);
unique++;
Class<?> returnType = staticMethod.getReturnType();
Class<?>[] paramTypes = staticMethod.getParameterTypes();
this.mBuilder = this.cBuilder.newMethodBuilder(Opcodes.ACC_PUBLIC, returnType, "invoke", paramTypes);
int index = 1;
for (int i = 0; i < paramTypes.length; i++) {
Type aType = Type.getType(paramTypes[i]);
this.mBuilder.visitVarInsn(aType.getOpcode(Opcodes.ILOAD), index);
// this.mBuilder.loadLocal(index, aType); FIXME
index += aType.getSize();
}
Type owner = Type.getType(staticMethod.getDeclaringClass());
Method methodDesc = Method.getMethod(staticMethod);
this.mBuilder.invokeStatic(owner, methodDesc);
this.mBuilder.returnValue();
this.mBuilder.endMethod();
Method desc = Method.getMethod("void <init> ()");
this.mBuilder = this.cBuilder.newMethodBuilder(Opcodes.ACC_PUBLIC, desc);
this.mBuilder.loadThis(); // InitMethod.visitVarInsn(ALOAD, 0);
this.mBuilder.invokeConstructor(Type.getType(superClass), desc);
this.mBuilder.returnValue();
this.mBuilder.endMethod();
return this.closeClass();
}
示例12: getAsmMethod
import org.objectweb.asm.commons.Method; //導入方法依賴的package包/類
static Method getAsmMethod(final Class<?> clazz,
final String methodName,
final Class<?>... parameterClassArray) {
return Method.getMethod(unCaughtGetClassDeclaredJavaMethod(clazz, methodName, parameterClassArray));
}
示例13: emitUnboxArg
import org.objectweb.asm.commons.Method; //導入方法依賴的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: generateRun
import org.objectweb.asm.commons.Method; //導入方法依賴的package包/類
private static void generateRun(ClassVisitor cv, Type testType, List<Actor> actors, List<Object> objArgs, boolean waitsEnabled) {
int access = ACC_PUBLIC;
Method m = new Method("call", RESULT_ARRAY_TYPE, NO_ARGS);
GeneratorAdapter mv = new GeneratorAdapter(access, m,
// Try-catch blocks sorting is required
new TryCatchBlockSorter(cv.visitMethod(access, m.getName(), m.getDescriptor(), null, null),
access, m.getName(), m.getDescriptor(), null, null)
);
mv.visitCode();
// Create Result[] array and store it to a local variable
int resLocal = createResultArray(mv, actors.size());
// Wait for other threads
arriveAndAwaitAdvance(mv);
// Number of current operation (starts with 0)
int iLocal = mv.newLocal(Type.INT_TYPE);
mv.push(0);
mv.storeLocal(iLocal);
// Invoke actors
for (int i = 0; i < actors.size(); i++) {
Actor actor = actors.get(i);
// Add busy-wait before operation execution (for non-first operations only)
if (waitsEnabled && i > 0) {
mv.loadThis();
mv.getField(TEST_THREAD_EXECUTION_TYPE, "waits", INT_ARRAY_TYPE);
mv.push(i - 1);
mv.arrayLoad(Type.INT_TYPE);
mv.invokeStatic(UTILS_TYPE, UTILS_CONSUME_CPU);
}
// Start of try-catch block for exceptions which this actor should handle
Label start, end = null, handler = null, handlerEnd = null;
if (actor.handlesExceptions()) {
start = mv.newLabel();
end = mv.newLabel();
handler = mv.newLabel();
handlerEnd = mv.newLabel();
for (Class<? extends Throwable> ec : actor.handledExceptions)
mv.visitTryCatchBlock(start, end, handler, Type.getType(ec).getInternalName());
mv.visitLabel(start);
}
// Load result array and index to store the current result
mv.loadLocal(resLocal);
mv.push(i);
// Load test instance
mv.loadThis();
mv.getField(TEST_THREAD_EXECUTION_TYPE, "testInstance", OBJECT_TYPE);
mv.checkCast(testType);
// Load arguments for operation
for (int j = 0; j < actor.arguments.length; j++) {
pushArgumentOnStack(mv, objArgs, actor.arguments[j], actor.method.getParameterTypes()[j]);
}
// Invoke operation
Method actorMethod = Method.getMethod(actor.method);
mv.invokeVirtual(testType, actorMethod);
// Create result
mv.box(actorMethod.getReturnType()); // box if needed
if (actor.method.getReturnType() == void.class) {
mv.pop();
mv.invokeStatic(RESULT_TYPE, RESULT_CREATE_VOID_RESULT);
} else {
mv.invokeStatic(RESULT_TYPE, RESULT_CREATE_VALUE_RESULT);
}
// Store result to array
mv.arrayStore(RESULT_TYPE);
// End of try-catch block
if (actor.handlesExceptions()) {
mv.visitLabel(end);
mv.goTo(handlerEnd);
mv.visitLabel(handler);
storeExceptionResultFromThrowable(mv, resLocal, iLocal);
mv.visitLabel(handlerEnd);
}
// Increment number of current operation
mv.iinc(iLocal, 1);
}
// Return results
mv.loadThis();
mv.loadLocal(resLocal);
mv.returnValue();
mv.visitMaxs(1, 1);
mv.visitEnd();
}
示例15: visitEnd
import org.objectweb.asm.commons.Method; //導入方法依賴的package包/類
@Override
public void visitEnd() {
if(canChangeSignature && !definesHashCode && !isInterface && RuntimeSettings.mockJVMNonDeterminism) {
// logger.info("No hashCode defined for: "+className+", superclass = "+superClassName);
if(superClassName.equals("java.lang.Object")) { //TODO: why only if superclass is Object??? unclear
Method hashCodeMethod = Method.getMethod("int hashCode()");
GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC, hashCodeMethod, null, null, this);
mg.loadThis();
mg.visitAnnotation(Type.getDescriptor(EvoSuiteExclude.class), true);
mg.invokeStatic(Type.getType(org.evosuite.runtime.System.class), Method.getMethod("int identityHashCode(Object)"));
mg.returnValue();
mg.endMethod();
}
}
/*
* If the class is serializable, then doing any change (adding hashCode, static reset, etc)
* will change the serialVersionUID if it is not defined in the class.
* Hence, if it is not defined, we have to define it to
* avoid problems in serialising the class, as reading Master will not do instrumentation.
* The serialVersionUID HAS to be the same as the un-instrumented class
*/
if(!definesUid && !isInterface && RuntimeSettings.applyUIDTransformation) {
ClassLoader threadCL = Thread.currentThread().getContextClassLoader();
try {
ClassLoader evoCL = MethodCallReplacementClassAdapter.class.getClassLoader();
Thread.currentThread().setContextClassLoader(evoCL);
Class<?> clazz = Class.forName(className.replace('/', '.'), false, evoCL);
if(Serializable.class.isAssignableFrom(clazz)) {
ObjectStreamClass c = ObjectStreamClass.lookup(clazz);
long serialID = c.getSerialVersionUID();
logger.info("Adding serialId to class "+className);
visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL, "serialVersionUID", "J", null, serialID);
}
} catch(ClassNotFoundException | NoClassDefFoundError | HeadlessException | ExceptionInInitializerError e) {
logger.warn("Failed to add serialId to class "+className+": "+e.getMessage());
} finally {
Thread.currentThread().setContextClassLoader(threadCL);
}
}
super.visitEnd();
}