本文整理了Java中org.objectweb.asm.commons.Method.getReturnType()
方法的一些代码示例,展示了Method.getReturnType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Method.getReturnType()
方法的具体详情如下:
包路径:org.objectweb.asm.commons.Method
类名称:Method
方法名:getReturnType
[英]Returns the return type of the method described by this object.
[中]返回此对象描述的方法的返回类型。
代码示例来源: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: com.google.gwt/gwt-servlet
/**
* Produce a rebased method declaration, also visiting referenced types.
*/
private Method processMethod(String sourceType, String name, String desc) {
Method method = new Method(name, desc);
Type[] argumentTypes = method.getArgumentTypes();
for (int i = 0, j = argumentTypes.length; i < j; i++) {
argumentTypes[i] = processType(sourceType, argumentTypes[i]);
}
method = new Method(name, processType(sourceType, method.getReturnType()), argumentTypes);
return method;
}
代码示例来源:origin: glowroot/glowroot
private void initOnBeforeAdvice(PointcutClass adviceClass, PointcutMethod adviceMethod)
throws AdviceConstructionException {
checkState(!hasOnBeforeAdvice, "@Pointcut '" + adviceClass.type().getClassName()
+ "' has more than one @OnBefore method");
Method asmMethod = adviceMethod.toAsmMethod();
builder.onBeforeAdvice(asmMethod);
List<AdviceParameter> parameters =
getAdviceParameters(adviceMethod.parameterAnnotationTypes(),
asmMethod.getArgumentTypes(), onBeforeBindAnnotationTypes, OnBeforeType);
builder.addAllOnBeforeParameters(parameters);
if (asmMethod.getReturnType().getSort() != Type.VOID) {
builder.travelerType(asmMethod.getReturnType());
}
checkForBindThreadContext(parameters);
checkForBindOptionalThreadContext(parameters);
hasOnBeforeAdvice = true;
}
代码示例来源:origin: glowroot/glowroot
private void initIsEnabledAdvice(PointcutClass adviceClass, PointcutMethod adviceMethod)
throws AdviceConstructionException {
checkState(!hasIsEnabledAdvice, "@Pointcut '" + adviceClass.type().getClassName()
+ "' has more than one @IsEnabled method");
Method asmMethod = adviceMethod.toAsmMethod();
checkState(asmMethod.getReturnType().getSort() == Type.BOOLEAN,
"@IsEnabled method must return boolean");
builder.isEnabledAdvice(asmMethod);
List<AdviceParameter> parameters =
getAdviceParameters(adviceMethod.parameterAnnotationTypes(),
asmMethod.getArgumentTypes(), isEnabledBindAnnotationTypes, IsEnabledType);
builder.addAllIsEnabledParameters(parameters);
hasIsEnabledAdvice = true;
}
代码示例来源:origin: glowroot/glowroot
private void initOnThrowAdvice(PointcutClass adviceClass, PointcutMethod adviceMethod)
throws AdviceConstructionException {
checkState(!hasOnThrowAdvice, "@Pointcut '" + adviceClass.type().getClassName()
+ "' has more than one @OnThrow method");
Method asmMethod = adviceMethod.toAsmMethod();
List<AdviceParameter> parameters =
getAdviceParameters(adviceMethod.parameterAnnotationTypes(),
asmMethod.getArgumentTypes(), onThrowBindAnnotationTypes, OnThrowType);
for (int i = 1; i < parameters.size(); i++) {
checkState(parameters.get(i).kind() != ParameterKind.THROWABLE,
"@BindThrowable must be the first argument to @OnThrow");
}
checkState(asmMethod.getReturnType().getSort() == Type.VOID,
"@OnThrow method must return void (for now)");
builder.onThrowAdvice(asmMethod);
builder.addAllOnThrowParameters(parameters);
checkForBindThreadContext(parameters);
checkForBindOptionalThreadContext(parameters);
hasOnThrowAdvice = true;
}
代码示例来源:origin: glowroot/glowroot
private void initOnAfterAdvice(PointcutClass adviceClass, PointcutMethod adviceMethod)
throws AdviceConstructionException {
checkState(!hasOnAfterAdvice, "@Pointcut '" + adviceClass.type().getClassName()
+ "' has more than one @OnAfter method");
Method asmMethod = adviceMethod.toAsmMethod();
checkState(asmMethod.getReturnType().getSort() == Type.VOID,
"@OnAfter method must return void");
builder.onAfterAdvice(asmMethod);
List<AdviceParameter> parameters =
getAdviceParameters(adviceMethod.parameterAnnotationTypes(),
asmMethod.getArgumentTypes(), onAfterBindAnnotationTypes, OnAfterType);
builder.addAllOnAfterParameters(parameters);
checkForBindThreadContext(parameters);
checkForBindOptionalThreadContext(parameters);
hasOnAfterAdvice = true;
}
代码示例来源:origin: glowroot/glowroot
Object[] stack;
AdviceParameter parameter = advice.onReturnParameters().get(0);
boolean leaveReturnValueOnStack = onReturnAdvice.getReturnType().getSort() == Type.VOID;
switch (parameter.kind()) {
case RETURN:
stack = new Object[] {};
} else {
if (onReturnAdvice.getReturnType().getSort() == Type.VOID) {
stack = new Object[] {convert(returnType)};
} else {
travelerLocals.get(advice), advice.adviceType(), OnReturn.class, true, null,
advice.pointcut().nestingGroup(), advice.pointcut().suppressionKey(), stack);
} else if (onReturnAdvice.getReturnType().getSort() != Type.VOID && opcode != RETURN) {
pop();
if (onReturnAdvice.getReturnType().getSort() != Type.VOID && opcode == RETURN) {
pop();
代码示例来源:origin: OpenMods/OpenModsLib
@Override
public Type getInterfaceType(Type annotationHint) {
return MoreObjects.firstNonNull(annotationHint, method.getReturnType());
}
代码示例来源: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: net.wetheinter/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: google/closure-templates
public static MethodRef createStaticMethod(TypeInfo owner, Method method) {
return new AutoValue_MethodRef(
Opcodes.INVOKESTATIC,
owner,
method,
method.getReturnType(),
ImmutableList.<Type>builder().add(method.getArgumentTypes()).build(),
Features.of());
}
代码示例来源:origin: com.google.template/soy
public static MethodRef createStaticMethod(TypeInfo owner, Method method) {
return new AutoValue_MethodRef(
Opcodes.INVOKESTATIC,
owner,
method,
method.getReturnType(),
ImmutableList.<Type>builder().add(method.getArgumentTypes()).build(),
Features.of());
}
代码示例来源:origin: google/closure-templates
public static MethodRef createInstanceMethod(TypeInfo owner, Method method) {
return new AutoValue_MethodRef(
Opcodes.INVOKEVIRTUAL,
owner,
method,
method.getReturnType(),
ImmutableList.<Type>builder().add(owner.type()).add(method.getArgumentTypes()).build(),
Features.of());
}
代码示例来源:origin: com.google.template/soy
public static MethodRef createInstanceMethod(TypeInfo owner, Method method) {
return new AutoValue_MethodRef(
Opcodes.INVOKEVIRTUAL,
owner,
method,
method.getReturnType(),
ImmutableList.<Type>builder().add(owner.type()).add(method.getArgumentTypes()).build(),
Features.of());
}
代码示例来源: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()));
}
代码示例来源:origin: com.vaadin.external.gwt/gwt-user
/**
* Produce a rebased method declaration, also visiting referenced types.
*/
private Method processMethod(String sourceType, String name, String desc) {
Method method = new Method(name, desc);
Type[] argumentTypes = method.getArgumentTypes();
for (int i = 0, j = argumentTypes.length; i < j; i++) {
argumentTypes[i] = processType(sourceType, argumentTypes[i]);
}
method = new Method(name, processType(sourceType, method.getReturnType()), argumentTypes);
return method;
}
代码示例来源:origin: net.wetheinter/gwt-user
/**
* Produce a rebased method declaration, also visiting referenced types.
*/
private Method processMethod(String sourceType, String name, String desc) {
Method method = new Method(name, desc);
Type[] argumentTypes = method.getArgumentTypes();
for (int i = 0, j = argumentTypes.length; i < j; i++) {
argumentTypes[i] = processType(sourceType, argumentTypes[i]);
}
method = new Method(name, processType(sourceType, method.getReturnType()), argumentTypes);
return method;
}
内容来源于网络,如有侵权,请联系作者删除!