3

I wrote an annotation processor that creates a subclass. For example, if you have the following code:

@MyAnnotation(Bar.class)
class Foo : MyGenerated_Foo {
}

Then the annotation processor generates:

class MyGenerated_Foo extends Bar {
  ... generate some helpful methods and fields here ...
}

After using this for a while I realized this doesn't work if Bar has a custom constructor. I'd like to create a pass through constructor but I wasn't sure what the best way to do that is.

Here's what I'd like to achieve:

class Bar {
  Bar(String arg) {}
}

@MyAnnotation(Bar.class)
class Foo : MyGenerated_Foo {
  Foo(String arg) {
    MyGenerated_Foo(arg);
  }
}

the above could should generate the following:

class MyGenerated_Foo extends Bar {
  MyGenerated_Bar(String arg) {
    Bar(arg);
  }

  ... generate some helpful methods and fields here ...
}
Sail Nepal
  • 31
  • 1

0 Answers0