phax / jcodemodel

A heavily extended fork of the com.sun.codemodel (from 2013/09)
Other
93 stars 34 forks source link

Add support for java 8 annotation targets TYPE_USE and TYPE_PARAMETER #50

Open tsachev opened 7 years ago

tsachev commented 7 years ago

Java 8 adds two new targets for annotations.

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

class MyClass<@NonNull T> {}

<@Immutable T> void process(T message);
stale[bot] commented 5 years ago

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.

fdutton commented 1 year ago

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.

phax commented 1 year ago

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