use of org.objectweb.asm.TypePath in project groovy by apache.
the class AsmClassGenerator method visitTypeAnnotations.
private void visitTypeAnnotations(final ClassNode sourceNode, final Object visitor, final TypeReference typeRef, final String typePathStr, boolean typeUse) {
for (AnnotationNode an : sourceNode.getTypeAnnotations()) {
if (an.isBuiltIn() || an.hasSourceRetention())
continue;
if (typeUse && !an.isTargetAllowed(AnnotationNode.TYPE_USE_TARGET))
continue;
AnnotationVisitor av = null;
final TypePath typePath;
try {
typePath = TypePath.fromString(typePathStr);
} catch (IllegalArgumentException ex) {
throw new GroovyBugError("Illegal type path for " + sourceNode.getText() + ", typeRef = " + typeRef + ", typePath = " + typePathStr);
}
final int typeRefInt = typeRef.getValue();
final String annotationDescriptor = BytecodeHelper.getTypeDescription(an.getClassNode());
if (visitor instanceof ClassVisitor) {
av = ((ClassVisitor) visitor).visitTypeAnnotation(typeRefInt, typePath, annotationDescriptor, an.hasRuntimeRetention());
} else if (visitor instanceof MethodVisitor) {
av = ((MethodVisitor) visitor).visitTypeAnnotation(typeRefInt, typePath, annotationDescriptor, an.hasRuntimeRetention());
} else if (visitor instanceof FieldVisitor) {
av = ((FieldVisitor) visitor).visitTypeAnnotation(typeRefInt, typePath, annotationDescriptor, an.hasRuntimeRetention());
} else if (visitor instanceof RecordComponentVisitor) {
av = ((RecordComponentVisitor) visitor).visitTypeAnnotation(typeRefInt, typePath, annotationDescriptor, an.hasRuntimeRetention());
} else {
throwException("Cannot create an AnnotationVisitor. Please report Groovy bug");
}
visitAnnotationAttributes(an, av);
av.visitEnd();
}
}
Aggregations