question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Build error processing type annotation on nested generic method parameters

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Ladicekcommented, Nov 24, 2022

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

1reaction
Ladicekcommented, Nov 22, 2022

Yea, I should do that. Tomorrow 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect constraint inference for unions with nested generics
mypy has troubles with inferring a proper constraint and passing a nested generic to function that should accept such nested generic fails. The ......
Read more >
Nested Generic Annotation changing Family Type parameter ...
Solved: I have nested generic annotations controlled by a family type parameter in an unhosted family (level based).
Read more >
Nested Generic Type Parameters Parameters - Stack Overflow
It is public abstract class BaseClass<X extends SecondClass, T extends FirstClass, U extends BaseAnother<X>> { , no?
Read more >
typing — Support for type hints — Python 3.11.1 documentation
Introducing syntax for annotating variables outside of function definitions, ... All varieties of TypeVar are permissible as parameters for a generic type:.
Read more >
Problem with nested generic parameters - Oracle Communities
I've run into a problem with nested generic parameters and type erasure. Here's a reduction of the problem: import java.util.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found