Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jakartaee-platform-dev] Notnull and Nullable annotations on the Jakarta Annotation spec

Good point, Romain!
 I looked into this to see whether any TCKs can be added since it has RUNTIME as its RentionPolicy. I think the annotations Nullable and Nonnull can be used by IDEs. Judging from the javadoc, it has some runtime assertion.

https://github.com/eclipse-ee4j/common-annotations-api/blob/master/api/src/main/java/jakarta/annotation/Nonnull.java#L27

However, I don't think the runtime will be able to force that. I could interprecate the above javadoc:
For a Nonnull field, if it is null, the application will not behave well. It does not force runtime to fail the application when a nonnull field is null when an instance is constructed. Besides, I think forcing the EE container to validate it might lead to a big startup performance hit.

If so, we don't need to do anything else.
Thanks
Emily



On Mon, Apr 25, 2022 at 12:33 PM Romain Manni-Bucau <rmannibucau@xxxxxxxxx> wrote:
Hi

Annotations are optional but I think it is not good to depend on an abandonned spec and strictly speaking, these annotations shouldnt be kept in the code (retention shouldnt be runtime, worse case CLASS as needed by the consuming tools).
That said, since it is not EE annotations but really SE annotations - EE only does not help since it will have holes in the nullability path which means the tools consuming these annotations can't deduce anything from it - so it should be kept off jakarta.annotations which is a runtime bundle and these annotations are not - even the javadoc explicitly states it - IMHO.
Last point is that it is quite misleading in ee-api bundle since bean validations does not know about that.

Hope it helps.

Romain Manni-Bucau
@rmannibucau |  Blog | Old BlogGithub | LinkedIn | Book


Le lun. 25 avr. 2022 à 13:03, Emily Jiang via jakartaee-platform-dev <jakartaee-platform-dev@xxxxxxxxxxx> a écrit :
In Jakarta Common Annotations 2.1, the annotation @Notnull and @Nullable were added to the specification via the issue 90

Normally for other annotations defined in Jakarta Common Annotations, the implementations were provided by other specifications. For the above new annotations, does it mean the implementation for common annotations needs to provide the implementation as I was not sure which specifications pull in these annotations? Does anyone know where the TCKs are for validating the implementation?

--
Thanks
Emily

_______________________________________________
jakartaee-platform-dev mailing list
jakartaee-platform-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jakartaee-platform-dev


--
Thanks
Emily


Back to the top