quarkus: Build error processing type annotation on nested generic method parameters

Describe the bug

In a kotlin quarkus project compiled with the compiler argument -Xemit-jvm-type-annotations, the build fails if a nested type parameter of a method parameter is annotated with a type parameter, for example

fun foo(bar: List<List<@Valid String>>) {

}

Expected behavior

The build should complete without exceptions

Actual behavior

The build fails with the following exception:

    Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.14.0.Final:build (default) on project (...): Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.deployment.steps.ApplicationIndexBuildStep#build threw an exception:   java.lang.IllegalArgumentException: Not a parameterized type!
        at org.jboss.jandex.Type.asParameterizedType(Type.java:248)
        at org.jboss.jandex.Indexer.resolveTypePath(Indexer.java:1227)
        at org.jboss.jandex.Indexer.resolveTypePath(Indexer.java:1234)
        at org.jboss.jandex.Indexer.resolveTypeAnnotation(Indexer.java:1098)
        at org.jboss.jandex.Indexer.resolveTypeAnnotations(Indexer.java:950)
        at org.jboss.jandex.Indexer.indexWithSummary(Indexer.java:2323)
        at org.jboss.jandex.Indexer.index(Indexer.java:2277)
        at io.quarkus.deployment.steps.ApplicationIndexBuildStep$1.visitFile(ApplicationIndexBuildStep.java:49)
        at io.quarkus.deployment.steps.ApplicationIndexBuildStep$1.visitFile(ApplicationIndexBuildStep.java:34)
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2811)
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2882)
        at io.quarkus.deployment.steps.ApplicationIndexBuildStep.build(ApplicationIndexBuildStep.java:34)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)

How to Reproduce?

Try to build the following example project:

code-with-quarkus.zip

Output of uname -a or ver

No response

Output of java -version

17.0.4

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.14.0.Final

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

The corresponding java code does not seem to trigger the same problem, even though the annotation information shown in javap -v of the generated class files doesn’t look different to me.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (11 by maintainers)

Most upvoted comments

OK so the fix in Jandex seems to work fine with the other cases. I’ll release 3.0.4 today.

I also reported the issue in https://youtrack.jetbrains.com/issue/KT-55128

Yea, I should do that. Tomorrow 😃

So this will be fixed in Jandex 3.0.4, but note that the annotation will be just ignored. Kotlin needs to fix their compiler to emit the type annotation path correctly.