[ 
https://issues.apache.org/jira/browse/LOG4J2-1477?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17788572#comment-17788572
 ] 

Matt Sicker commented on LOG4J2-1477:
-------------------------------------

So far, they're just aliases for {{javax.annotation.Nonnull}} just like most 
other implementations, so they all work together just fine. Really, what I'd 
like here are a set of nullability annotations that work similarly but are not 
retained at runtime (which is what the JSR305 version is doing, hence the need 
for annotation aliases) so we don't need the annotation jar as a runtime 
dependency. I'm in favor of whatever solution allows us to keep log4j-api as a 
{{{}java.base{}}}-only module (which itself has required a bit of refactoring 
to push out optional dependencies into more modules). In this case, you'd be 
able to use the normal javax annotations, though we don't want that to be a 
required dependency of the API.

> @NonNull support (for @NonNullByDefault or similar)
> ---------------------------------------------------
>
>                 Key: LOG4J2-1477
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1477
>             Project: Log4j 2
>          Issue Type: Wish
>          Components: API
>    Affects Versions: 2.6.2
>         Environment: any
>            Reporter: Bojan Antonović
>            Assignee: Matt Sicker
>            Priority: Major
>             Fix For: 3.0.0
>
>
> Eclipse (and other tools) offer non-null checks by annotation processing.
> One of the possibilities to enable this is to add the annotation 
> @org.eclipse.jdt.annotation.NonNullByDefault in your package-info.java file.
> Example:
> @org.eclipse.jdt.annotation.NonNullByDefault
> package foo;
> A frequent problem is reported when using a logger:
> private static final Logger LOGGER = LogManager.getLogger(Bla.class);
> for which Eclipse says:
> Null type safety (type annotations): The expression of type 'Logger' needs 
> unchecked conversion to conform to '@NonNull Logger' Bla.java      (...)
> This can by bypassed by putting a @SuppressWarnings("null") over the 
> expression, but this has to be done in every class, and may be the *only* 
> line of code with this workaround.
> Problems:
> - There are other annotations for non-null (javax.annotation.Nonnull) and 
> many other frameworks, like the Checker Framework.
> - I don't want to be a judge which one to choose.
> - Deeper support may require a dependency on Java 8.
> - If you want to do it framework wide, this can be a huge task.
> - As some tools are not mature (IMHO), it will need experiments.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to