本文整理汇总了Java中net.bytebuddy.jar.asm.Type类的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于net.bytebuddy.jar.asm包,在下文中一共展示了Type类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: describeType
import net.bytebuddy.jar.asm.Type; //导入依赖的package包/类
private Object describeType(Type type) {
switch (type.getSort()) {
case Type.OBJECT:
return type.getInternalName();
case Type.INT:
case Type.BYTE:
case Type.BOOLEAN:
case Type.SHORT:
return Opcodes.INTEGER;
case Type.LONG:
return Opcodes.LONG;
case Type.DOUBLE:
return Opcodes.DOUBLE;
case Type.FLOAT:
return Opcodes.FLOAT;
default:
throw new IllegalArgumentException("Unhandled type as method argument: " + type);
}
}
示例2: visitFrame
import net.bytebuddy.jar.asm.Type; //导入依赖的package包/类
private void visitFrame(
MethodVisitor mv, boolean localsIncludeReturn, @Nullable String stackTop) {
boolean hasReturnLocal = (returnVarIndex != null) && localsIncludeReturn;
Type[] localTypes = Type.getArgumentTypes(instrumentedMethod.getDescriptor());
Object[] locals = new Object[1 + localTypes.length + (hasReturnLocal ? 1 : 0)];
locals[0] = instrumentedMethod.getReceiverType().asErasure().getInternalName();
for (int i = 0; i < localTypes.length; i++) {
locals[i + 1] = describeType(localTypes[i]);
}
if (hasReturnLocal) {
locals[locals.length - 1] = returnType.getInternalName();
}
Object[] stack = stackTop == null ? new Object[] {} : new Object[] {stackTop};
mv.visitFrame(Opcodes.F_NEW, locals.length, locals, stack.length, stack);
}
示例3: apply
import net.bytebuddy.jar.asm.Type; //导入依赖的package包/类
@Override
public ByteCodeAppender.Size apply(MethodVisitor mv, Implementation.Context implementationContext, MethodDescription instrumentedMethod) {
mv.visitVarInsn(ALOAD, 0);
if (!isStatic) {
mv.visitFieldInsn(GETFIELD, thisClass, "instance", "Ljava/lang/Object;");
mv.visitTypeInsn(CHECKCAST, listenerClass);
}
mv.visitVarInsn(ALOAD, 1);
mv.visitTypeInsn(CHECKCAST, eventClass);
mv.visitMethodInsn(isStatic ? INVOKESTATIC : INVOKEVIRTUAL, listenerClass, callback.getName(), Type.getMethodDescriptor(callback), false);
mv.visitInsn(RETURN);
mv.visitMaxs(2, 2);
return new Size(2, 2);
}