本文整理汇总了Java中org.objectweb.asm.AnnotationVisitor.visitEnd方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationVisitor.visitEnd方法的具体用法?Java AnnotationVisitor.visitEnd怎么用?Java AnnotationVisitor.visitEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.objectweb.asm.AnnotationVisitor
的用法示例。
在下文中一共展示了AnnotationVisitor.visitEnd方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitAnnotationValues
import org.objectweb.asm.AnnotationVisitor; //导入方法依赖的package包/类
private void visitAnnotationValues(Annotation annotation, AnnotationVisitor annotationVisitor) {
for (Method method : annotation.annotationType().getDeclaredMethods()) {
String name = method.getName();
Class<?> returnType = method.getReturnType();
if (returnType.isEnum()) {
annotationVisitor.visitEnum(name, Type.getType(returnType).getDescriptor(), getAnnotationParameterValue(annotation, method).toString());
} else if (returnType.isArray() && !PRIMITIVE_TYPES.contains(returnType.getComponentType())) {
AnnotationVisitor arrayVisitor = annotationVisitor.visitArray(name);
Object[] elements = (Object[]) getAnnotationParameterValue(annotation, method);
visitArrayElements(arrayVisitor, returnType.getComponentType(), elements);
arrayVisitor.visitEnd();
} else if (returnType.equals(Class.class)) {
Class<?> clazz = (Class<?>) getAnnotationParameterValue(annotation, method);
annotationVisitor.visit(name, Type.getType(clazz));
} else if (returnType.isAnnotation()) {
Annotation nestedAnnotation = (Annotation) getAnnotationParameterValue(annotation, method);
AnnotationVisitor nestedAnnotationVisitor = annotationVisitor.visitAnnotation(name, Type.getType(returnType).getDescriptor());
visitAnnotationValues(nestedAnnotation, nestedAnnotationVisitor);
nestedAnnotationVisitor.visitEnd();
} else {
annotationVisitor.visit(name, getAnnotationParameterValue(annotation, method));
}
}
}
示例2: accept
import org.objectweb.asm.AnnotationVisitor; //导入方法依赖的package包/类
/**
* Makes the given visitor visit a given annotation value.
*
* @param av
* an annotation visitor. Maybe <tt>null</tt>.
* @param name
* the value name.
* @param value
* the actual value.
*/
static void accept(final AnnotationVisitor av, final String name,
final Object value) {
if (av != null) {
if (value instanceof String[]) {
String[] typeconst = (String[]) value;
av.visitEnum(name, typeconst[0], typeconst[1]);
} else if (value instanceof AnnotationNode) {
AnnotationNode an = (AnnotationNode) value;
an.accept(av.visitAnnotation(name, an.desc));
} else if (value instanceof List) {
AnnotationVisitor v = av.visitArray(name);
if (v != null) {
List<?> array = (List<?>) value;
for (int j = 0; j < array.size(); ++j) {
accept(v, null, array.get(j));
}
v.visitEnd();
}
} else {
av.visit(name, value);
}
}
}
示例3: end
import org.objectweb.asm.AnnotationVisitor; //导入方法依赖的package包/类
@Override
public void end(final String name) {
AnnotationVisitor av = (AnnotationVisitor) pop();
if (av != null) {
av.visitEnd();
}
}
示例4: accept
import org.objectweb.asm.AnnotationVisitor; //导入方法依赖的package包/类
/**
* Makes the given visitor visit this annotation.
*
* @param av
* an annotation visitor. Maybe <tt>null</tt>.
*/
public void accept(final AnnotationVisitor av) {
if (av != null) {
if (values != null) {
for (int i = 0; i < values.size(); i += 2) {
String name = (String) values.get(i);
Object value = values.get(i + 1);
accept(av, name, value);
}
}
av.visitEnd();
}
}
示例5: addConstructor
import org.objectweb.asm.AnnotationVisitor; //导入方法依赖的package包/类
public void addConstructor(Constructor<?> constructor) throws Exception {
List<Type> paramTypes = new ArrayList<Type>();
for (Class<?> paramType : constructor.getParameterTypes()) {
paramTypes.add(Type.getType(paramType));
}
String methodDescriptor = Type.getMethodDescriptor(VOID_TYPE, paramTypes.toArray(EMPTY_TYPES));
MethodVisitor methodVisitor = visitor.visitMethod(Opcodes.ACC_PUBLIC, "<init>", methodDescriptor, signature(constructor), EMPTY_STRINGS);
for (Annotation annotation : constructor.getDeclaredAnnotations()) {
if (annotation.annotationType().getAnnotation(Inherited.class) != null) {
continue;
}
Retention retention = annotation.annotationType().getAnnotation(Retention.class);
AnnotationVisitor annotationVisitor = methodVisitor.visitAnnotation(Type.getType(annotation.annotationType()).getDescriptor(), retention != null && retention.value() == RetentionPolicy.RUNTIME);
annotationVisitor.visitEnd();
}
methodVisitor.visitCode();
// this.super(p0 .. pn)
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
for (int i = 0; i < constructor.getParameterTypes().length; i++) {
methodVisitor.visitVarInsn(Type.getType(constructor.getParameterTypes()[i]).getOpcode(Opcodes.ILOAD), i + 1);
}
methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, superclassType.getInternalName(), "<init>", methodDescriptor, false);
methodVisitor.visitInsn(Opcodes.RETURN);
methodVisitor.visitMaxs(0, 0);
methodVisitor.visitEnd();
}
示例6: includeNotInheritedAnnotations
import org.objectweb.asm.AnnotationVisitor; //导入方法依赖的package包/类
private void includeNotInheritedAnnotations() {
for (Annotation annotation : type.getDeclaredAnnotations()) {
if (annotation.annotationType().getAnnotation(Inherited.class) != null) {
continue;
}
Retention retention = annotation.annotationType().getAnnotation(Retention.class);
boolean visible = retention != null && retention.value() == RetentionPolicy.RUNTIME;
AnnotationVisitor annotationVisitor = visitor.visitAnnotation(Type.getType(annotation.annotationType()).getDescriptor(), visible);
visitAnnotationValues(annotation, annotationVisitor);
annotationVisitor.visitEnd();
}
}
示例7: addMethodParameterAnnotations
import org.objectweb.asm.AnnotationVisitor; //导入方法依赖的package包/类
private static void addMethodParameterAnnotations(Method method, MethodVisitor mv)
throws IllegalAccessException, InvocationTargetException {
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
for (int i = 0; i < parameterAnnotations.length; i++) {
Annotation[] annotations = parameterAnnotations[i];
for (Annotation ann : annotations) {
Class<? extends Annotation> annotationType = ann.annotationType();
AnnotationVisitor av0 = mv.visitParameterAnnotation(i, Type.getDescriptor(annotationType), true);
addAnnotationTree(av0, ann, annotationType);
av0.visitEnd();
}
}
}
示例8: addTypeAnnotations
import org.objectweb.asm.AnnotationVisitor; //导入方法依赖的package包/类
private static void addTypeAnnotations(Class<?> clazzToProxy, ClassWriter cw)
throws IllegalAccessException, InvocationTargetException {
for (Annotation ann : clazzToProxy.getDeclaredAnnotations()) {
Class<? extends Annotation> annotationType = ann.annotationType();
AnnotationVisitor av0 = cw.visitAnnotation(Type.getDescriptor(annotationType), true);
addAnnotationTree(av0, ann, annotationType);
av0.visitEnd();
}
}