Refine search
public static void acceptAnnotation(final AnnotationVisitor av, final String name, final Object value) { 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); List<?> array = (List<?>) value; for (int j = 0; j < array.size(); ++j) { acceptAnnotation(v, null, array.get(j)); } v.visitEnd(); } else { av.visit(name, value); } }
@Override public AnnotationVisitor visitArray(String name) { List<String> values = new ArrayList<>(); if (name.equals("value")) { return new AnnotationVisitor(Opcodes.ASM7) { @Override public void visit(String name, Object value) { values.add(((Type) value).getClassName()); } @Override public void visitEnd() { resultConsumer.accept(values.toArray(new String[0])); } }; } return null; } };
annotationVisitor.visit( elementName, (byte) readInt(cpInfoOffsets[readUnsignedShort(currentOffset)])); currentOffset += 2; break; case 'C': // const_value_index, CONSTANT_Integer annotationVisitor.visit( case 'I': // const_value_index, CONSTANT_Integer case 'J': // const_value_index, CONSTANT_Long annotationVisitor.visit( break; case 'S': // const_value_index, CONSTANT_Integer annotationVisitor.visit( annotationVisitor.visit( break; case 's': // const_value_index, CONSTANT_Utf8 annotationVisitor.visit(elementName, readUTF8(currentOffset, charBuffer)); currentOffset += 2; break; case 'e': // enum_const_value annotationVisitor.visitEnum( break; case 'c': // class_info annotationVisitor.visit(elementName, Type.getType(readUTF8(currentOffset, charBuffer))); currentOffset += 2;
private static void addOnAfterMethodTimerOnly(ClassWriter cw) { MethodVisitor mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "onAfter", "(Lorg/glowroot/agent/plugin/api/Timer;)V", null, null); visitAnnotation(mv, "Lorg/glowroot/agent/plugin/api/weaving/OnAfter;"); checkNotNull(mv.visitParameterAnnotation(0, "Lorg/glowroot/agent/plugin/api/weaving/BindTraveler;", true)).visitEnd(); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKEINTERFACE, "org/glowroot/agent/plugin/api/Timer", "stop", "()V", true); mv.visitInsn(RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); }
"(Lorg/glowroot/agent/plugin/api/weaving/OptionalReturn;" + travelerType + ")V", null, null); checkNotNull(mv.visitParameterAnnotation(0, "Lorg/glowroot/agent/plugin/api/weaving/BindOptionalReturn;", true)).visitEnd(); checkNotNull(mv.visitParameterAnnotation(1, "Lorg/glowroot/agent/plugin/api/weaving/BindTraveler;", true)).visitEnd(); int travelerParamIndex = 1; visitAnnotation(mv, "Lorg/glowroot/agent/plugin/api/weaving/OnReturn;"); mv.visitCode(); if (!config.traceEntryEnabledProperty().isEmpty()) { mv.visitVarInsn(ALOAD, travelerParamIndex);
AnnotationVisitor interceptorTypeAnn = constructorWriter.visitParameterAnnotation( interceptorArgumentIndex, Type.getDescriptor(io.micronaut.context.annotation.Type.class), true ).visitArray("value"); for (Type interceptorType : interceptorTypes) { interceptorTypeAnn.visit(null, interceptorType); interceptorTypeAnn.visitEnd(); ACC_PRIVATE | ACC_FINAL, FIELD_BEAN_LOCATOR, TYPE_BEAN_LOCATOR.getDescriptor(), null, null ACC_PRIVATE, FIELD_BEAN_QUALIFIER, Type.getType(Qualifier.class).getDescriptor(), null, null constructorWriter.visitInsn(RETURN); constructorWriter.visitMaxs(DEFAULT_MAX_STACK, 1); this.constructorWriter.visitEnd();
static byte[] create(String name, String path) throws IOException { ClassReader reader = new ClassReader(DefaultApplication.class.getClassLoader().getResourceAsStream(DefaultApplication.class.getName().replace('.', '/') + ".class")); String slashName = name.replace('.', '/' ); ClassWriter writer = new ClassWriter(0); Remapper remapper = new Remapper() { @Override public String map(String typeName) { if (typeName.equals("org/wildfly/swarm/jaxrs/DefaultApplication")) { return slashName; } return super.map(typeName); } }; RemappingClassAdapter adapter = new RemappingClassAdapter(writer, remapper); reader.accept(adapter, 0); AnnotationVisitor ann = writer.visitAnnotation("Ljavax/ws/rs/ApplicationPath;", true); ann.visit("value", path); ann.visitEnd(); writer.visitEnd(); return writer.toByteArray(); } }
private void addPathAnnotation(MethodVisitor mv, String path) { AnnotationVisitor av = mv.visitAnnotation(Type.getDescriptor(Path.class), true); av.visit("value", path); av.visitEnd(); }
static byte[] create() throws IOException { ClassReader reader = new ClassReader(FaviconExceptionMapper.class.getClassLoader().getResourceAsStream(FaviconExceptionMapper.class.getName().replace('.', '/') + ".class")); ClassWriter writer = new ClassWriter(0); Remapper remapper = new Remapper() { @Override public String map(String typeName) { if (typeName.equals("org/wildfly/swarm/jaxrs/FaviconExceptionMapper")) { return "org/wildfly/swarm/generated/FaviconExceptionMapper"; } return super.map(typeName); } }; RemappingClassAdapter adapter = new RemappingClassAdapter(writer, remapper); reader.accept(adapter, 0); writer.visitAnnotation("Ljavax/ws/rs/ext/Provider;", true).visitEnd(); writer.visitEnd(); return writer.toByteArray(); } }
final int callingLineNumber = previous.getLineNumber(); ClassReader cr = new ClassReader(callingClassName); cr.accept(new ClassVisitor(Opcodes.ASM5) { @Override public MethodVisitor visitMethod(int access, String name,String desc, String signature, String[] exceptions) { TypeReference reference = new TypeReference(typeRef); if (reference.getSort() == TypeReference.CAST) { return new AnnotationVisitor(Opcodes.ASM5) { public void visit(String name, final Object value) { if (name.equals("value")) {
context.currentMethodAccessFlags = readUnsignedShort(currentOffset); context.currentMethodName = readUTF8(currentOffset + 2, charBuffer); context.currentMethodDescriptor = readUTF8(currentOffset + 4, charBuffer); currentOffset += 6; while (parametersCount-- > 0) { methodVisitor.visitParameter( readUTF8(currentParameterOffset, charBuffer), readUnsignedShort(currentParameterOffset + 2)); AnnotationVisitor annotationVisitor = methodVisitor.visitAnnotationDefault(); readElementValue(annotationVisitor, annotationDefaultOffset, null, charBuffer); if (annotationVisitor != null) { annotationVisitor.visitEnd(); readElementValues( methodVisitor.visitAnnotation(annotationDescriptor, /* visible = */ true), currentAnnotationOffset, /* named = */ true,
private void addPathParamAnnotation(MethodVisitor mv, int index, String paramName) { AnnotationVisitor av = mv.visitParameterAnnotation(index, Type.getDescriptor(PathParam.class), true); av.visit("value", paramName); av.visitEnd(); }
private void addProducesAnnotation(ClassVisitor cv) { AnnotationVisitor av = cv.visitAnnotation(Type.getDescriptor(Produces.class), true); AnnotationVisitor av1 = av.visitArray("value"); av1.visit(null, MediaType.APPLICATION_JSON); av1.visitEnd(); av.visitEnd(); }
AnnotationVisitor av = mv.visitAnnotationDefault(); if (av != null) { accept(av, null, defaultValue); av.visitEnd(); mv.visitCode(); convertCode(methodNode, mv); mv.visitEnd();
@Override public void visit(String name, Object value) { Type type = value instanceof Type ? (Type) value : Type.getType(value.getClass()); log.debug(String.format("Skipping @%s class: %s", Restricted.class.getSimpleName(), type.getClassName())); skippedRestrictedClasses.add(type); super.visit(name, value); } };
AnnotationVisitor av = mv.visitAnnotationDefault(); MethodFlow.acceptAnnotation(av, null, mf.annotationDefault); av.visitEnd(); an.accept(mv.visitAnnotation(an.desc, true)); for (i = 0; i < n; ++i) { AnnotationNode an = (AnnotationNode) mf.invisibleAnnotations.get(i); an.accept(mv.visitAnnotation(an.desc, false));
private void addClassAnnotation(ClassWriter cw) { AnnotationVisitor annotationVisitor = cw.visitAnnotation("Lorg/glowroot/agent/plugin/api/weaving/Pointcut;", true); annotationVisitor.visit("className", config.className()); annotationVisitor.visit("classAnnotation", config.classAnnotation()); annotationVisitor.visit("subTypeRestriction", config.subTypeRestriction()); annotationVisitor.visit("superTypeRestriction", config.superTypeRestriction()); annotationVisitor.visit("methodName", config.methodName()); annotationVisitor.visit("methodAnnotation", config.methodAnnotation()); AnnotationVisitor arrayAnnotationVisitor = checkNotNull(annotationVisitor.visitArray("methodParameterTypes")); for (String methodParameterType : config.methodParameterTypes()) { arrayAnnotationVisitor.visit(null, methodParameterType); arrayAnnotationVisitor.visitEnd(); String timerName = config.timerName(); if (config.isTimerOrGreater()) { if (timerName.isEmpty()) { annotationVisitor.visit("timerName", "<no timer name provided>"); } else { annotationVisitor.visit("timerName", timerName); annotationVisitor.visit("nestingGroup", nestingGroup); } else if (!config.traceEntryCaptureSelfNested()) { annotationVisitor.visit("nestingGroup", "__GeneratedAdvice" + uniqueNum); annotationVisitor.visit("order", config.order()); annotationVisitor.visitEnd();
v.visit("value", Type.getObjectType(nullnessAnnotationType.getClassName())); v.visitEnd();
public static void accept(DexAnnotationNode ann, MethodVisitor v) { AnnotationVisitor av = v.visitAnnotation(ann.type, ann.visibility != Visibility.BUILD); if (av != null) { accept(ann.items, av); av.visitEnd(); } }