org.objectweb.asm.commons.Method.getName()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(78)

本文整理了Java中org.objectweb.asm.commons.Method.getName()方法的一些代码示例,展示了Method.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Method.getName()方法的具体详情如下:
包路径:org.objectweb.asm.commons.Method
类名称:Method
方法名:getName

Method.getName介绍

[英]Returns the name of the method described by this object.
[中]返回此对象描述的方法的名称。

代码示例

代码示例来源:origin: robolectric/robolectric

private BaseAdapter(
  Method method, org.objectweb.asm.commons.Method asmMethod, MethodVisitor methodVisitor) {
 super(
   Opcodes.ASM6,
   methodVisitor,
   Opcodes.ACC_PUBLIC,
   asmMethod.getName(),
   asmMethod.getDescriptor());
 this.iMethod = method;
}

代码示例来源:origin: robolectric/robolectric

private BaseAdapter(
  org.objectweb.asm.commons.Method asmMethod, Method method) {
 this(
   method,
   asmMethod,
   ReflectorClassWriter.this.visitMethod(
     Opcodes.ACC_PUBLIC,
     asmMethod.getName(),
     asmMethod.getDescriptor(),
     null,
     ReflectorClassWriter.getInternalNames(method.getExceptionTypes())));
}

代码示例来源:origin: micronaut-projects/micronaut-core

private Method writeResolveTargetMethod(ClassWriter proxyClassWriter, Type targetType) {
  Method resolveTargetMethodDesc = Method.getMethod(targetClassFullName + " " + METHOD_RESOLVE_TARGET + "()");
  GeneratorAdapter resolveTargetMethod = new GeneratorAdapter(proxyClassWriter.visitMethod(
    ACC_PRIVATE,
    resolveTargetMethodDesc.getName(),
    resolveTargetMethodDesc.getDescriptor(),
    null, null
  ), ACC_PRIVATE, METHOD_RESOLVE_TARGET, resolveTargetMethodDesc.getDescriptor());
  // add the logic to create to the bean instance
  resolveTargetMethod.loadThis();
  // load the bean context
  resolveTargetMethod.getField(proxyType, FIELD_BEAN_LOCATOR, TYPE_BEAN_LOCATOR);
  // 1st argument: the type
  resolveTargetMethod.push(targetType);
  // 2nd argument: null qualifier
  resolveTargetMethod.loadThis();
  // the bean qualifier
  resolveTargetMethod.getField(proxyType, FIELD_BEAN_QUALIFIER, Type.getType(Qualifier.class));
  resolveTargetMethod.invokeInterface(
    TYPE_BEAN_LOCATOR,
    METHOD_GET_PROXY_TARGET_BEAN
  );
  pushCastToType(resolveTargetMethod, targetClassFullName);
  resolveTargetMethod.returnValue();
  resolveTargetMethod.visitMaxs(1, 1);
  return resolveTargetMethodDesc;
}

代码示例来源:origin: micronaut-projects/micronaut-core

ClassVisitor pcw = proxyBeanDefinitionWriter.getClassWriter();
targetDefinitionGenerator = new GeneratorAdapter(pcw.visitMethod(ACC_PUBLIC,
  METHOD_PROXY_TARGET_TYPE.getName(),
  METHOD_PROXY_TARGET_TYPE.getDescriptor(),
  null, null
), ACC_PUBLIC, METHOD_PROXY_TARGET_TYPE.getName(), METHOD_PROXY_TARGET_TYPE.getDescriptor());
targetDefinitionGenerator.loadThis();
targetDefinitionGenerator.push(getTypeReference(parentWriter.getBeanDefinitionName()));
    METHOD_PROXY_TARGET_CLASS.getName(),
    METHOD_PROXY_TARGET_CLASS.getDescriptor(),
    null, null
), ACC_PUBLIC, METHOD_PROXY_TARGET_CLASS.getName(), METHOD_PROXY_TARGET_CLASS.getDescriptor());
targetTypeGenerator.loadThis();
targetTypeGenerator.push(getTypeReference(parentWriter.getBeanTypeName()));

代码示例来源:origin: com.google.gwt/gwt-servlet

private static String print(Method method) {
 StringBuilder sb = new StringBuilder();
 sb.append(print(method.getReturnType())).append(" ").append(method.getName()).append("(");
 for (Type t : method.getArgumentTypes()) {
  sb.append(print(t)).append(" ");
 }
 sb.append(")");
 return sb.toString();
}

代码示例来源:origin: glowroot/glowroot

private @Nullable Method hack(@Nullable Method method) {
  if (method == null) {
    return null;
  }
  Type[] argumentTypes = method.getArgumentTypes();
  Type[] hackedArgumentTypes = new Type[argumentTypes.length];
  for (int i = 0; i < argumentTypes.length; i++) {
    hackedArgumentTypes[i] = hack(argumentTypes[i]);
  }
  return new Method(method.getName(), hack(method.getReturnType()), hackedArgumentTypes);
}

代码示例来源:origin: glowroot/glowroot

@RequiresNonNull("type")
private void addShim(ShimType shimType) {
  for (java.lang.reflect.Method reflectMethod : shimType.shimMethods()) {
    Method method = Method.getMethod(reflectMethod);
    Shim shim = reflectMethod.getAnnotation(Shim.class);
    checkNotNull(shim);
    if (shim.value().length != 1) {
      throw new IllegalStateException(
          "@Shim annotation must have exactly one value when used on methods");
    }
    Method targetMethod = Method.getMethod(shim.value()[0]);
    MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, method.getName(), method.getDescriptor(),
        null, null);
    mv.visitCode();
    int i = 0;
    mv.visitVarInsn(ALOAD, i++);
    for (Type argumentType : method.getArgumentTypes()) {
      mv.visitVarInsn(argumentType.getOpcode(ILOAD), i++);
    }
    mv.visitMethodInsn(INVOKEVIRTUAL, type.getInternalName(), targetMethod.getName(),
        targetMethod.getDescriptor(), false);
    mv.visitInsn(method.getReturnType().getOpcode(IRETURN));
    mv.visitMaxs(0, 0);
    mv.visitEnd();
  }
}

代码示例来源:origin: glowroot/glowroot

for (java.lang.reflect.Method shimMethod : shimType.shimMethods()) {
  Method method = Method.getMethod(shimMethod);
  shimMethods.add(method.getName() + method.getDescriptor());

代码示例来源:origin: glowroot/glowroot

IsEnabled.class, false, null, nestingGroup, suppressionKey);
visitMethodInsn(INVOKESTATIC, advice.adviceType().getInternalName(),
    isEnabledAdvice.getName(), isEnabledAdvice.getDescriptor(), false);
if (otherEnabledFactorsDisabledEnd == null) {

代码示例来源:origin: glowroot/glowroot

String descriptor = "(Z" + onBeforeAdvice.getDescriptor().substring(1);
  visitMethodInsn(INVOKESTATIC, advice.adviceType().getInternalName(),
      onBeforeAdvice.getName(), descriptor, false);
} else {
  visitMethodInsn(INVOKESTATIC, advice.adviceType().getInternalName(),
      onBeforeAdvice.getName(), onBeforeAdvice.getDescriptor(), false);

代码示例来源:origin: glowroot/glowroot

onThrowAdvice.getName(), onThrowAdvice.getDescriptor(), false);
if (onThrowBlockEnd != null) {
  visitLabel(onThrowBlockEnd);

代码示例来源:origin: glowroot/glowroot

private void visitOnAfterAdvice(Advice advice, boolean insideCatchHandler) {
  Method onAfterAdvice = advice.onAfterAdvice();
  if (onAfterAdvice == null) {
    return;
  }
  Integer enabledLocal = enabledLocals.get(advice);
  Label onAfterBlockEnd = null;
  if (enabledLocal != null) {
    onAfterBlockEnd = new Label();
    loadLocal(enabledLocal);
    visitJumpInsn(IFEQ, onAfterBlockEnd);
  }
  loadMethodParameters(advice.onAfterParameters(), 0, travelerLocals.get(advice),
      advice.adviceType(), OnAfter.class, true, null, advice.pointcut().nestingGroup(),
      advice.pointcut().suppressionKey());
  visitMethodInsn(INVOKESTATIC, advice.adviceType().getInternalName(),
      onAfterAdvice.getName(), onAfterAdvice.getDescriptor(), false);
  if (onAfterBlockEnd != null) {
    visitLabel(onAfterBlockEnd);
    // either inside catch handler or inside on return block
    if (insideCatchHandler) {
      visitImplicitFrame("java/lang/Throwable");
    } else if (returnType.getSort() == Type.VOID) {
      visitImplicitFrame();
    } else {
      visitImplicitFrame(convert(returnType));
    }
  }
}

代码示例来源:origin: org.ow2.asm/asm-commons

/**
 * Generates an invoke method instruction.
 *
 * @param opcode the instruction's opcode.
 * @param type the class in which the method is defined.
 * @param method the method to be invoked.
 * @param isInterface whether the 'type' class is an interface or not.
 */
private void invokeInsn(
  final int opcode, final Type type, final Method method, final boolean isInterface) {
 String owner = type.getSort() == Type.ARRAY ? type.getDescriptor() : type.getInternalName();
 mv.visitMethodInsn(opcode, owner, method.getName(), method.getDescriptor(), isInterface);
}

代码示例来源:origin: google/closure-templates

public CodeBuilder(int access, Method method, @Nullable Type[] exceptions, ClassVisitor cv) {
 this(
   access,
   method,
   cv.visitMethod(
     access,
     method.getName(),
     method.getDescriptor(),
     null /* generic signature */,
     getInternalNames(exceptions)));
}

代码示例来源:origin: com.google.template/soy

public CodeBuilder(int access, Method method, @Nullable Type[] exceptions, ClassVisitor cv) {
 this(
   access,
   method,
   cv.visitMethod(
     access,
     method.getName(),
     method.getDescriptor(),
     null /* generic signature */,
     getInternalNames(exceptions)));
}

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

private static String print(Method method) {
 StringBuilder sb = new StringBuilder();
 sb.append(print(method.getReturnType())).append(" ").append(method.getName()).append("(");
 for (Type t : method.getArgumentTypes()) {
  sb.append(print(t)).append(" ");
 }
 sb.append(")");
 return sb.toString();
}

代码示例来源:origin: org.robolectric/utils-reflector

private BaseAdapter(
  org.objectweb.asm.commons.Method asmMethod, Method method) {
 this(
   method,
   asmMethod,
   ReflectorClassWriter.this.visitMethod(
     Opcodes.ACC_PUBLIC,
     asmMethod.getName(),
     asmMethod.getDescriptor(),
     null,
     ReflectorClassWriter.getInternalNames(method.getExceptionTypes())));
}

代码示例来源:origin: glowroot/glowroot

onReturnAdvice.getName(), onReturnAdvice.getDescriptor(), false);
if (onReturnAdvice.getReturnType().getSort() != Type.VOID && opcode == RETURN) {
  pop();

代码示例来源:origin: google/closure-templates

/**
 * Returns a new {@link ConstructorRef} that refers to a constructor on the given type with the
 * given parameter types.
 */
public static ConstructorRef create(TypeInfo type, Method init) {
 checkArgument(
   init.getName().equals("<init>") && init.getReturnType().equals(Type.VOID_TYPE),
   "'%s' is not a valid constructor",
   init);
 return new AutoValue_ConstructorRef(type, init, ImmutableList.copyOf(init.getArgumentTypes()));
}

代码示例来源:origin: com.google.template/soy

/**
 * Returns a new {@link ConstructorRef} that refers to a constructor on the given type with the
 * given parameter types.
 */
public static ConstructorRef create(TypeInfo type, Method init) {
 checkArgument(
   init.getName().equals("<init>") && init.getReturnType().equals(Type.VOID_TYPE),
   "'%s' is not a valid constructor",
   init);
 return new AutoValue_ConstructorRef(type, init, ImmutableList.copyOf(init.getArgumentTypes()));
}

相关文章