diff --git a/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java b/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java index d4076b42abab7..2d7bc8b9bf69b 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java @@ -13,6 +13,7 @@ import static java.util.Arrays.asList; import java.io.IOException; +import java.lang.invoke.MethodHandles; import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -432,6 +433,7 @@ private static Consumer loadStepsFromClass(Class clazz, final List methods = getMethods(clazz); final Map> nameToMethods = methods.stream().collect(Collectors.groupingBy(m -> m.getName())); + MethodHandles.Lookup lookup = MethodHandles.lookup(); for (Method method : methods) { final BuildStep buildStep = method.getAnnotation(BuildStep.class); if (buildStep == null) { @@ -846,17 +848,11 @@ public void execute(final BuildContext bc) { } Object result; try { - result = method.invoke(instance, methodArgs); + result = lookup.unreflect(method).bindTo(instance).invokeWithArguments(methodArgs); } catch (IllegalAccessException e) { throw ReflectUtil.toError(e); - } catch (InvocationTargetException e) { - try { - throw e.getCause(); - } catch (RuntimeException | Error e2) { - throw e2; - } catch (Throwable t) { - throw new IllegalStateException(t); - } + } catch (Throwable t) { + throw new IllegalStateException(t); } resultConsumer.accept(bc, result); if (isRecorder) {