本文整理匯總了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);
}