本文整理匯總了Java中org.objectweb.asm.AnnotationVisitor類的典型用法代碼示例。如果您正苦於以下問題:Java AnnotationVisitor類的具體用法?Java AnnotationVisitor怎麽用?Java AnnotationVisitor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AnnotationVisitor類屬於org.objectweb.asm包,在下文中一共展示了AnnotationVisitor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visitAnnotation
import org.objectweb.asm.AnnotationVisitor; //導入依賴的package包/類
@Override
public AnnotationVisitor visitAnnotation(final String desc,
final boolean visible) {
AnnotationNode an = new AnnotationNode(desc);
if (visible) {
if (visibleAnnotations == null) {
visibleAnnotations = new ArrayList<AnnotationNode>(1);
}
visibleAnnotations.add(an);
} else {
if (invisibleAnnotations == null) {
invisibleAnnotations = new ArrayList<AnnotationNode>(1);
}
invisibleAnnotations.add(an);
}
return an;
}
示例2: visitTypeAnnotation
import org.objectweb.asm.AnnotationVisitor; //導入依賴的package包/類
@Override
public AnnotationVisitor visitTypeAnnotation(int typeRef,
TypePath typePath, String desc, boolean visible) {
TypeAnnotationNode an = new TypeAnnotationNode(typeRef, typePath, desc);
if (visible) {
if (visibleTypeAnnotations == null) {
visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
}
visibleTypeAnnotations.add(an);
} else {
if (invisibleTypeAnnotations == null) {
invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
}
invisibleTypeAnnotations.add(an);
}
return an;
}
示例3: visitInsnAnnotation
import org.objectweb.asm.AnnotationVisitor; //導入依賴的package包/類
@Override
public AnnotationVisitor visitInsnAnnotation(int typeRef,
TypePath typePath, String desc, boolean visible) {
// Finds the last real instruction, i.e. the instruction targeted by
// this annotation.
AbstractInsnNode insn = instructions.getLast();
while (insn.getOpcode() == -1) {
insn = insn.getPrevious();
}
// Adds the annotation to this instruction.
TypeAnnotationNode an = new TypeAnnotationNode(typeRef, typePath, desc);
if (visible) {
if (insn.visibleTypeAnnotations == null) {
insn.visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(
1);
}
insn.visibleTypeAnnotations.add(an);
} else {
if (insn.invisibleTypeAnnotations == null) {
insn.invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(
1);
}
insn.invisibleTypeAnnotations.add(an);
}
return an;
}
示例4: visitAnnotationValue
import org.objectweb.asm.AnnotationVisitor; //導入依賴的package包/類
private void visitAnnotationValue(AnnotationVisitor annotationVisitor, AnnotationValue<?> value) {
String name = value.getName();
if (value instanceof EnumAnnotationValue) {
annotationVisitor.visitEnum(name, ((EnumAnnotationValue) value).getTypeDesc(), (String) value.getValue());
} else if (value instanceof SimpleAnnotationValue) {
annotationVisitor.visit(name, value.getValue());
} else if (value instanceof ArrayAnnotationValue) {
AnnotationVisitor arrayVisitor = annotationVisitor.visitArray(name);
AnnotationValue<?>[] values = ((ArrayAnnotationValue) value).getValue();
for (AnnotationValue<?> annotationValue : values) {
visitAnnotationValue(arrayVisitor, annotationValue);
}
arrayVisitor.visitEnd();
} else if (value instanceof AnnotationAnnotationValue) {
AnnotationMember annotation = ((AnnotationAnnotationValue) value).getValue();
AnnotationVisitor annVisitor = annotationVisitor.visitAnnotation(name, annotation.getName());
visitAnnotationValues(annotation, annVisitor);
}
}
示例5: 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);
}
}
}
示例6: visitTryCatchAnnotation
import org.objectweb.asm.AnnotationVisitor; //導入依賴的package包/類
@Override
public AnnotationVisitor visitTryCatchAnnotation(int typeRef,
TypePath typePath, String desc, boolean visible) {
TryCatchBlockNode tcb = tryCatchBlocks.get((typeRef & 0x00FFFF00) >> 8);
TypeAnnotationNode an = new TypeAnnotationNode(typeRef, typePath, desc);
if (visible) {
if (tcb.visibleTypeAnnotations == null) {
tcb.visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(
1);
}
tcb.visibleTypeAnnotations.add(an);
} else {
if (tcb.invisibleTypeAnnotations == null) {
tcb.invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(
1);
}
tcb.invisibleTypeAnnotations.add(an);
}
return an;
}
示例7: visitLocalVariableAnnotation
import org.objectweb.asm.AnnotationVisitor; //導入依賴的package包/類
@Override
public AnnotationVisitor visitLocalVariableAnnotation(int typeRef,
TypePath typePath, Label[] start, Label[] end, int[] index,
String desc, boolean visible) {
LocalVariableAnnotationNode an = new LocalVariableAnnotationNode(
typeRef, typePath, getLabelNodes(start), getLabelNodes(end),
index, desc);
if (visible) {
if (visibleLocalVariableAnnotations == null) {
visibleLocalVariableAnnotations = new ArrayList<LocalVariableAnnotationNode>(
1);
}
visibleLocalVariableAnnotations.add(an);
} else {
if (invisibleLocalVariableAnnotations == null) {
invisibleLocalVariableAnnotations = new ArrayList<LocalVariableAnnotationNode>(
1);
}
invisibleLocalVariableAnnotations.add(an);
}
return an;
}
示例8: visitInsnAnnotation
import org.objectweb.asm.AnnotationVisitor; //導入依賴的package包/類
@Override
public AnnotationVisitor visitInsnAnnotation(final int typeRef,
final TypePath typePath, final String desc, final boolean visible) {
checkStartCode();
checkEndCode();
int sort = typeRef >>> 24;
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 sort 0x"
+ Integer.toHexString(sort));
}
CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
CheckMethodAdapter.checkDesc(desc, false);
return new CheckAnnotationAdapter(super.visitInsnAnnotation(typeRef,
typePath, desc, visible));
}
示例9: addAnnotationTree
import org.objectweb.asm.AnnotationVisitor; //導入依賴的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));
}
}
}
示例10: visitAnnotationMembers
import org.objectweb.asm.AnnotationVisitor; //導入依賴的package包/類
private void visitAnnotationMembers(Set<AnnotationMember> annotationMembers) {
for (AnnotationMember annotation : annotationMembers) {
AnnotationVisitor annotationVisitor =
apiMemberAdapter.visitAnnotation(annotation.getName(), annotation.isVisible());
visitAnnotationValues(annotation, annotationVisitor);
}
}
示例11: visitInsnAnnotation
import org.objectweb.asm.AnnotationVisitor; //導入依賴的package包/類
@Override
public AnnotationVisitor visitInsnAnnotation(int typeRef,
TypePath typePath, String desc, boolean visible) {
AnnotationVisitor av = super.visitInsnAnnotation(typeRef, typePath,
remapper.mapDesc(desc), visible);
return av == null ? av : new AnnotationRemapper(av, remapper);
}
示例12: visitArray
import org.objectweb.asm.AnnotationVisitor; //導入依賴的package包/類
@Override
public AnnotationVisitor visitArray(final String name) {
Printer p = this.p.visitArray(name);
AnnotationVisitor av = this.av == null ? null : this.av
.visitArray(name);
return new TraceAnnotationVisitor(av, p);
}
示例13: visitAnnotation
import org.objectweb.asm.AnnotationVisitor; //導入依賴的package包/類
@Override
public AnnotationVisitor visitAnnotation(final String desc,
final boolean visible) {
Printer p = this.p.visitFieldAnnotation(desc, visible);
AnnotationVisitor av = fv == null ? null : fv.visitAnnotation(desc,
visible);
return new TraceAnnotationVisitor(av, p);
}
示例14: visitAnnotation
import org.objectweb.asm.AnnotationVisitor; //導入依賴的package包/類
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
if (desc.equals(ANNOTATION_DESCRIPTOR)) {
found = true;
}
return new AnnotationVisitor(Opcodes.ASM5) {
@Override
public void visit(String name, Object value) {
if (name.equals("value")) {
interfaceName = value.toString();
}
}
};
}
示例15: visitTypeAnnotation
import org.objectweb.asm.AnnotationVisitor; //導入依賴的package包/類
@Override
public AnnotationVisitor visitTypeAnnotation(int typeRef,
TypePath typePath, String desc, boolean visible) {
AnnotationVisitor av = super.visitTypeAnnotation(typeRef, typePath,
remapper.mapDesc(desc), visible);
return av == null ? null : createRemappingAnnotationAdapter(av);
}