Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ private static ParameterSpec buildParameter(TypeName parameterType, MethodParame
MergedAnnotations annotations = MergedAnnotations.from(methodParameter.getParameterAnnotations());

for (MergedAnnotation<Annotation> annotation : annotations) {
builder.addAnnotation(AnnotationSpec.get(annotation.synthesize()));
if (annotation.isDirectlyPresent()) {
builder.addAnnotation(AnnotationSpec.get(annotation.synthesize()));
}
}

return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -61,6 +65,16 @@ void addsAnnotations() throws NoSuchMethodException {
.containsExactly(SortDefault.class.getTypeName(), Param.class.getTypeName());
}

@Test // GH-3499
void doesNotRenderMetaAnnotations() throws NoSuchMethodException {

MethodMetadata metadata = methodMetadataFor("metaAnnotatedArgMethod");

ParameterSpec arg0 = metadata.getMethodArguments().get("arg0");
assertThat(arg0.annotations()).extracting(annotationSpec -> annotationSpec.type().toString())
.containsExactly(MetaAnnotated.class.getCanonicalName());
}

@Test // GH-3270
void getParameterNameByNonExistingIndex() throws NoSuchMethodException {

Expand Down Expand Up @@ -100,5 +114,16 @@ private interface DummyRepo {
String noArgsMethod();

String threeArgsMethod(Object arg0, @SortDefault Pageable arg1, @SortDefault @Param("foo") Object arg2);

String metaAnnotatedArgMethod(@MetaAnnotated Object arg0);
}

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE)
private @interface Meta {}

@Meta
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
private @interface MetaAnnotated {}
}
Loading