Java Code Examples for jdk.internal.org.objectweb.asm.AnnotationVisitor
The following examples show how to use
jdk.internal.org.objectweb.asm.AnnotationVisitor. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jdk8u-jdk Source File: CheckClassAdapter.java License: GNU General Public License v2.0 | 6 votes |
@Override public AnnotationVisitor visitTypeAnnotation(final int typeRef, final TypePath typePath, final String desc, final boolean visible) { checkState(); int sort = typeRef >>> 24; if (sort != TypeReference.CLASS_TYPE_PARAMETER && sort != TypeReference.CLASS_TYPE_PARAMETER_BOUND && sort != TypeReference.CLASS_EXTENDS) { throw new IllegalArgumentException("Invalid type reference sort 0x" + Integer.toHexString(sort)); } checkTypeRefAndPath(typeRef, typePath); CheckMethodAdapter.checkDesc(desc, false); return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef, typePath, desc, visible)); }
Example 2
Source Project: openjdk-jdk8u Source File: MethodNode.java License: GNU General Public License v2.0 | 6 votes |
@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; }
Example 3
Source Project: TencentKona-8 Source File: MethodNode.java License: GNU General Public License v2.0 | 6 votes |
@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; }
Example 4
Source Project: Bytecoder Source File: CheckMethodAdapter.java License: Apache License 2.0 | 6 votes |
@Override public AnnotationVisitor visitParameterAnnotation( final int parameter, final String descriptor, final boolean visible) { checkVisitEndNotCalled(); if ((visible && visibleAnnotableParameterCount > 0 && parameter >= visibleAnnotableParameterCount) || (!visible && invisibleAnnotableParameterCount > 0 && parameter >= invisibleAnnotableParameterCount)) { throw new IllegalArgumentException("Invalid parameter index"); } checkDescriptor(version, descriptor, false); return new CheckAnnotationAdapter( super.visitParameterAnnotation(parameter, descriptor, visible)); }
Example 5
Source Project: Bytecoder Source File: CheckClassAdapter.java License: Apache License 2.0 | 6 votes |
@Override public AnnotationVisitor visitTypeAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { checkState(); int sort = new TypeReference(typeRef).getSort(); if (sort != TypeReference.CLASS_TYPE_PARAMETER && sort != TypeReference.CLASS_TYPE_PARAMETER_BOUND && sort != TypeReference.CLASS_EXTENDS) { throw new IllegalArgumentException( "Invalid type reference sort 0x" + Integer.toHexString(sort)); } checkTypeRef(typeRef); CheckMethodAdapter.checkDescriptor(version, descriptor, false); return new CheckAnnotationAdapter( super.visitTypeAnnotation(typeRef, typePath, descriptor, visible)); }
Example 6
Source Project: hottub Source File: CheckClassAdapter.java License: GNU General Public License v2.0 | 6 votes |
@Override public AnnotationVisitor visitTypeAnnotation(final int typeRef, final TypePath typePath, final String desc, final boolean visible) { checkState(); int sort = typeRef >>> 24; if (sort != TypeReference.CLASS_TYPE_PARAMETER && sort != TypeReference.CLASS_TYPE_PARAMETER_BOUND && sort != TypeReference.CLASS_EXTENDS) { throw new IllegalArgumentException("Invalid type reference sort 0x" + Integer.toHexString(sort)); } checkTypeRefAndPath(typeRef, typePath); CheckMethodAdapter.checkDesc(desc, false); return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef, typePath, desc, visible)); }
Example 7
Source Project: jdk8u-jdk Source File: MethodNode.java License: GNU General Public License v2.0 | 6 votes |
@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; }
Example 8
Source Project: jdk8u-dev-jdk Source File: MethodNode.java License: GNU General Public License v2.0 | 6 votes |
@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; }
Example 9
Source Project: openjdk-8 Source File: FieldNode.java License: GNU General Public License v2.0 | 6 votes |
@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; }
Example 10
Source Project: Bytecoder Source File: MethodNode.java License: Apache License 2.0 | 6 votes |
@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) { LocalVariableAnnotationNode localVariableAnnotation = new LocalVariableAnnotationNode( typeRef, typePath, getLabelNodes(start), getLabelNodes(end), index, descriptor); if (visible) { if (visibleLocalVariableAnnotations == null) { visibleLocalVariableAnnotations = new ArrayList<LocalVariableAnnotationNode>(1); } visibleLocalVariableAnnotations.add(localVariableAnnotation); } else { if (invisibleLocalVariableAnnotations == null) { invisibleLocalVariableAnnotations = new ArrayList<LocalVariableAnnotationNode>(1); } invisibleLocalVariableAnnotations.add(localVariableAnnotation); } return localVariableAnnotation; }
Example 11
Source Project: openjdk-jdk8u-backup Source File: AnnotationNode.java License: GNU General Public License v2.0 | 6 votes |
/** * 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); } } }
Example 12
Source Project: openjdk-8-source Source File: MethodNode.java License: GNU General Public License v2.0 | 6 votes |
@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; }
Example 13
Source Project: hottub Source File: ScriptClassInfoCollector.java License: GNU General Public License v2.0 | 6 votes |
@Override public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) { final AnnotationVisitor delegateAV = super.visitAnnotation(desc, visible); if (SCRIPT_CLASS_ANNO_DESC.equals(desc)) { return new AnnotationVisitor(Opcodes.ASM4, delegateAV) { @Override public void visit(final String name, final Object value) { if ("value".equals(name)) { scriptClassName = (String) value; } super.visit(name, value); } }; } return delegateAV; }
Example 14
Source Project: hottub Source File: MethodNode.java License: GNU General Public License v2.0 | 6 votes |
@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; }
Example 15
Source Project: hottub Source File: MethodNode.java License: GNU General Public License v2.0 | 6 votes |
@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; }
Example 16
Source Project: Bytecoder Source File: MethodNode.java License: Apache License 2.0 | 6 votes |
@Override public AnnotationVisitor visitTryCatchAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { TryCatchBlockNode tryCatchBlock = tryCatchBlocks.get((typeRef & 0x00FFFF00) >> 8); TypeAnnotationNode typeAnnotation = new TypeAnnotationNode(typeRef, typePath, descriptor); if (visible) { if (tryCatchBlock.visibleTypeAnnotations == null) { tryCatchBlock.visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1); } tryCatchBlock.visibleTypeAnnotations.add(typeAnnotation); } else { if (tryCatchBlock.invisibleTypeAnnotations == null) { tryCatchBlock.invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1); } tryCatchBlock.invisibleTypeAnnotations.add(typeAnnotation); } return typeAnnotation; }
Example 17
Source Project: jdk8u_jdk Source File: CheckClassAdapter.java License: GNU General Public License v2.0 | 6 votes |
@Override public AnnotationVisitor visitTypeAnnotation(final int typeRef, final TypePath typePath, final String desc, final boolean visible) { checkState(); int sort = typeRef >>> 24; if (sort != TypeReference.CLASS_TYPE_PARAMETER && sort != TypeReference.CLASS_TYPE_PARAMETER_BOUND && sort != TypeReference.CLASS_EXTENDS) { throw new IllegalArgumentException("Invalid type reference sort 0x" + Integer.toHexString(sort)); } checkTypeRefAndPath(typeRef, typePath); CheckMethodAdapter.checkDesc(desc, false); return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef, typePath, desc, visible)); }
Example 18
Source Project: Bytecoder Source File: MethodNode.java License: Apache License 2.0 | 6 votes |
@Override public AnnotationVisitor visitInsnAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { // Find the last real instruction, i.e. the instruction targeted by this annotation. AbstractInsnNode currentInsn = instructions.getLast(); while (currentInsn.getOpcode() == -1) { currentInsn = currentInsn.getPrevious(); } // Add the annotation to this instruction. TypeAnnotationNode typeAnnotation = new TypeAnnotationNode(typeRef, typePath, descriptor); if (visible) { if (currentInsn.visibleTypeAnnotations == null) { currentInsn.visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1); } currentInsn.visibleTypeAnnotations.add(typeAnnotation); } else { if (currentInsn.invisibleTypeAnnotations == null) { currentInsn.invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1); } currentInsn.invisibleTypeAnnotations.add(typeAnnotation); } return typeAnnotation; }
Example 19
Source Project: jdk8u_jdk Source File: MethodNode.java License: GNU General Public License v2.0 | 6 votes |
@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; }
Example 20
Source Project: Bytecoder Source File: ClassNode.java License: Apache License 2.0 | 6 votes |
@Override public AnnotationVisitor visitTypeAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { TypeAnnotationNode typeAnnotation = new TypeAnnotationNode(typeRef, typePath, descriptor); if (visible) { if (visibleTypeAnnotations == null) { visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1); } visibleTypeAnnotations.add(typeAnnotation); } else { if (invisibleTypeAnnotations == null) { invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1); } invisibleTypeAnnotations.add(typeAnnotation); } return typeAnnotation; }
Example 21
Source Project: openjdk-jdk9 Source File: NullVisitor.java License: GNU General Public License v2.0 | 6 votes |
@Override public MethodVisitor visitMethod( final int access, final String name, final String desc, final String signature, final String[] exceptions) { return new MethodVisitor(Main.ASM_VERSION) { @Override public AnnotationVisitor visitAnnotationDefault() { return new NullAnnotationVisitor(); } @Override public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) { return new NullAnnotationVisitor(); } }; }
Example 22
Source Project: openjdk-jdk9 Source File: TraceMethodVisitor.java License: GNU General Public License v2.0 | 5 votes |
@Override public AnnotationVisitor visitTryCatchAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { Printer p = this.p.visitTryCatchAnnotation(typeRef, typePath, desc, visible); AnnotationVisitor av = mv == null ? null : mv.visitTryCatchAnnotation( typeRef, typePath, desc, visible); return new TraceAnnotationVisitor(av, p); }
Example 23
Source Project: openjdk-jdk8u-backup Source File: TraceMethodVisitor.java License: GNU General Public License v2.0 | 5 votes |
@Override public AnnotationVisitor visitTryCatchAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { Printer p = this.p.visitTryCatchAnnotation(typeRef, typePath, desc, visible); AnnotationVisitor av = mv == null ? null : mv.visitTryCatchAnnotation( typeRef, typePath, desc, visible); return new TraceAnnotationVisitor(av, p); }
Example 24
Source Project: dragonwell8_jdk Source File: RemappingMethodAdapter.java License: GNU General Public License v2.0 | 5 votes |
@Override public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) { AnnotationVisitor av = super.visitParameterAnnotation(parameter, remapper.mapDesc(desc), visible); return av == null ? av : new RemappingAnnotationAdapter(av, remapper); }
Example 25
Source Project: jdk8u-jdk Source File: CheckAnnotationAdapter.java License: GNU General Public License v2.0 | 5 votes |
@Override public AnnotationVisitor visitArray(final String name) { checkEnd(); checkName(name); return new CheckAnnotationAdapter(av == null ? null : av.visitArray(name), false); }
Example 26
Source Project: Bytecoder Source File: TraceMethodVisitor.java License: Apache License 2.0 | 5 votes |
@Override public AnnotationVisitor visitParameterAnnotation( final int parameter, final String descriptor, final boolean visible) { Printer annotationPrinter = p.visitParameterAnnotation(parameter, descriptor, visible); return new TraceAnnotationVisitor( super.visitParameterAnnotation(parameter, descriptor, visible), annotationPrinter); }
Example 27
Source Project: dragonwell8_jdk Source File: LocalVariablesSorter.java License: GNU General Public License v2.0 | 5 votes |
@Override public AnnotationVisitor visitLocalVariableAnnotation(int typeRef, TypePath typePath, Label[] start, Label[] end, int[] index, String desc, boolean visible) { Type t = Type.getType(desc); int[] newIndex = new int[index.length]; for (int i = 0; i < newIndex.length; ++i) { newIndex[i] = remap(index[i], t); } return mv.visitLocalVariableAnnotation(typeRef, typePath, start, end, newIndex, desc, visible); }
Example 28
Source Project: nashorn Source File: CheckClassAdapter.java License: GNU General Public License v2.0 | 5 votes |
@Override public AnnotationVisitor visitAnnotation( final String desc, final boolean visible) { checkState(); CheckMethodAdapter.checkDesc(desc, false); return new CheckAnnotationAdapter(super.visitAnnotation(desc, visible)); }
Example 29
Source Project: jdk8u_jdk Source File: RemappingMethodAdapter.java License: GNU General Public License v2.0 | 5 votes |
@Override public AnnotationVisitor visitTryCatchAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { AnnotationVisitor av = super.visitTryCatchAnnotation(typeRef, typePath, remapper.mapDesc(desc), visible); return av == null ? av : new RemappingAnnotationAdapter(av, remapper); }
Example 30
Source Project: jdk8u-jdk Source File: MethodNode.java License: GNU General Public License v2.0 | 5 votes |
@Override @SuppressWarnings("serial") public AnnotationVisitor visitAnnotationDefault() { return new AnnotationNode(new ArrayList<Object>(0) { @Override public boolean add(final Object o) { annotationDefault = o; return super.add(o); } }); }