Passing a dynamic parameter to an annotation that is processed at compile-time
<p>Consider this example, I'm looking for a general solution to this kind of problem though.</p>

<p>I'm working on an annotation processor that creates interfaces for classes, basically copying all their public mehtods. The name (and package) of the interface can be configured using a String parameter. But because the annotation is <code>@Inherited</code>, there should be the ability to define an <code>InterfaceNamingStrategy</code> that maps the name of a subclass to its interface name.</p>

<p>I tried to use a dynamic annotation parameter following <a href="https://stackoverflow.com/a/16636081/5519485">this answer</a>.</p>

<pre><code>/**
 * Generates an interface that contains all public member mehtods of the annotated class.
 * This can only be used on top-level classes.
 */
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.CLASS)
@Inherited
@Documented
public @interface GenerateInterface {

    /**
     * Name of the generated interface. If this is not specified, the {@link #namingStrategy()}
     * is used to retrieve the interface name.
     * If the name is not fully qualified, the interface will have the same package
     * as the annotated class.
     */
    String value() default "";

    /**
     * An implementation of {@link InterfaceNamingStrategy} that returns the interface name
     * for a given annotated class. It must be accessible and contain a public no-arg constructor.
     */
    Class&lt;? extends InterfaceNamingStrategy&gt; namingStrategy() default InterfaceNamingStrategy.PrefixI.class;

}

/**
 * Naming strategy to be used with {@link GenerateInterface}.
 */
public interface InterfaceNamingStrategy {

    /**
     * @param impl TypeElement representing the annotated class
     * @return the name of the generated interface. See {@link GenerateInterface#value()}.
     */
    String getInterfaceName(TypeElement impl);

    /**
     * Will create the interface {@code Foo} for the annotated class {@code FooImpl}
     */
    public static class ExceptLastFourChars implements InterfaceNamingStrategy {
        @Override
        public String getInterfaceName(TypeElement impl) {
            return impl.getSimpleName().toString().substring(0, impl.getSimpleName().length()-4);
        }
    }

    /**
     * Will create the interface {@code IFoo} for the annotated class {@code Foo}
     */
    public static class PrefixI implements InterfaceNamingStrategy {
        @Override
        public String getInterfaceName(TypeElement impl) {
            return "I" + impl.getSimpleName();
        }
    }
}
</code></pre>

<p>This does, however, not work when processing the annotation at compile-time because you can't instantiate the implementation of <code>InterfaceNamingStrategy</code> as discussed in <a href="https://stackoverflow.com/questions/39222612/how-to-create-an-instance-out-of-a-typemirror/">this question</a>.</p>

<p>Is there any way to pass a dynamic parameter to an annotation that is processed at compile-time?</p>

<p>My current solution would be to use a String parameter and <a href="https://stackoverflow.com/a/6130240/5519485">evaluate it as a Groovy closure</a>. But I would prefer a solution using actual type-checked Java code.</p>