Skip to content

Commit

Permalink
Use invokeExact when creating a ConfigMapping object (#1275)
Browse files Browse the repository at this point in the history
This invocation should be slightly more efficient
that the generic `invoke` method
  • Loading branch information
geoand authored Jan 2, 2025
1 parent ab22555 commit 8ac2f93
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ static <T> Map<String, String> configMappingProperties(final Class<T> interfaceT

static <T> T configMappingObject(final Class<T> interfaceType, final ConfigMappingContext configMappingContext) {
try {
MethodHandle constructor = LOOKUP.findConstructor(CACHE.get(interfaceType).getImplementationClass(),
Class<? extends ConfigMappingObject> implClass = CACHE.get(interfaceType).getImplementationClass();
MethodHandle constructor = LOOKUP.findConstructor(implClass,
methodType(void.class, ConfigMappingContext.class));
return interfaceType.cast(constructor.invoke(configMappingContext));
return (T) constructor.asType(constructor.type().changeReturnType(Object.class)).invokeExact(configMappingContext);
} catch (NoSuchMethodException e) {
throw new NoSuchMethodError(e.getMessage());
} catch (IllegalAccessException e) {
Expand Down

0 comments on commit 8ac2f93

Please sign in to comment.