jcodemodel icon indicating copy to clipboard operation
jcodemodel copied to clipboard

Add support for java 8 annotation targets TYPE_USE and TYPE_PARAMETER

Open tsachev opened this issue 9 years ago • 3 comments

Java 8 adds two new targets for annotations.

  • TYPE_USE - here are some examples
class MyData implements MyTypedInterface<@Limit(2) MyType> {}

new @Immutable Rock()

(@NonNull String) calculateValue()

void doSomething() throws @Critical IOException();

For all possible 16 type uses refer to https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.11

  • TYPE_PARAMETER - is for declaring type parameters like
class MyClass<@NonNull T> {}

<@Immutable T> void process(T message);

tsachev avatar Jul 22 '16 15:07 tsachev

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 14 '19 23:05 stale[bot]

I have need for this but was able to work around the issue by creating a custom AbstractJType.

If there is interest in resolving this issue, I am willing to submit a pull-request.

However, I think it is likely this would be a breaking change for most of the API since a proper implementation requires separating the concept of type-usage from type-definition. For example, JPrimitiveType and JReferencedClass would no longer extend AbstractJType since they really represent usage of an existing type and not definitions of a new type.

fdutton avatar Oct 22 '22 22:10 fdutton

Yes, feel free to submit a PR - the next update will anyway a major version (4) :)

phax avatar Oct 23 '22 16:10 phax