jooby-project / jooby

The modular web framework for Java and Kotlin
https://jooby.io
Apache License 2.0
1.7k stars 199 forks source link

kotlin: mvc: don't generate primitive types with generics type #3490

Closed jknack closed 1 month ago

jknack commented 1 month ago

Given:

fun box(@QueryParam box: Box<Int>)

Generates:

 /** See [Controller.box] */
app.get("/box", this::box)
  .setReturnType(io.jooby.Reified.getParameterized(foo.Box::class.java, Int::class.java).getType())
  .setMvcMethod(Controller::class.java.getMethod("box", foo.Box::class.java))

Which results in a runtime exception:

[2024-08-03 11:57:40,773]-[main] ERROR io.jooby.Jooby - Application initialization resulted in exception
java.lang.IllegalArgumentException: Not a primitive type: int
        at jars//io.jooby.internal.reflect.$Types.checkNotPrimitive($Types.java:385)
        at jars//io.jooby.internal.reflect.$Types$ParameterizedTypeImpl.<init>($Types.java:429)
        at jars//io.jooby.internal.reflect.$Types.newParameterizedTypeWithOwner($Types.java:43)
        at jars//io.jooby.Reified.getParameterized(Reified.java:229)
        at kotlin-new-apt//app.Controller_.install(Controller_.kt:70)
        at jars//io.jooby.Jooby.mvc(Jooby.java:533)