本文整理了Java中org.objectweb.asm.Type.getDescriptor()
方法的一些代码示例,展示了Type.getDescriptor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Type.getDescriptor()
方法的具体详情如下:
包路径:org.objectweb.asm.Type
类名称:Type
方法名:getDescriptor
[英]Returns the descriptor corresponding to this Java type.
[中]返回与此Java类型对应的描述符。
代码示例来源:origin: cglib/cglib
void emit_field(int opcode, Type ctype, String name, Type ftype) {
mv.visitFieldInsn(opcode,
ctype.getInternalName(),
name,
ftype.getDescriptor());
}
代码示例来源:origin: JCTools/JCTools
private static int parameterTypeUnsafe(MethodVisitor methodVisitor, Class<?> parameterType, boolean write) {
parameterType = parameterType.isPrimitive() ? parameterType : Object.class;
Type type = Type.getType(parameterType);
String boolDescriptor = parameterType == boolean.class ? "Ljava/lang/Object;" : "";
methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
Type.getInternalName(Unsafe.class),
(write ? "put" : "get") + Character.toUpperCase(type.getClassName().charAt(0)) + type.getClassName().substring(1),
write ? ("(" + boolDescriptor + "J" + type.getDescriptor() + ")V") : ("(" + boolDescriptor + "J)" + type.getDescriptor()),
false);
return type.getSize();
}
代码示例来源:origin: cglib/cglib
public static Type getComponentType(Type type) {
if (!isArray(type)) {
throw new IllegalArgumentException("Type " + type + " is not an array");
}
return Type.getType(type.getDescriptor().substring(1));
}
代码示例来源:origin: cglib/cglib
void emit_field(int opcode, Type ctype, String name, Type ftype) {
mv.visitFieldInsn(opcode,
ctype.getInternalName(),
name,
ftype.getDescriptor());
}
代码示例来源:origin: cglib/cglib
public static Type getComponentType(Type type) {
if (!isArray(type)) {
throw new IllegalArgumentException("Type " + type + " is not an array");
}
return Type.getType(type.getDescriptor().substring(1));
}
代码示例来源:origin: robolectric/robolectric
private String remapParamType(Type type) {
String remappedName;
String internalName;
switch (type.getSort()) {
case ARRAY:
internalName = type.getInternalName();
int count = 0;
while (internalName.charAt(count) == '[') count++;
remappedName = remapParamType(internalName.substring(count));
if (remappedName != null) {
return Type.getObjectType(internalName.substring(0, count) + remappedName).getDescriptor();
}
break;
case OBJECT:
type = mappedType(type);
break;
default:
break;
}
return type.getDescriptor();
}
}
代码示例来源:origin: cglib/cglib
private void emit_type(int opcode, Type type) {
String desc;
if (TypeUtils.isArray(type)) {
desc = type.getDescriptor();
} else {
desc = type.getInternalName();
}
mv.visitTypeInsn(opcode, desc);
}
代码示例来源:origin: org.ow2.asm/asm
return getType(getDescriptor(clazz));
代码示例来源:origin: fengjiachun/Jupiter
Type p_type = Type.getType(parameterTypes[p_index]);
switch (p_type.getSort()) {
case Type.BOOLEAN:
break;
case Type.ARRAY:
mv.visitTypeInsn(CHECKCAST, p_type.getDescriptor());
break;
case Type.OBJECT:
mv.visitTypeInsn(CHECKCAST, p_type.getInternalName());
break;
buf.append(p_type.getDescriptor());
buf.append(')').append(Type.getDescriptor(returnType));
Type r_type = Type.getType(returnType);
switch (r_type.getSort()) {
case Type.VOID:
代码示例来源:origin: JCTools/JCTools
private static void writeAcquireWithWaitStrategy(MethodVisitor methodVisitor, String generatedName, Class<? extends ProxyChannelRingBuffer> backendType) {
// One of these is for the getfield bytecode, the other is as the first arg to the writeAcquireWithWaitStrategy
methodVisitor.visitVarInsn(Opcodes.ALOAD, LOCALS_INDEX_THIS);
methodVisitor.visitVarInsn(Opcodes.ALOAD, LOCALS_INDEX_THIS);
methodVisitor.visitFieldInsn(Opcodes.GETFIELD, generatedName, "waitStrategy", Type.getDescriptor(WaitStrategy.class));
methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC,
Type.getInternalName(ProxyChannelFactory.class),
"writeAcquireWithWaitStrategy",
methodDescriptor(long.class, ProxyChannelRingBuffer.class, WaitStrategy.class),
false);
}
代码示例来源:origin: Meituan-Dianping/Robust
false);
int local = mv.newLocal(Type.getType("Lcom/meituan/robust/PatchProxyResult;"));
mv.storeLocal(local);
mv.loadLocal(local);
if ("V".equals(returnType.getDescriptor())) {
mv.visitInsn(Opcodes.RETURN);
} else {
mv.visitFieldInsn(Opcodes.GETFIELD, "com/meituan/robust/PatchProxyResult", "result", "Ljava/lang/Object;");
if (!castPrimateToObj(mv, returnType.getDescriptor())) {
int len = returnType.getDescriptor().length();
if (returnType.getDescriptor().startsWith("[")) {
newTypeStr = returnType.getDescriptor().substring(0, len);
} else {
newTypeStr = returnType.getDescriptor().substring(1, len - 1);
mv.visitInsn(getReturnTypeCode(returnType.getDescriptor()));
代码示例来源:origin: fengjiachun/Jupiter
Type p_type = Type.getType(parameterTypes[p_index]);
switch (p_type.getSort()) {
case Type.BOOLEAN:
break;
case Type.ARRAY:
mv.visitTypeInsn(CHECKCAST, p_type.getDescriptor());
break;
case Type.OBJECT:
mv.visitTypeInsn(CHECKCAST, p_type.getInternalName());
break;
buf.append(p_type.getDescriptor());
buf.append(')').append(Type.getDescriptor(returnType));
Type r_type = Type.getType(returnType);
switch (r_type.getSort()) {
case Type.VOID:
代码示例来源:origin: cglib/cglib
private void emit_type(int opcode, Type type) {
String desc;
if (TypeUtils.isArray(type)) {
desc = type.getDescriptor();
} else {
desc = type.getInternalName();
}
mv.visitTypeInsn(opcode, desc);
}
代码示例来源:origin: robolectric/robolectric
void write() {
// write our field to hold target field reference (but just once)...
if (fieldRefs.add(targetFieldName)) {
visitField(ACC_PRIVATE | ACC_STATIC, fieldRefName, FIELD_TYPE.getDescriptor(), null, null);
}
visitCode();
if (isSetter) {
// pseudocode:
// field_x.set(this, arg0);
loadFieldRef();
loadTarget();
loadArg(0);
Class<?> parameterType = iMethod.getParameterTypes()[0];
if (parameterType.isPrimitive()) {
box(Type.getType(parameterType));
}
invokeVirtual(FIELD_TYPE, FIELD$SET);
returnValue();
} else { // getter
// pseudocode:
// return field_x.get(this);
loadFieldRef();
loadTarget();
invokeVirtual(FIELD_TYPE, FIELD$GET);
castForReturn(iMethod.getReturnType());
returnValue();
}
endMethod();
}
代码示例来源:origin: robolectric/robolectric
<T> Factory createProxyFactory(Class<T> targetClass) {
Type targetType = Type.getType(targetClass);
String targetName = targetType.getInternalName();
String proxyName = targetName + "$GeneratedProxy";
Type proxyType = Type.getType("L" + proxyName.replace('.', '/') + ";");
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES| ClassWriter.COMPUTE_MAXS);
writer.visit(V1_7, ACC_PUBLIC | ACC_SUPER | ACC_FINAL, proxyName, null, targetName, null);
writer.visitField(ACC_PUBLIC, TARGET_FIELD, targetType.getDescriptor(), null, null);
代码示例来源:origin: alibaba/jvm-sandbox
final protected void visitFieldInsn(int opcode, Type owner, String name, Type type) {
super.visitFieldInsn(opcode, owner.getInternalName(), name, type.getDescriptor());
}
代码示例来源:origin: Meituan-Dianping/Robust
switch (arg.getDescriptor()) {
case "Z":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Boolean", "TYPE", "Ljava/lang/Class;");
break;
default:
mv.visitLdcInsn(Type.getType(arg.getDescriptor()));
代码示例来源:origin: JCTools/JCTools
Type.getInternalName(iFace),
method.getName(),
Type.getMethodDescriptor(method),
methodVisitor.visitLocalVariable("impl", Type.getType(iFace).getDescriptor(), null, localScopeStart, localScopeEnd, localIndexOfImpl);
methodVisitor.visitLocalVariable("limit", Type.getType(int.class).getDescriptor(), null, localScopeStart, localScopeEnd, localIndexOfLimit);
methodVisitor.visitLocalVariable("loopIndex", Type.getType(int.class).getDescriptor(), null, localScopeStart, localScopeEnd, localIndexOfLoopIndex);
methodVisitor.visitLocalVariable("rOffset", Type.getType(long.class).getDescriptor(), null, localScopeStart, localScopeEnd, localIndexOfROffset);
methodVisitor.visitLocalVariable("typeId", Type.getType(int.class).getDescriptor(), null, localScopeStart, localScopeEnd, localIndexOfTypeId);
代码示例来源:origin: micronaut-projects/micronaut-core
@Override
protected void startClass(ClassVisitor classWriter, String className, Type superType) {
String[] interfaces = getImplementedInterfaceInternalNames();
classWriter.visit(V1_8, ACC_PUBLIC, className, null, !isInterface ? superType.getInternalName() : null, interfaces);
classWriter.visitField(ACC_FINAL | ACC_PRIVATE, FIELD_INTERCEPTORS, FIELD_TYPE_INTERCEPTORS.getDescriptor(), null, null);
classWriter.visitField(ACC_FINAL | ACC_PRIVATE, FIELD_PROXY_METHODS, FIELD_TYPE_PROXY_METHODS.getDescriptor(), null, null);
}
代码示例来源:origin: pxb1988/dex2jar
int sort = type.getSort();
if (sort == Type.OBJECT || sort == Type.ARRAY) {
return b(1, Exprs.nType(type.getDescriptor()));
} else if (sort == Type.METHOD) {
throw new UnsupportedOperationException("Not supported yet.");
case GETSTATIC:
FieldInsnNode fin = (FieldInsnNode) insn;
return b(Type.getType(fin.desc).getSize(), Exprs.nStaticField("L" + fin.owner + ";", fin.name,
fin.desc));
case NEW:
内容来源于网络,如有侵权,请联系作者删除!