当前位置: 首页>>代码示例>>Java>>正文


Java Method.getDescriptor方法代码示例

本文整理汇总了Java中org.objectweb.asm.commons.Method.getDescriptor方法的典型用法代码示例。如果您正苦于以下问题:Java Method.getDescriptor方法的具体用法?Java Method.getDescriptor怎么用?Java Method.getDescriptor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.objectweb.asm.commons.Method的用法示例。


在下文中一共展示了Method.getDescriptor方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:goblinbr,项目名称:BytecodeCallHierarchyScanner,代码行数:23,代码来源:JavaScanner.java

示例2: MethodWriter

import org.objectweb.asm.commons.Method; //导入方法依赖的package包/类
public MethodWriter(int access, Method method, ClassVisitor cw, BitSet statements, CompilerSettings settings) {
    super(Opcodes.ASM5, cw.visitMethod(access, method.getName(), method.getDescriptor(), null, null),
            access, method.getName(), method.getDescriptor());

    this.statements = statements;
    this.settings = settings;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:MethodWriter.java

示例3: addSupportMethod

import org.objectweb.asm.commons.Method; //导入方法依赖的package包/类
public void addSupportMethod() {
        int access = Opcodes.ACC_PUBLIC;
        Method m = new Method("isSupport", "(I)Z");
        MethodVisitor mv = super.visitMethod(access,
                m.getName(),
                m.getDescriptor(),
                null, null);

        mv.visitCode();
        mv.visitVarInsn(Opcodes.ALOAD, 1);
//        mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/String", "hashCode", "()I", false);

        int[] hashArray = new int[fixMtds.size()];
        Label[] labelArray = new Label[fixMtds.size()];
        Label l0 = new Label();
        Label l1 = new Label();
        for (int i = 0; i < fixMtds.size(); i++) {
            hashArray[i] = AcesoProguardMap.instance().getClassData(visitedClassName).getMtdIndex(fixMtds.get(i));
            labelArray[i] = l0;
        }

        mv.visitLookupSwitchInsn(l1, hashArray, labelArray);
        mv.visitLabel(l0);
        mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
        mv.visitInsn(Opcodes.ICONST_1);
        mv.visitInsn(Opcodes.IRETURN);
        mv.visitLabel(l1);
        mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
        mv.visitInsn(Opcodes.ICONST_0);
        mv.visitInsn(Opcodes.IRETURN);
        mv.visitMaxs(1, 2);
        mv.visitEnd();

        mv.visitMaxs(0, 0);
        mv.visitEnd();

    }
 
开发者ID:meili,项目名称:Aceso,代码行数:38,代码来源:IncrementalChangeVisitor.java

示例4: 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 );
}
 
开发者ID:goblinbr,项目名称:BytecodeCallHierarchyScanner,代码行数:19,代码来源:JavaScanner.java

示例5: MethodBuilder

import org.objectweb.asm.commons.Method; //导入方法依赖的package包/类
public MethodBuilder(int accessFlag, Method method, ClassVisitor cv) {
	super(Opcodes.ASM5, toMethodVisitor(accessFlag, method, cv), accessFlag, method.getName(), method.getDescriptor());
	this.loopLabels = new ArrayDeque<>();
	this.tryLabels = new ArrayDeque<>();
	int startIndex = 0;
	if ((accessFlag & Opcodes.ACC_STATIC) != Opcodes.ACC_STATIC) {
		startIndex = 1;
	}
	this.varScopes = new VarScopes(startIndex);
	this.method = method;
}
 
开发者ID:nez-peg,项目名称:konoha,代码行数:12,代码来源:MethodBuilder.java

示例6: 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();
}
 
开发者ID:Devexperts,项目名称:lin-check,代码行数:82,代码来源:TestThreadExecutionGenerator.java

示例7: push

import org.objectweb.asm.commons.Method; //导入方法依赖的package包/类
void push(Functor f, SyntaxTree node) {
	if (f.ref instanceof java.lang.reflect.Method) {
		java.lang.reflect.Method m = (java.lang.reflect.Method) f.ref;
		if (Lang.isStatic(m)) {
			this.mBuilder.invokeStatic(Type.getType(m.getDeclaringClass()), Method.getMethod(m));
		} else if (Lang.isInterface(m)) {
			this.mBuilder.invokeInterface(Type.getType(m.getDeclaringClass()), Method.getMethod(m));
		} else {
			this.mBuilder.invokeVirtual(Type.getType(m.getDeclaringClass()), Method.getMethod(m));
		}
		Class<?> t = node.getClassType();
		if (m.getReturnType() == Object.class && t != Object.class) {
			if (t.isPrimitive()) {
				this.mBuilder.unbox(Type.getType(t));
			} else {
				this.mBuilder.checkCast(Type.getType(t));
			}
		}
	} else if (f.ref instanceof java.lang.reflect.Field) {
		Field fld = (Field) f.ref;
		Type owner = Type.getType(fld.getDeclaringClass());
		String name = fld.getName();
		Type fieldType = Type.getType(fld.getType());
		if (f.syntax == Syntax.Getter) {
			if (Lang.isStatic(fld)) {
				this.mBuilder.getStatic(owner, name, fieldType);
			} else {
				this.mBuilder.getField(owner, name, fieldType);
			}
		} else {
			java.lang.reflect.Type ret = f.getReturnType();
			if (Lang.isStatic(fld)) {
				if (ret == long.class || ret == double.class) {
					this.mBuilder.dup2();
				} else if (ret != void.class) {
					this.mBuilder.dup();
				}
				this.mBuilder.putStatic(owner, name, fieldType);
			} else {
				if (ret == long.class || ret == double.class) {
					this.mBuilder.dup2X1();
				} else if (ret != void.class) {
					this.mBuilder.dupX1();
				}
				this.mBuilder.putField(owner, name, fieldType);
			}
		}
	} else if (f.ref instanceof java.lang.reflect.Constructor) {
		java.lang.reflect.Constructor<?> c = (java.lang.reflect.Constructor<?>) f.ref;
		this.mBuilder.invokeConstructor(Type.getType(c.getDeclaringClass()), Method.getMethod(c));
	} else if (f.ref instanceof Prototype) {
		((Prototype) f.ref).push(this.mBuilder);
	} else if (f.ref instanceof DynamicSite) {
		if (f.syntax == Syntax.Setter) {
			this.mBuilder.dupX1();
		} else if (f.syntax == Syntax.SetIndexer) {
			this.mBuilder.dupX2();
		}
		DynamicSite site = (DynamicSite) f.ref;
		String desc = site.type().toMethodDescriptorString();
		// System.out.println("InvokeDynamic: " + desc);
		Type[] paramTypes = { Type.getType(MethodHandles.Lookup.class), Type.getType(String.class), Type.getType(MethodType.class) };
		Method methodDesc = new Method("bootstrap", Type.getType(CallSite.class), paramTypes);
		Handle handle = new Handle(Opcodes.H_INVOKESTATIC, Type.getType(site.getClass()).getInternalName(), "bootstrap", methodDesc.getDescriptor());
		this.mBuilder.invokeDynamic(site.encodeName(), desc, handle);
	}
}
 
开发者ID:nez-peg,项目名称:konoha,代码行数:68,代码来源:ScriptCompilerAsm.java

示例8: toMethodVisitor

import org.objectweb.asm.commons.Method; //导入方法依赖的package包/类
/**
 * helper method for method visitor generation
 * 
 * @param access
 * @param method
 * @param cv
 * @return
 */

private static MethodVisitor toMethodVisitor(int access, Method method, ClassVisitor cv) {
	MethodVisitor visitor = cv.visitMethod(access, method.getName(), method.getDescriptor(), null, null);
	JSRInlinerAdapter inlinerAdapter = new JSRInlinerAdapter(visitor, access, method.getName(), method.getDescriptor(), null, null);
	return inlinerAdapter;
	// return visitor;
}
 
开发者ID:nez-peg,项目名称:konoha,代码行数:16,代码来源:MethodBuilder.java


注:本文中的org.objectweb.asm.commons.Method.getDescriptor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。