use of org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor in project tapestry-5 by apache.
the class LocalVariablesSorter method visitLocalVariableAnnotation.
@Override
public AnnotationVisitor visitLocalVariableAnnotation(final int typeRef, final TypePath typePath, final Label[] start, final Label[] end, final int[] index, final String descriptor, final boolean visible) {
Type type = Type.getType(descriptor);
int[] remappedIndex = new int[index.length];
for (int i = 0; i < remappedIndex.length; ++i) {
remappedIndex[i] = remap(index[i], type);
}
return super.visitLocalVariableAnnotation(typeRef, typePath, start, end, remappedIndex, descriptor, visible);
}
use of org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor in project tapestry-5 by apache.
the class MethodNode method accept.
/**
* Makes the given method visitor visit this method.
*
* @param methodVisitor a method visitor.
*/
public void accept(final MethodVisitor methodVisitor) {
// Visit the parameters.
if (parameters != null) {
for (int i = 0, n = parameters.size(); i < n; i++) {
parameters.get(i).accept(methodVisitor);
}
}
// Visit the annotations.
if (annotationDefault != null) {
AnnotationVisitor annotationVisitor = methodVisitor.visitAnnotationDefault();
AnnotationNode.accept(annotationVisitor, null, annotationDefault);
if (annotationVisitor != null) {
annotationVisitor.visitEnd();
}
}
if (visibleAnnotations != null) {
for (int i = 0, n = visibleAnnotations.size(); i < n; ++i) {
AnnotationNode annotation = visibleAnnotations.get(i);
annotation.accept(methodVisitor.visitAnnotation(annotation.desc, true));
}
}
if (invisibleAnnotations != null) {
for (int i = 0, n = invisibleAnnotations.size(); i < n; ++i) {
AnnotationNode annotation = invisibleAnnotations.get(i);
annotation.accept(methodVisitor.visitAnnotation(annotation.desc, false));
}
}
if (visibleTypeAnnotations != null) {
for (int i = 0, n = visibleTypeAnnotations.size(); i < n; ++i) {
TypeAnnotationNode typeAnnotation = visibleTypeAnnotations.get(i);
typeAnnotation.accept(methodVisitor.visitTypeAnnotation(typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, true));
}
}
if (invisibleTypeAnnotations != null) {
for (int i = 0, n = invisibleTypeAnnotations.size(); i < n; ++i) {
TypeAnnotationNode typeAnnotation = invisibleTypeAnnotations.get(i);
typeAnnotation.accept(methodVisitor.visitTypeAnnotation(typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, false));
}
}
if (visibleAnnotableParameterCount > 0) {
methodVisitor.visitAnnotableParameterCount(visibleAnnotableParameterCount, true);
}
if (visibleParameterAnnotations != null) {
for (int i = 0, n = visibleParameterAnnotations.length; i < n; ++i) {
List<AnnotationNode> parameterAnnotations = visibleParameterAnnotations[i];
if (parameterAnnotations == null) {
continue;
}
for (int j = 0, m = parameterAnnotations.size(); j < m; ++j) {
AnnotationNode annotation = parameterAnnotations.get(j);
annotation.accept(methodVisitor.visitParameterAnnotation(i, annotation.desc, true));
}
}
}
if (invisibleAnnotableParameterCount > 0) {
methodVisitor.visitAnnotableParameterCount(invisibleAnnotableParameterCount, false);
}
if (invisibleParameterAnnotations != null) {
for (int i = 0, n = invisibleParameterAnnotations.length; i < n; ++i) {
List<AnnotationNode> parameterAnnotations = invisibleParameterAnnotations[i];
if (parameterAnnotations == null) {
continue;
}
for (int j = 0, m = parameterAnnotations.size(); j < m; ++j) {
AnnotationNode annotation = parameterAnnotations.get(j);
annotation.accept(methodVisitor.visitParameterAnnotation(i, annotation.desc, false));
}
}
}
// Visit the non standard attributes.
if (visited) {
instructions.resetLabels();
}
if (attrs != null) {
for (int i = 0, n = attrs.size(); i < n; ++i) {
methodVisitor.visitAttribute(attrs.get(i));
}
}
// Visit the code.
if (instructions.size() > 0) {
methodVisitor.visitCode();
// Visits the try catch blocks.
if (tryCatchBlocks != null) {
for (int i = 0, n = tryCatchBlocks.size(); i < n; ++i) {
tryCatchBlocks.get(i).updateIndex(i);
tryCatchBlocks.get(i).accept(methodVisitor);
}
}
// Visit the instructions.
instructions.accept(methodVisitor);
// Visits the local variables.
if (localVariables != null) {
for (int i = 0, n = localVariables.size(); i < n; ++i) {
localVariables.get(i).accept(methodVisitor);
}
}
// Visits the local variable annotations.
if (visibleLocalVariableAnnotations != null) {
for (int i = 0, n = visibleLocalVariableAnnotations.size(); i < n; ++i) {
visibleLocalVariableAnnotations.get(i).accept(methodVisitor, true);
}
}
if (invisibleLocalVariableAnnotations != null) {
for (int i = 0, n = invisibleLocalVariableAnnotations.size(); i < n; ++i) {
invisibleLocalVariableAnnotations.get(i).accept(methodVisitor, false);
}
}
methodVisitor.visitMaxs(maxStack, maxLocals);
visited = true;
}
methodVisitor.visitEnd();
}
use of org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor in project tapestry-5 by apache.
the class CheckMethodAdapter method visitTypeAnnotation.
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
checkVisitEndNotCalled();
int sort = new TypeReference(typeRef).getSort();
if (sort != TypeReference.METHOD_TYPE_PARAMETER && sort != TypeReference.METHOD_TYPE_PARAMETER_BOUND && sort != TypeReference.METHOD_RETURN && sort != TypeReference.METHOD_RECEIVER && sort != TypeReference.METHOD_FORMAL_PARAMETER && sort != TypeReference.THROWS) {
throw new IllegalArgumentException(INVALID_TYPE_REFERENCE + Integer.toHexString(sort));
}
CheckClassAdapter.checkTypeRef(typeRef);
CheckMethodAdapter.checkDescriptor(version, descriptor, false);
return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef, typePath, descriptor, visible));
}
use of org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor in project tapestry-5 by apache.
the class CheckMethodAdapter method visitInsnAnnotation.
@Override
public AnnotationVisitor visitInsnAnnotation(final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
checkVisitCodeCalled();
checkVisitMaxsNotCalled();
int sort = new TypeReference(typeRef).getSort();
if (sort != TypeReference.INSTANCEOF && sort != TypeReference.NEW && sort != TypeReference.CONSTRUCTOR_REFERENCE && sort != TypeReference.METHOD_REFERENCE && sort != TypeReference.CAST && sort != TypeReference.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT && sort != TypeReference.METHOD_INVOCATION_TYPE_ARGUMENT && sort != TypeReference.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT && sort != TypeReference.METHOD_REFERENCE_TYPE_ARGUMENT) {
throw new IllegalArgumentException(INVALID_TYPE_REFERENCE + Integer.toHexString(sort));
}
CheckClassAdapter.checkTypeRef(typeRef);
CheckMethodAdapter.checkDescriptor(version, descriptor, false);
return new CheckAnnotationAdapter(super.visitInsnAnnotation(typeRef, typePath, descriptor, visible));
}
use of org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor in project tapestry-5 by apache.
the class PlasticClassImpl method addMethodAndParameterAnnotationsFromExistingClass.
private static void addMethodAndParameterAnnotationsFromExistingClass(MethodNode methodNode, MethodNode implementationMethodNode) {
// visits the method attributes
int i, j, n;
if (implementationMethodNode.annotationDefault != null) {
AnnotationVisitor av = methodNode.visitAnnotationDefault();
AnnotationNode.accept(av, null, implementationMethodNode.annotationDefault);
if (av != null) {
av.visitEnd();
}
}
n = implementationMethodNode.visibleAnnotations == null ? 0 : implementationMethodNode.visibleAnnotations.size();
for (i = 0; i < n; ++i) {
AnnotationNode an = implementationMethodNode.visibleAnnotations.get(i);
an.accept(methodNode.visitAnnotation(an.desc, true));
}
n = implementationMethodNode.invisibleAnnotations == null ? 0 : implementationMethodNode.invisibleAnnotations.size();
for (i = 0; i < n; ++i) {
AnnotationNode an = implementationMethodNode.invisibleAnnotations.get(i);
an.accept(methodNode.visitAnnotation(an.desc, false));
}
n = implementationMethodNode.visibleParameterAnnotations == null ? 0 : implementationMethodNode.visibleParameterAnnotations.length;
for (i = 0; i < n; ++i) {
List<?> l = implementationMethodNode.visibleParameterAnnotations[i];
if (l == null) {
continue;
}
for (j = 0; j < l.size(); ++j) {
AnnotationNode an = (AnnotationNode) l.get(j);
an.accept(methodNode.visitParameterAnnotation(i, an.desc, true));
}
}
n = implementationMethodNode.invisibleParameterAnnotations == null ? 0 : implementationMethodNode.invisibleParameterAnnotations.length;
for (i = 0; i < n; ++i) {
List<?> l = implementationMethodNode.invisibleParameterAnnotations[i];
if (l == null) {
continue;
}
for (j = 0; j < l.size(); ++j) {
AnnotationNode an = (AnnotationNode) l.get(j);
an.accept(methodNode.visitParameterAnnotation(i, an.desc, false));
}
}
methodNode.visitEnd();
}
Aggregations