I am attempting to use a macro class to implement an SPI interface, and the
implemented class is essentially a registration (a name and an associated
JVM Class) to be read during bootstrap later. I have this implemented in
Java using an annotation processor and Freemarker, interpolating the values
(class name, type name, class literal) and then adding it as a source file.
I'm now making an ASTT to do the same natively in Groovy.

I have MacroClass correctly generating a .class file with the desired
constant values inside the typeName() and typeClass() methods, but it's a
bare Groovy class. When I try to say this:

```
new MacroClass() {
  class TypeReg extends com.example.TypeRegistration {
  }
}
```

the compiler tells me
```
You are not allowed to implement the class 'com.example.TypeRegistration',
use extends instead.
```

I tried various $v incantations, which all produced syntax errors.

In addition, adding `@groovy.transform.CompileStatic` or
`@groovy.transform.stc.POJO` on top of `class TypeReg` results in
```
class groovy.transform.CompileStatic is not an annotation in
@groovy.transform.CompileStatic
```

I'm not particular in what manner I add the "plain POGO" instructions, so
if I can programmatically invoke the behavior, that's fine with me, but I
would prefer to trim the 80% excess bytecode off the generated class.

Reply via email to