diff --git a/extensions/hibernate-validator/deployment/src/test/java/io/quarkus/hibernate/validator/test/valueextractor/ApplicationScopedCustomValueExtractorTest.java b/extensions/hibernate-validator/deployment/src/test/java/io/quarkus/hibernate/validator/test/valueextractor/ApplicationScopedCustomValueExtractorTest.java index 6daaa7a8b40ba..3065ac937e16e 100644 --- a/extensions/hibernate-validator/deployment/src/test/java/io/quarkus/hibernate/validator/test/valueextractor/ApplicationScopedCustomValueExtractorTest.java +++ b/extensions/hibernate-validator/deployment/src/test/java/io/quarkus/hibernate/validator/test/valueextractor/ApplicationScopedCustomValueExtractorTest.java @@ -11,13 +11,11 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.test.QuarkusUnitTest; -@Disabled("Reproduces https://github.com/quarkusio/quarkus/issues/20375, not yet fixed") public class ApplicationScopedCustomValueExtractorTest { @Inject diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AsmUtilCopy.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AsmUtilCopy.java index 4602c12ea37b9..89513c0dc7581 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AsmUtilCopy.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AsmUtilCopy.java @@ -164,48 +164,35 @@ else if (erased) /** * Returns the Java bytecode signature of a given Jandex Class using the given type argument mappings. - * For example, given this class: - * + * + * For example, given this superclass: + * *
      * {@code
      * public class Foo extends Bar implements List {
      * }
      * 
- * - * This will return <R:Ljava/lang/Object;>LBar<TR;>;Ljava/util/List<Ljava/lang/String;>;. - * - * @param klass the class you want the signature for. - * - * @return a bytecode signature for that class. - */ - public static String getSignature(ClassInfo klass) { - return getSignature(klass, NO_ARG_MAPPER); - } - - /** - * Returns the Java bytecode signature of a given Jandex Class using the given type argument mappings. - * For example, given this class: - * + * + * This will return <R:Ljava/lang/Object;>LFoo<TR;>;. + * {@code Bar} and {@code List} will be ignored, as they won't be part of the signature of the generated subclass. + * + * All will be as if the generated subclass was declared like this: + * *
      * {@code
-     * public class Foo extends Bar implements List {
+     * public class MyGeneratedClass extends Foo {
      * }
      * 
+ * + * @param superClass the superclass of the type you want to generate the signature for. * - * This will return <R:Ljava/lang/Object;>LBar<TR;>;Ljava/util/List<Ljava/lang/String;>;. - * - * @param klass the class you want the signature for. - * - * @param typeArgMapper a mapping between type variables and their resolved type. + * @param superClassAsType the superclass as a Jandex Type. * @return a bytecode signature for that class. */ - public static String getSignature(ClassInfo klass, Function typeArgMapper) { - StringBuilder signature = new StringBuilder(""); - toSignature(signature, klass.typeParameters(), typeArgMapper, false); - toSignature(signature, klass.superClassType(), typeArgMapper, false); - for (Type superinterface : klass.interfaceTypes()) { - toSignature(signature, superinterface, typeArgMapper, false); - } + public static String getGeneratedSubClassSignature(ClassInfo superClass, Type superClassAsType) { + StringBuilder signature = new StringBuilder(); + toSignature(signature, superClass.typeParameters(), NO_ARG_MAPPER, false); + toSignature(signature, superClassAsType, NO_ARG_MAPPER, false); return signature.toString(); } @@ -224,21 +211,6 @@ private static void toSignature(StringBuilder sb, List typeParamet sb.append(">"); } - /** - * Returns true if the given class has type parameters or if its superclass or superinterfaces require a signature - */ - public static boolean needsSignature(ClassInfo klass) { - if (!klass.typeParameters().isEmpty() - || needsSignature(klass.superClassType())) { - return true; - } - for (Type type : klass.interfaceTypes()) { - if (needsSignature(type)) - return true; - } - return false; - } - /** * Returns true if the given method has type parameters or if its return type or parameter types require a signature */ 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 5720e8a930296..7eb5be95ff0ce 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 @@ -111,8 +111,16 @@ Collection generate(BeanInfo bean, String beanClassName, ClassCreator clientProxy = ClassCreator.builder().classOutput(classOutput).className(generatedName) .superClass(superClass) .interfaces(interfaces.toArray(new String[0])).build(); - if (AsmUtilCopy.needsSignature(providerClass)) { - clientProxy.setSignature(AsmUtilCopy.getSignature(providerClass)); + // See https://docs.oracle.com/javase/specs/jvms/se14/html/jvms-4.html#jvms-4.7.9.1 + // Essentially a signature is needed if a class has type parameters or extends/implements parameterized type. + // We're generating a subtype (subclass or subinterface) of "providerClass". + // The only way for that generated subtype to have type parameters or to extend/implement a parameterized type + // is if providerClass has type parameters. + // Whether supertypes or superinterfaces of providerClass have type parameters is irrelevant: + // as long as those type parameters are bound in providerClass, + // they won't affect the need for a signature in the generated subtype. + if (!providerClass.typeParameters().isEmpty()) { + clientProxy.setSignature(AsmUtilCopy.getGeneratedSubClassSignature(providerClass, bean.getProviderType())); } Map> resolvedTypeVariables = Types.resolvedTypeVariables(providerClass, bean.getDeployment()); diff --git a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/AsmUtilCopyTest.java b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/AsmUtilCopyTest.java deleted file mode 100644 index e11239251d128..0000000000000 --- a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/AsmUtilCopyTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package io.quarkus.arc.processor; - -import static org.junit.jupiter.api.Assertions.assertFalse; - -import java.io.IOException; -import org.junit.jupiter.api.Test; - -public class AsmUtilCopyTest { - - @Test - public void testNeedsSignature() throws IOException { - assertFalse(AsmUtilCopy.needsSignature(Basics.index(Object.class).getClassByName(DotNames.OBJECT))); - } - -}