Skip to content

Commit

Permalink
Fix AOT processing of add method with array parameter in Logback model
Browse files Browse the repository at this point in the history
Fixes gh-33387
  • Loading branch information
wilkinsona committed Nov 28, 2022
1 parent 012e135 commit c1dab0f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Expand Up @@ -291,7 +291,8 @@ private Collection<String> parameterTypesNames(Collection<Method> methods) {
.filter((method) -> !method.getDeclaringClass().equals(ContextAware.class)
&& !method.getDeclaringClass().equals(ContextAwareBase.class))
.map(Method::getParameterTypes).flatMap(Stream::of)
.filter((type) -> !type.isPrimitive() && !type.equals(String.class)).map(Class::getName).toList();
.filter((type) -> !type.isPrimitive() && !type.equals(String.class))
.map((type) -> type.isArray() ? type.getComponentType() : type).map(Class::getName).toList();
}

}
Expand Down
Expand Up @@ -18,6 +18,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -178,6 +179,15 @@ void typeFromParentsDefaultClassAnnotatedSetterIsRegisteredForReflection() {
.accepts(generationContext.getRuntimeHints());
}

@Test
void componentTypesOfArraysAreRegisteredForReflection() {
ComponentModel component = new ComponentModel();
component.setClassName(ArrayParmeters.class.getName());
TestGenerationContext generationContext = applyContribution(component);
assertThat(invokePublicConstructorsAndInspectAndInvokePublicMethodsOf(InetSocketAddress.class))
.accepts(generationContext.getRuntimeHints());
}

private Predicate<RuntimeHints> invokePublicConstructorsOf(String name) {
return RuntimeHintsPredicates.reflection().onType(TypeReference.of(name))
.withMemberCategory(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS);
Expand Down Expand Up @@ -254,4 +264,12 @@ public interface Contract {

}

public static class ArrayParmeters {

public void addDestinations(InetSocketAddress... addresses) {

}

}

}

0 comments on commit c1dab0f

Please sign in to comment.