avaje/avaje-http

Nested parent class not imported in generated server code

Closed this issue · 2 comments

Repost from Discord :)

Using avaje-http and avaje-http-javalin-generator 2.4

The following code,

package my.project.a;

import my.project.b.Foo;

@Controller
public class TestController {
    @Post
    public void foo(Foo.NestedEnum value) {
        System.out.println(value);
    }
package my.project.b;

public class Foo {
    public enum NestedEnum {
        A, B, C
    }
}

produces:

import my.project.b.Foo.PublicSubclass;
import my.project.a.TestController;

@Generated("avaje-javalin-generator")
@Component
public class TestController$Route extends AvajeJavalinPlugin {
...

  private void routes(JavalinDefaultRouting app) {
    app.post("", ctx -> {
      ctx.status(201);
      var value = (Foo.NestedEnum) toEnum(Foo.NestedEnum.class, ctx.queryParam("value")); // <-- error here, "cannot resolve symbol Foo.NestedEnum"
      controller.foo(value);
    });
}

at compile.

But compile fails as the error Unknown class: Foo.NestedEnum is produced since it imports my.project.b.Foo.NestedEnum and not the parent class my.project.b.Foo.

Thank you for your work, love the library :)

Thanks !!! You can try 2.6-RC2 to confirm the fix.

Can confirm fixed. Thank you!