当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationVisitor.visitEnd方法代码示例

本文整理汇总了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));
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:25,代码来源:AsmBackedClassGenerator.java

示例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);
        }
    }
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:34,代码来源:AnnotationNode.java

示例3: end

import org.objectweb.asm.AnnotationVisitor; //导入方法依赖的package包/类
@Override
public void end(final String name) {
    AnnotationVisitor av = (AnnotationVisitor) pop();
    if (av != null) {
        av.visitEnd();
    }
}
 
开发者ID:acmerli,项目名称:fastAOP,代码行数:8,代码来源:ASMContentHandler.java

示例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();
    }
}
 
开发者ID:acmerli,项目名称:fastAOP,代码行数:19,代码来源:AnnotationNode.java

示例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();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:32,代码来源:AsmBackedClassGenerator.java

示例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();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:13,代码来源:AsmBackedClassGenerator.java

示例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();
        }
    }
}
 
开发者ID:primeval-io,项目名称:primeval-reflex,代码行数:15,代码来源:ProxyClassGenerator.java

示例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();
    }
}
 
开发者ID:primeval-io,项目名称:primeval-reflex,代码行数:12,代码来源:ProxyClassGenerator.java


注:本文中的org.objectweb.asm.AnnotationVisitor.visitEnd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。