本文整理匯總了Java中org.objectweb.asm.Type.getDescriptor方法的典型用法代碼示例。如果您正苦於以下問題:Java Type.getDescriptor方法的具體用法?Java Type.getDescriptor怎麽用?Java Type.getDescriptor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.objectweb.asm.Type
的用法示例。
在下文中一共展示了Type.getDescriptor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visitEnd
import org.objectweb.asm.Type; //導入方法依賴的package包/類
public void visitEnd() {
if (! doneAddField) {
doneAddField = true;
super.visitField(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, CLASS_FIELD, Type.getDescriptor(Agent.class), null, null);
}
if (! doneAddMethod) {
doneAddMethod = true;
GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, new Method(LOG_CLASS_METHOD, LOG_CLASS_SIGNATURE), LOG_CLASS_SIGNATURE, new Type[] {}, this);
Label target = mg.newLabel();
mg.getStatic(JAVA_LANG_SYSTEM_TYPE, CLASS_FIELD, JAVA_LANG_CLASS_TYPE);
mg.ifNull(target);
mg.push(LOG_INTERNAL_TYPE);
mg.putStatic(JAVA_LANG_SYSTEM_TYPE, CLASS_FIELD, JAVA_LANG_CLASS_TYPE);
mg.mark(target);
mg.getStatic(JAVA_LANG_SYSTEM_TYPE, CLASS_FIELD, JAVA_LANG_CLASS_TYPE);
mg.returnValue();
}
super.visitEnd();
}
示例2: translateTypes
import org.objectweb.asm.Type; //導入方法依賴的package包/類
private Type[] translateTypes(Map<String, String> mapIn, Type... types) {
int index = 0;
Type[] translated = new Type[types.length];
for(Type arg : types) {
switch (arg.getSort()) {
case Type.ARRAY:
// ignore primitive arrays
if(arg.getElementType().getSort() != Type.OBJECT) break;
case Type.OBJECT:
String desc = arg.getDescriptor();
String heading = desc.substring(0, desc.indexOf('L') + 1);
String name = desc.substring(heading.length(), desc.indexOf(';'));
String newName = mapIn.get(name);
arg = Type.getType(heading + (!Strings.isNullOrEmpty(newName) ? newName : name) + ";");
break;
default:
break;
}
translated[index++] = arg;
}
return translated;
}
示例3: addAnnotationTree
import org.objectweb.asm.Type; //導入方法依賴的package包/類
private static void addAnnotationTree(AnnotationVisitor av0, Annotation ann,
Class<? extends Annotation> annotationType)
throws IllegalAccessException, InvocationTargetException {
Method[] annMethods = annotationType.getDeclaredMethods();
for (Method m : annMethods) {
Class<?> returnType = m.getReturnType();
if (returnType.isArray()) {
Class<?> compType = returnType.getComponentType();
String compDesc = Type.getDescriptor(compType);
AnnotationVisitor avArray = av0.visitArray(m.getName());
Object[] arr = (Object[]) m.invoke(ann);
for (Object comp : arr) {
addAnnotation(null, compType, compDesc, avArray, comp);
}
avArray.visitEnd();
} else {
addAnnotation(m.getName(), returnType, Type.getDescriptor(returnType), av0, m.invoke(ann));
}
}
}
示例4: compile
import org.objectweb.asm.Type; //導入方法依賴的package包/類
public byte[] compile(String className, Class<?> clazz) throws IOException, CompilerException {
ClassWriter cw = new ClassWriter(0);
Type clazzType = Type.getType(clazz);
String internalName = className.replace('.', '/');
String classDesc = "L" + internalName + ";";
String signature = BytecodeGenerator.OBJECT.getDescriptor() + "L" +
BytecodeGenerator.OBJECT_TEMPLATE.getInternalName() + "<" + clazzType.getDescriptor() + ">;";
cw.visit(52, ACC_PUBLIC + ACC_SUPER, internalName, signature,
BytecodeGenerator.OBJECT.getInternalName(),
new String[]{BytecodeGenerator.OBJECT_TEMPLATE.getInternalName()});
cw.visitSource(templateName, null);
createConstructor(cw, classDesc);
createObjectRender(cw, internalName, classDesc, clazzType);
DataManager getter = new ClassDataManager(clazz, clazzType);
generator = new BytecodeGenerator(this, cw, getter, internalName, classDesc);
generator.insertMethodStart("render");
parser.parse();
generator.insertMethodEnd();
cw.visitEnd();
return cw.toByteArray();
}
示例5: getShortyDescriptor
import org.objectweb.asm.Type; //導入方法依賴的package包/類
private static String getShortyDescriptor(Type type) {
switch (type.getSort()) {
case Type.METHOD:
throw new InternalCompilerError("Cannot produce a shorty decriptor for methods");
case Type.ARRAY:
case Type.OBJECT:
return "L";
default:
return type.getDescriptor();
}
}
示例6: loadBoxedBoolean
import org.objectweb.asm.Type; //導入方法依賴的package包/類
public static AbstractInsnNode loadBoxedBoolean(boolean value) {
return new FieldInsnNode(
GETSTATIC,
Type.getInternalName(Boolean.class),
value ? "TRUE" : "FALSE",
Type.getDescriptor(Boolean.class));
}
示例7: redirectLocal
import org.objectweb.asm.Type; //導入方法依賴的package包/類
/**
* Pushes in the stack the value that should be redirected for the given local.
*/
protected static void redirectLocal(GeneratorAdapter mv, Type arg) {
switch (arg.getDescriptor()) {
case "Z":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Boolean", "TYPE", "Ljava/lang/Class;");
break;
case "B":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Byte", "TYPE", "Ljava/lang/Class;");
break;
case "C":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Character", "TYPE", "Ljava/lang/Class;");
break;
case "S":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Short", "TYPE", "Ljava/lang/Class;");
break;
case "I":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Integer", "TYPE", "Ljava/lang/Class;");
break;
case "F":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Float", "TYPE", "Ljava/lang/Class;");
break;
case "D":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Double", "TYPE", "Ljava/lang/Class;");
break;
case "J":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Long", "TYPE", "Ljava/lang/Class;");
break;
case "V":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Void", "TYPE", "Ljava/lang/Class;");
break;
default:
mv.visitLdcInsn(Type.getType(arg.getDescriptor()));
}
}
示例8: generateMethodArgsUpdater
import org.objectweb.asm.Type; //導入方法依賴的package包/類
public static byte[] generateMethodArgsUpdater(Class<?> classToProxy, Method method, int methodId) throws Exception {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
String classToProxyDescriptor = Type.getDescriptor(classToProxy);
String classToProxyInternalName = Type.getInternalName(classToProxy);
String suffix = SUFFIX_START + method.getName() + methodId;
String selfClassInternalName = classToProxyInternalName + suffix;
String selfClassDescriptor = BytecodeGenUtils.makeSuffixClassDescriptor(classToProxyDescriptor, suffix);
String argsClassInternalName = classToProxyInternalName + MethodArgumentsGenerator.SUFFIX_START + method.getName() + methodId;
String constDesc = Type.getMethodDescriptor(Type.VOID_TYPE,
Stream.concat(Stream.of(List.class), Stream.of(method.getParameterTypes())).map(Type::getType)
.toArray(Type[]::new));
cw.visit(52, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, selfClassInternalName, null, "java/lang/Object",
new String[] { "io/primeval/reflex/arguments/ArgumentsUpdater" });
Parameter[] parameters = method.getParameters();
generateFields(method, cw, parameters);
generateConstructor(method, cw, selfClassInternalName, selfClassDescriptor, constDesc, parameters);
generateHashCodeMethod(cw, selfClassInternalName, selfClassDescriptor, parameters);
generateEqualsMethod(cw, selfClassInternalName, selfClassDescriptor, parameters);
generateToStringMethod(cw, selfClassInternalName, selfClassDescriptor, parameters);
generateUpdateMethod(cw, selfClassInternalName, selfClassDescriptor, argsClassInternalName, constDesc, parameters);
generateParametersGetter(cw, selfClassInternalName, selfClassDescriptor);
generateArgumentSetters(cw, selfClassInternalName, selfClassDescriptor, parameters);
generateArgumentGetters(cw, selfClassInternalName, selfClassDescriptor, parameters);
cw.visitEnd();
return cw.toByteArray();
}
示例9: generateMethodArgs
import org.objectweb.asm.Type; //導入方法依賴的package包/類
public static byte[] generateMethodArgs(Class<?> classToProxy, Method method, int methodId) throws Exception {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
String classToProxyDescriptor = Type.getDescriptor(classToProxy);
String classToProxyInternalName = Type.getInternalName(classToProxy);
String suffix = SUFFIX_START + method.getName() + methodId;
String selfClassInternalName = classToProxyInternalName + suffix;
String selfClassDescriptor = BytecodeGenUtils.makeSuffixClassDescriptor(classToProxyDescriptor, suffix);
String updaterClassInternalName = classToProxyInternalName + MethodArgumentssUpdaterGenerator.SUFFIX_START + method.getName() + methodId;
String constDesc = Type.getMethodDescriptor(Type.VOID_TYPE,
Stream.concat(Stream.of(List.class), Stream.of(method.getParameterTypes())).map(Type::getType)
.toArray(Type[]::new));
cw.visit(52, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, selfClassInternalName, null, "java/lang/Object",
new String[] { "io/primeval/reflex/arguments/Arguments" });
Parameter[] parameters = method.getParameters();
generateFields(method, cw, parameters);
generateConstructor(method, cw, selfClassInternalName, selfClassDescriptor, constDesc, parameters);
generateHashCodeMethod(cw, selfClassInternalName, selfClassDescriptor, parameters);
generateEqualsMethod(cw, selfClassInternalName, selfClassDescriptor, parameters);
generateToStringMethod(cw, selfClassInternalName, selfClassDescriptor, parameters);
generateUpdaterMethod(cw, selfClassInternalName, selfClassDescriptor, updaterClassInternalName, constDesc, parameters);
generateParametersGetter(cw, selfClassInternalName, selfClassDescriptor);
generateArgumentGetters(cw, selfClassInternalName, selfClassDescriptor, parameters);
cw.visitEnd();
return cw.toByteArray();
}
示例10: insertDefaultSectionStart
import org.objectweb.asm.Type; //導入方法依賴的package包/類
protected void insertDefaultSectionStart(String key, boolean inverted) throws CompilerException {
if(!builderLoaded && needLocal) {
mv.visitVarInsn(ALOAD, varBuilder);
builderLoaded = true;
}
if(data.getDataType() != DATA) {
throw new CompilerException("The default section generator can't be used within a custom data type");
}
String methodName = "lambda$render$" + compiler.getNextLambdaId();
mv.visitVarInsn(ALOAD, varData);
mv.visitLdcInsn(key);
Type methodType = Type.getMethodType(STRING, DATA);
Handle lambda = new Handle(H_INVOKESTATIC, "java/lang/invoke/LambdaMetafactory", "metafactory",
"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;"
+ "Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;", false);
Handle method = new Handle(H_INVOKESTATIC, className, methodName, methodType.getDescriptor(), false);
mv.visitInvokeDynamicInsn("render", Type.getMethodDescriptor(SIMPLE_TEMPLATE), lambda, methodType, method, methodType);
mv.visitInsn(inverted ? ICONST_1 : ICONST_0);
mv.visitMethodInsn(INVOKESTATIC, UTILS.getInternalName(), "renderSection", "(" + BUILDER.getDescriptor() +
DATA.getDescriptor() + STRING.getDescriptor() + SIMPLE_TEMPLATE.getDescriptor() +"Z)" + BUILDER.getDescriptor(), false);
BytecodeGenerator gen = new BytecodeGenerator(compiler, this, key, cw, data, className, classDesc);
compiler.setGenerator(gen);
gen.insertMethodStart(methodName);
}
示例11: getTypeStr
import org.objectweb.asm.Type; //導入方法依賴的package包/類
/**
* Converts a given type to a string. Output will be simplified if enabled
* in passed options.
*
* @param type
* The type object.
* @param options
* Options object.
* @return String representation of the type object.
* @see me.coley.recaf.config.UiConfig
*/
default String getTypeStr(Type type, ConfUI options) {
String s = type.getDescriptor();
// Check if field type. If so, then format as class name.
if (!s.contains("(") && (s.length() == 1 || s.startsWith("L") || s.startsWith("["))) {
s = type.getClassName();
}
// If simplification is on, substring away package.
if (options != null && options.opcodeSimplifyDescriptors && s.contains(".")) {
s = s.substring(s.lastIndexOf(".") + 1);
}
// Return name in internal style
return s.replace(".", "/");
}
示例12: getLoadInsn
import org.objectweb.asm.Type; //導入方法依賴的package包/類
static VarInsnNode getLoadInsn(Type type, int position) {
int opCode;
switch (type.getDescriptor().charAt(0)) {
case 'B':
opCode = Opcodes.ILOAD;
break;
case 'C':
opCode = Opcodes.ILOAD;
break;
case 'D':
opCode = Opcodes.DLOAD;
break;
case 'F':
opCode = Opcodes.FLOAD;
break;
case 'I':
opCode = Opcodes.ILOAD;
break;
case 'J':
opCode = Opcodes.LLOAD;
break;
case 'L':
opCode = Opcodes.ALOAD;
break;
case '[':
opCode = Opcodes.ALOAD;
break;
case 'Z':
opCode = Opcodes.ILOAD;
break;
case 'S':
opCode = Opcodes.ILOAD;
break;
default:
throw new ClassFormatError("Invalid method signature: "
+ type.getDescriptor());
}
return new VarInsnNode(opCode, position);
}
示例13: AssignableInfo
import org.objectweb.asm.Type; //導入方法依賴的package包/類
private AssignableInfo(
String name,
int memberIndex,
Class<?> type) {
super(name, memberIndex, Type.getDescriptor(type));
this.internalName = Type.getInternalName(type);
this.type = type;
}
示例14: forPrimitive
import org.objectweb.asm.Type; //導入方法依賴的package包/類
private static AccessInfo forPrimitive(String memberType, Type type) {
String camelCaseClassName = WordUtils.capitalize(type.getClassName());
String capitalizedMemberType = WordUtils.capitalize(memberType);
return new AccessInfo(
memberType,
"get" + camelCaseClassName + capitalizedMemberType,
"set" + camelCaseClassName + capitalizedMemberType,
type.getClassName(),
type.getDescriptor(),
type.getOpcode(ILOAD),
type.getOpcode(IRETURN));
}
示例15: getStoreInsn
import org.objectweb.asm.Type; //導入方法依賴的package包/類
static VarInsnNode getStoreInsn(Type type, int position) {
int opCode;
switch (type.getDescriptor().charAt(0)) {
case 'B':
opCode = Opcodes.ISTORE;
break;
case 'C':
opCode = Opcodes.ISTORE;
break;
case 'D':
opCode = Opcodes.DSTORE;
break;
case 'F':
opCode = Opcodes.FSTORE;
break;
case 'I':
opCode = Opcodes.ISTORE;
break;
case 'J':
opCode = Opcodes.LSTORE;
break;
case 'L':
opCode = Opcodes.ASTORE;
break;
case '[':
opCode = Opcodes.ASTORE;
break;
case 'Z':
opCode = Opcodes.ISTORE;
break;
case 'S':
opCode = Opcodes.ISTORE;
break;
default:
throw new ClassFormatError("Invalid method signature: "
+ type.getDescriptor());
}
return new VarInsnNode(opCode, position);
}