本文整理了Java中org.objectweb.asm.Type.getType()
方法的一些代码示例,展示了Type.getType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Type.getType()
方法的具体详情如下:
包路径:org.objectweb.asm.Type
类名称:Type
方法名:getType
[英]Returns the Java type corresponding to the given class.
[中]返回与给定类对应的Java类型。
代码示例来源:origin: pxb1988/dex2jar
protected static String toInternalName(String desc) {
// TODO without creating object
return Type.getType(desc).getInternalName();
}
代码示例来源: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: 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: pxb1988/dex2jar
static String toInternal(String n) {
// TODO replace
return Type.getType(n).getInternalName();
}
代码示例来源: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: robolectric/robolectric
private static String[] getInternalNames(final Class<?>[] types) {
if (types == null) {
return null;
}
String[] names = new String[types.length];
for (int i = 0; i < names.length; ++i) {
names[i] = Type.getType(types[i]).getInternalName();
}
return names;
}
代码示例来源:origin: org.ow2.asm/asm
return getType(getDescriptor(clazz));
代码示例来源: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: JCTools/JCTools
for (Class<?> parameterType : parameterTypes) {
int localIndexOfParameter = locals.newLocal(parameterType);
int loadOpCode = Type.getType(parameterType).getOpcode(Opcodes.ILOAD);
methodVisitor.visitVarInsn(loadOpCode, localIndexOfParameter);
methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, Type.getInternalName(parameterType));
methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, Type.getInternalName(returnType));
int returnOpcode = Type.getType(returnType).getOpcode(Opcodes.IRETURN);
methodVisitor.visitInsn(returnOpcode);
代码示例来源: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);
代码示例来源: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
public void begin_class(int version, final int access, String className, final Type superType, final Type[] interfaces, String source) {
final Type classType = Type.getType("L" + className.replace('.', '/') + ";");
classInfo = new ClassInfo() {
public Type getType() {
return classType;
}
public Type getSuperType() {
return (superType != null) ? superType : Constants.TYPE_OBJECT;
}
public Type[] getInterfaces() {
return interfaces;
}
public int getModifiers() {
return access;
}
};
cv.visit(version,
access,
classInfo.getType().getInternalName(),
null,
classInfo.getSuperType().getInternalName(),
TypeUtils.toInternalNames(interfaces));
if (source != null)
cv.visitSource(source, null);
init();
}
代码示例来源: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: 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
public void begin_class(int version, final int access, String className, final Type superType, final Type[] interfaces, String source) {
final Type classType = Type.getType("L" + className.replace('.', '/') + ";");
classInfo = new ClassInfo() {
public Type getType() {
return classType;
}
public Type getSuperType() {
return (superType != null) ? superType : Constants.TYPE_OBJECT;
}
public Type[] getInterfaces() {
return interfaces;
}
public int getModifiers() {
return access;
}
};
cv.visit(version,
access,
classInfo.getType().getInternalName(),
null,
classInfo.getSuperType().getInternalName(),
TypeUtils.toInternalNames(interfaces));
if (source != null)
cv.visitSource(source, null);
init();
}
代码示例来源: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: JCTools/JCTools
int index = 0;
for (Class<?> exceptionType : method.getExceptionTypes()) {
exceptions[index++] = Type.getInternalName(exceptionType);
varOffset,
backendType);
varOffset += Type.getType(parameterType).getSize();
arrayReferenceBaseIndexDelta++;
代码示例来源: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:
内容来源于网络,如有侵权,请联系作者删除!