Skip to content

Nested parent class not imported in generated server code #453

Closed
@literallyEllie

Description

@literallyEllie

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 :)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions