本文整理汇总了Java中net.bytebuddy.description.method.MethodDescription.ForLoadedMethod方法的典型用法代码示例。如果您正苦于以下问题:Java MethodDescription.ForLoadedMethod方法的具体用法?Java MethodDescription.ForLoadedMethod怎么用?Java MethodDescription.ForLoadedMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.bytebuddy.description.method.MethodDescription
的用法示例。
在下文中一共展示了MethodDescription.ForLoadedMethod方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: UserCodeMethodInvocation
import net.bytebuddy.description.method.MethodDescription; //导入方法依赖的package包/类
UserCodeMethodInvocation(
@Nullable Integer returnVarIndex,
MethodDescription targetMethod,
MethodDescription instrumentedMethod) {
this.returnVarIndex = returnVarIndex;
this.targetMethod = targetMethod;
this.instrumentedMethod = instrumentedMethod;
this.returnType = targetMethod.getReturnType().asErasure();
boolean targetMethodReturnsVoid = TypeDescription.VOID.equals(returnType);
checkArgument(
(returnVarIndex == null) == targetMethodReturnsVoid,
"returnVarIndex should be defined if and only if the target method has a return value");
try {
createUserCodeException =
new MethodDescription.ForLoadedMethod(
UserCodeException.class.getDeclaredMethod("wrap", Throwable.class));
} catch (NoSuchMethodException | SecurityException e) {
throw new RuntimeException("Unable to find UserCodeException.wrap", e);
}
}
示例2: getEnumDescriptor
import net.bytebuddy.description.method.MethodDescription; //导入方法依赖的package包/类
/**
* Returns a {@link StackManipulation} that returns the {@link
* com.google.protobuf.Descriptors.EnumDescriptor} for the given enum field.
*/
static StackManipulation getEnumDescriptor(ProtoFieldInfo info) {
Class<?> clz = info.enumClass();
final MethodDescription.ForLoadedMethod getDescriptor;
try {
getDescriptor = new MethodDescription.ForLoadedMethod(clz.getDeclaredMethod("getDescriptor"));
} catch (NoSuchMethodException e) {
throw new IllegalStateException("Not an enum class: " + clz, e);
}
return MethodInvocation.invoke(getDescriptor);
}
示例3: getExtraContextFactoryMethodDescription
import net.bytebuddy.description.method.MethodDescription; //导入方法依赖的package包/类
/**
* This wrapper exists to convert checked exceptions to unchecked exceptions, since if this fails
* the library itself is malformed.
*/
private static MethodDescription getExtraContextFactoryMethodDescription(
String methodName, Class<?>... parameterTypes) {
try {
return new MethodDescription.ForLoadedMethod(
DoFnInvoker.ArgumentProvider.class.getMethod(methodName, parameterTypes));
} catch (Exception e) {
throw new IllegalStateException(
String.format(
"Failed to locate required method %s.%s",
DoFnInvoker.ArgumentProvider.class.getSimpleName(), methodName),
e);
}
}
示例4: DoFnMethodDelegation
import net.bytebuddy.description.method.MethodDescription; //导入方法依赖的package包/类
public DoFnMethodDelegation(TypeDescription doFnType, Method targetMethod) {
this.doFnType = doFnType;
this.targetMethod = new MethodDescription.ForLoadedMethod(targetMethod);
targetHasReturn = !TypeDescription.VOID.equals(this.targetMethod.getReturnType().asErasure());
}