From a761ecd8a9c37d2df2f07fafd0b92852b1dae111 Mon Sep 17 00:00:00 2001 From: Martin Kouba Date: Wed, 9 Jun 2021 13:20:45 +0200 Subject: [PATCH] ArC client proxies - prioritize delegating methods impl. on superclasses - resolves #17755 --- .../arc/processor/ClientProxyGenerator.java | 14 ++++++----- .../io/quarkus/arc/processor/Methods.java | 20 ++++++++------- ...roxyMethodInvocationInConstructorTest.java | 25 +++++++++++++++++++ .../delegatingmethods/Component.java | 11 ++++++++ .../delegatingmethods/HasElement.java | 10 ++++++++ .../delegatingmethods/HasSize.java | 8 ++++++ .../clientproxy/delegatingmethods/MyBean.java | 14 +++++++++++ 7 files changed, 87 insertions(+), 15 deletions(-) create mode 100644 independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/clientproxy/delegatingmethods/ClientProxyMethodInvocationInConstructorTest.java create mode 100644 independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/clientproxy/delegatingmethods/Component.java create mode 100644 independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/clientproxy/delegatingmethods/HasElement.java create mode 100644 independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/clientproxy/delegatingmethods/HasSize.java create mode 100644 independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/clientproxy/delegatingmethods/MyBean.java diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/ClientProxyGenerator.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/ClientProxyGenerator.java index 4410f808f41d8..5720e8a930296 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/ClientProxyGenerator.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/ClientProxyGenerator.java @@ -33,6 +33,7 @@ import org.jboss.jandex.ClassInfo; import org.jboss.jandex.DotName; import org.jboss.jandex.FieldInfo; +import org.jboss.jandex.IndexView; import org.jboss.jandex.MethodInfo; import org.jboss.jandex.Type; import org.jboss.jandex.TypeVariable; @@ -310,11 +311,12 @@ void implementGetBean(ClassCreator clientProxy, FieldDescriptor beanField) { Collection getDelegatingMethods(BeanInfo bean, Consumer bytecodeTransformerConsumer, boolean transformUnproxyableClasses) { Map methods = new HashMap<>(); + IndexView index = bean.getDeployment().getBeanArchiveIndex(); if (bean.isClassBean()) { Set methodsFromWhichToRemoveFinal = new HashSet<>(); ClassInfo classInfo = bean.getTarget().get().asClass(); - Methods.addDelegatingMethods(bean.getDeployment().getBeanArchiveIndex(), classInfo, + Methods.addDelegatingMethods(index, classInfo, methods, methodsFromWhichToRemoveFinal, transformUnproxyableClasses); if (!methodsFromWhichToRemoveFinal.isEmpty()) { String className = classInfo.name().toString(); @@ -323,16 +325,16 @@ Collection getDelegatingMethods(BeanInfo bean, Consumer methods, Set methodsFromWhichToRemoveFinal, boolean transformUnproxyableClasses) { - // TODO support interfaces default methods if (classInfo != null) { + // First methods declared on the class for (MethodInfo method : classInfo.methods()) { if (skipForClientProxy(method, transformUnproxyableClasses, methodsFromWhichToRemoveFinal)) { continue; @@ -88,14 +88,7 @@ static void addDelegatingMethods(IndexView index, ClassInfo classInfo, Map