本文整理了Java中org.objectweb.asm.Type.getClassName()
方法的一些代码示例,展示了Type.getClassName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Type.getClassName()
方法的具体详情如下:
包路径:org.objectweb.asm.Type
类名称:Type
方法名:getClassName
[英]Returns the binary name of the class corresponding to this type. This method must not be used on method types.
[中]返回与此类型对应的类的二进制名称。此方法不能用于方法类型。
代码示例来源:origin: robolectric/robolectric
private static String normalize(Type type) {
return type.getClassName().replace('$', '.');
}
代码示例来源:origin: simpligility/android-maven-plugin
@Override
public void visit( String name, Object value )
{
if ( value instanceof Type )
{
if ( ( ( Type ) value ).getClassName().contains( "AndroidJUnit4" ) )
{
flagAsFound();
}
}
}
代码示例来源: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: robolectric/robolectric
public static MethodSignature parse(String internalString) {
int parenStart = internalString.indexOf('(');
int methodStart = internalString.lastIndexOf('/', parenStart);
String className = internalString.substring(0, methodStart).replace('/', '.');
String methodName = internalString.substring(methodStart + 1, parenStart);
String methodDescriptor = internalString.substring(parenStart);
Type[] argumentTypes = Type.getArgumentTypes(methodDescriptor);
String[] paramTypes = new String[argumentTypes.length];
for (int i = 0; i < argumentTypes.length; i++) {
paramTypes[i] = argumentTypes[i].getClassName();
}
final String returnType = Type.getReturnType(methodDescriptor).getClassName();
return new MethodSignature(className, methodName, paramTypes, returnType);
}
代码示例来源:origin: cglib/cglib
public String toString() {
// TODO: include modifiers, superType, interfaces
return getType().getClassName();
}
}
代码示例来源:origin: cglib/cglib
FieldInfo getFieldInfo(String name) {
FieldInfo field = (FieldInfo)fieldInfo.get(name);
if (field == null) {
throw new IllegalArgumentException("Field " + name + " is not declared in " + getClassType().getClassName());
}
return field;
}
代码示例来源:origin: jooby-project/jooby
public boolean matches(final Signature signature) {
if (this.owners.stream().filter(signature.owners::contains).findFirst().isPresent()) {
if (this.name == null || signature.name.equals(this.name)) {
if (this.args.length == signature.args.length) {
for (int i = 0; i < this.args.length; i++) {
if (!this.args[i].getClassName().equals(signature.args[i].getClassName())) {
//
return false;
}
}
return true;
}
}
}
return false;
}
代码示例来源:origin: micronaut-projects/micronaut-core
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
String className = Type.getType(desc).getClassName();
annotations.add(className);
return super.visitAnnotation(desc, visible);
}
代码示例来源:origin: cglib/cglib
FieldInfo getFieldInfo(String name) {
FieldInfo field = (FieldInfo)fieldInfo.get(name);
if (field == null) {
throw new IllegalArgumentException("Field " + name + " is not declared in " + getClassType().getClassName());
}
return field;
}
代码示例来源:origin: cglib/cglib
public String toString() {
// TODO: include modifiers, superType, interfaces
return getType().getClassName();
}
}
代码示例来源:origin: alibaba/jvm-sandbox
private String getBehaviorSignCode(final String name,
final String desc) {
final Type methodType = Type.getMethodType(desc);
final Collection<String> parameterClassNameArray = new ArrayList<String>();
if (null != methodType.getArgumentTypes()) {
for (final Type parameterType : methodType.getArgumentTypes()) {
parameterClassNameArray.add(parameterType.getClassName());
}
}
final String signCode = String.format(
"%s#%s(%s)",
targetJavaClassName,
name,
join(parameterClassNameArray, ",")
);
return signCode;
}
代码示例来源:origin: pxb1988/dex2jar
Class<?> toJavaType(Type t) throws ClassNotFoundException {
switch (t.getSort()) {
case Type.BOOLEAN:
return boolean.class;
case Type.BYTE:
return byte.class;
case Type.SHORT:
return short.class;
case Type.CHAR:
return char.class;
case Type.INT:
return int.class;
case Type.FLOAT:
return float.class;
case Type.LONG:
return long.class;
case Type.DOUBLE:
return double.class;
case Type.OBJECT:
return Class.forName(t.getClassName());
case Type.ARRAY:
return Class.forName(t.getDescriptor());
case Type.VOID:
return void.class;
}
throw new RuntimeException();
}
}
代码示例来源:origin: robolectric/robolectric
/**
* Intercepts the method using the invokedynamic bytecode instruction available in Java 7+.
* Should be called through interceptInvokeVirtualMethod, not directly.
*/
private void interceptInvokeVirtualMethodWithInvokeDynamic(
ListIterator<AbstractInsnNode> instructions, MethodInsnNode targetMethod) {
instructions.remove(); // remove the method invocation
Type type = Type.getObjectType(targetMethod.owner);
String description = targetMethod.desc;
String owner = type.getClassName();
if (targetMethod.getOpcode() != Opcodes.INVOKESTATIC) {
String thisType = type.getDescriptor();
description = "(" + thisType + description.substring(1);
}
instructions.add(new InvokeDynamicInsnNode(targetMethod.name, description, BOOTSTRAP_INTRINSIC, owner));
}
}
代码示例来源:origin: dcevm/dcevm
@Override
public void visitEnum(String name, String enumDesc, String value) {
if (Type.getType(enumDesc).getClassName().equals(RedefinitionPolicy.class.getName())) {
RedefinitionPolicy valueAsEnum = RedefinitionPolicy.valueOf(value);
if (Type.getType(desc).getClassName().equals(FieldRedefinitionPolicy.class.getName())) {
cv.visitAttribute(new SingleByteAttribute(FieldRedefinitionPolicy.class.getSimpleName(), (byte) valueAsEnum.ordinal()));
}
if (Type.getType(desc).getClassName().equals(MethodRedefinitionPolicy.class.getName())) {
cv.visitAttribute(new SingleByteAttribute(MethodRedefinitionPolicy.class.getSimpleName(), (byte) valueAsEnum.ordinal()));
}
}
super.visitEnum(name, desc, value);
}
};
代码示例来源:origin: Meituan-Dianping/Robust
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (isProtect(access)) {
access = setPublic(access);
}
MethodVisitor mv = super.visitMethod(access, name,
desc, signature, exceptions);
if (!isQualifiedMethod(access, name, desc, methodInstructionTypeMap)) {
return mv;
}
StringBuilder parameters = new StringBuilder();
Type[] types = Type.getArgumentTypes(desc);
for (Type type : types) {
parameters.append(type.getClassName()).append(",");
}
//remove the last ","
if (parameters.length() > 0 && parameters.charAt(parameters.length() - 1) == ',') {
parameters.deleteCharAt(parameters.length() - 1);
}
//record method number
methodMap.put(className.replace('/', '.') + "." + name + "(" + parameters.toString() + ")", insertMethodCount.incrementAndGet());
return new MethodBodyInsertor(mv, className, desc, isStatic(access), String.valueOf(insertMethodCount.get()), name, access);
}
代码示例来源:origin: cglib/cglib
public static String getClassName(Type type) {
if (isPrimitive(type)) {
return (String)rtransforms.get(type.getDescriptor());
} else if (isArray(type)) {
return getClassName(getComponentType(type)) + "[]";
} else {
return type.getClassName();
}
}
代码示例来源:origin: cglib/cglib
public static String getClassName(Type type) {
if (isPrimitive(type)) {
return (String)rtransforms.get(type.getDescriptor());
} else if (isArray(type)) {
return getClassName(getComponentType(type)) + "[]";
} else {
return type.getClassName();
}
}
代码示例来源:origin: pmd/pmd
private void addType(Type t) {
switch (t.getSort()) {
case Type.ARRAY:
addType(t.getElementType());
break;
case Type.OBJECT:
parseClassName(t.getClassName().replace('.', '/'));
break;
default:
// Do nothing
break;
}
}
代码示例来源:origin: spring-projects/spring-loaded
private void chooseMethodSignature() throws Exception {
methodSignature = choice(getMethodSignatures());
int splitAt = methodSignature.indexOf('(');
methodName = methodSignature.substring(0, splitAt);
String methodDescriptor = methodSignature.substring(splitAt);
Type[] asmTypes = Type.getArgumentTypes(methodDescriptor);
params = new Class<?>[asmTypes.length];
//Get the corresponding class for each param type name
for (int i = 0; i < asmTypes.length; i++) {
params[i] = classForName(asmTypes[i].getClassName());
}
}
代码示例来源:origin: spring-projects/spring-loaded
private void chooseMethodSignature() throws Exception {
methodDescriptor = choice(getMethodSignatures());
Type[] asmTypes = Type.getArgumentTypes(methodDescriptor);
params = new Class<?>[asmTypes.length];
//Get the corresponding class for each param type name
for (int i = 0; i < asmTypes.length; i++) {
params[i] = classForName(asmTypes[i].getClassName());
}
}
内容来源于网络,如有侵权,请联系作者删除!