You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Xeno Amess <xe...@gmail.com> on 2020/08/25 04:53:35 UTC

Re: opinions about @NotNull and @Nullable ?

Hi.
Today I see a pr have similar ideas with this, so I will suggest we
consider it again.
at [LANG-1598 <https://issues.apache.org/jira/browse/LANG-1598>]
He suggest a google annotations repo, and I'd prefer the one from
jetbrains, but that is not key point.
Key point is, should we consider about adding such Annotations?
Adding such annotations can help:
1. make people who want to modify the function sure whether each
param/return value can be null, and make sure do not change it.
It has better readability than any other ways.
2. make people who invoke these functions have a clear idea whether this
function can return null.
And more importantly maybe, let the ide also knows whether this function
can return null.
That will simplify a lot of human time to check.

Any ideas?

Xeno Amess <xe...@gmail.com> 于2020年4月24日周五 下午6:50写道:

> I want to know about your opinions about @NotNull and @Nullable.
>
> Should we use it in every function?
> Or we use it  only at some misleading places?
> Or simply not use them at all?
>
> thx.
>
>

Re: opinions about @NotNull and @Nullable ?

Posted by Miguel Muñoz <sw...@gmail.com>.
As I see it, the annotations serve two purposes. They clarify for the users
where nulls are legal values, and they allow development tools to leverage
the information to provide more detailed inspections. Some colleagues have
objected to their use claiming that, we don't want to rely on a specific
tool. I've never understood this logic, because we don't actually rely
on the code inspections. The code works either way. The annotations do no
harm, and they often help. That said, I'm glad there's an Eclipse plugin,
even though I don't use Eclipse. (Somehow, they never apply their argument
to tools like FindBugs, even though that uses annotations too.)

IDEs aside, a lot of developers have been using Optional to solve the
problem of null parameters and return values, and it's producing some very
bad code. If anything, simply by specifying in the API where null values
are allowed will do a lot to clarify how APIs should be used. If this
improves the quality of people's code, they will have served their purpose,
regardless of what inspections are used.
— Miguel Muñoz



On Fri, Aug 28, 2020 at 10:15 AM Xeno Amess <xe...@gmail.com> wrote:

> https://imgur.com/gGRHH5i
> https://imgur.com/THMdel1
> 😊
>
> Xeno Amess <xe...@gmail.com> 于2020年8月29日周六 上午12:46写道:
>
> > https://imgur.com/gGRHH5i
> > https://imgur.com/THMdel1
> > will try imgur
> >
> > Gary Gregory <ga...@gmail.com> 于2020年8月29日周六 上午12:44写道:
> >
> >> The PNG links yield Temporary Error (404).
> >>
> >> Gary
> >>
> >> On Fri, Aug 28, 2020 at 12:31 PM Xeno Amess <xe...@gmail.com>
> wrote:
> >>
> >>> @Gary Gregory <ga...@gmail.com>
> >>> the outcome is:
> >>> Eclipse users CAN use those annotations, but MUST install a
> >>> eclipse-plugin to detect those bugs and show them on screen.
> >>> (though both idea and eclipse users CAN choose to use maven plugin to
> do
> >>> it lol)
> >>>
> >>> The plugin is:
> >>> eclipse_2020-08-29_00-28-02.png
> >>> (14 K)
> >>>
> >>> <
> https://mail.google.com/mail/u/0?ui=2&ik=40323997ff&attid=0.1&permmsgid=msg-a:r-2567034696490897823&view=att&disp=safe&realattid=f_keegbc8a0
> >
> >>>
> >>>
> >>> and the outcome gui page is:
> >>> eclipse_2020-08-29_00-30-29.png
> >>> (236 K)
> >>>
> >>> <
> https://mail.google.com/mail/u/0?ui=2&ik=40323997ff&attid=0.2&permmsgid=msg-a:r-2567034696490897823&view=att&disp=safe&realattid=f_keegd69v1
> >
> >>>
> >>>
> >>> Well, it seems at least usable :)
> >>>
> >>> Xeno Amess <xe...@gmail.com> 于2020年8月28日周五 下午11:08写道:
> >>>
> >>>> >  Keep in mind that not everyone uses IJ, for example, I use Eclipse.
> >>>> Yep.
> >>>> And not every jetbrains library requires people use idea.
> >>>> I think Eclipse can supports those annotations.
> >>>> Let me, have a test :)
> >>>>
> >>>>
> >>>> Gary Gregory <ga...@gmail.com> 于2020年8月28日周五 下午11:04写道:
> >>>>
> >>>>> Keep in mind that not everyone uses IJ, for example, I use Eclipse.
> >>>>>
> >>>>> Gary
> >>>>>
> >>>>> On Fri, Aug 28, 2020 at 10:54 AM Xeno Amess <xe...@gmail.com>
> >>>>> wrote:
> >>>>>
> >>>>> > >  IntelliJ specifies Runtime retention so they can interact
> >>>>> > with IntelliJ's internal JRE, which adds additional assertions into
> >>>>> the
> >>>>> > code to enforce the annotations.
> >>>>> >
> >>>>> > seems never.
> >>>>> > see this demo repo.
> >>>>> > https://github.com/XenoAmess/demo_jetbrains_annotation
> >>>>> >
> >>>>> > And I looked up the sources and see every annotation classes be
> >>>>> > with RetentionPolicy.CLASS or RetentionPolicy.SOURCE
> >>>>> >
> >>>>> > HOWEVER, I was talking about org.jetbrainss.annotations.
> >>>>> > but for jsr305, which is google java codes, I will not be very
> >>>>> surprised if
> >>>>> > they have different ideas.
> >>>>> >
> >>>>> > Miguel Muñoz <sw...@gmail.com> 于2020年8月28日周五 下午1:54写道:
> >>>>> >
> >>>>> > > Good question. IntelliJ specifies Runtime retention so they can
> >>>>> interact
> >>>>> > > with IntelliJ's internal JRE, which adds additional assertions
> >>>>> into the
> >>>>> > > code to enforce the annotations. So even though they have Runtime
> >>>>> > > retention, they're still a development-phase tool. In production,
> >>>>> they
> >>>>> > > don't need to be retained at runtime. Personally, I never need
> the
> >>>>> > Runtime
> >>>>> > > retention feature, so if we write our own annotations, we can
> give
> >>>>> them
> >>>>> > > compile-time retention and they'll work fine. That's often how I
> >>>>> work. In
> >>>>> > > fact, I often use my own annotations, which don't have Runtime
> >>>>> retention,
> >>>>> > > and they work fine, so I don't miss that feature.
> >>>>> > >
> >>>>> > > — Miguel Muñoz
> >>>>> > >
> >>>>> > > On Tue, Aug 25, 2020 at 12:36 PM Jochen Wiedmann <
> >>>>> > > jochen.wiedmann@gmail.com>
> >>>>> > > wrote:
> >>>>> > >
> >>>>> > > > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
> >>>>> > > >
> >>>>> > > > > AFAIK that means Maven won't download the dependency.
> >>>>> > > > > Surely that makes it harder for the developer?
> >>>>> > > >
> >>>>> > > > No, it means that Maven won't add the dependency to a
> >>>>> distribution.
> >>>>> > > >
> >>>>> > > > However, I've got a question: These annotations have
> >>>>> > > > @Retention(Runtime). (See
> >>>>> > > >
> >>>>> > > >
> >>>>> > >
> >>>>> >
> >>>>>
> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
> >>>>> > > > .)
> >>>>> > > > Aren't we enforcing the presence of the respective jar at
> >>>>> runtime?
> >>>>> > > >
> >>>>> > > >
> >>>>> > > > Jochen
> >>>>> > > >
> >>>>> > > > --
> >>>>> > > >
> >>>>> > > > Look, that's why there's rules, understand? So that you think
> >>>>> before
> >>>>> > > > you break 'em.
> >>>>> > > >
> >>>>> > > >     -- (Terry Pratchett, Thief of Time)
> >>>>> > > >
> >>>>> > > >
> >>>>> ---------------------------------------------------------------------
> >>>>> > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> >>>>> > > > For additional commands, e-mail: dev-help@commons.apache.org
> >>>>> > > >
> >>>>> > > >
> >>>>> > >
> >>>>> >
> >>>>>
> >>>>
>

Re: opinions about @NotNull and @Nullable ?

Posted by Xeno Amess <xe...@gmail.com>.
https://imgur.com/gGRHH5i
https://imgur.com/THMdel1
😊

Xeno Amess <xe...@gmail.com> 于2020年8月29日周六 上午12:46写道:

> https://imgur.com/gGRHH5i
> https://imgur.com/THMdel1
> will try imgur
>
> Gary Gregory <ga...@gmail.com> 于2020年8月29日周六 上午12:44写道:
>
>> The PNG links yield Temporary Error (404).
>>
>> Gary
>>
>> On Fri, Aug 28, 2020 at 12:31 PM Xeno Amess <xe...@gmail.com> wrote:
>>
>>> @Gary Gregory <ga...@gmail.com>
>>> the outcome is:
>>> Eclipse users CAN use those annotations, but MUST install a
>>> eclipse-plugin to detect those bugs and show them on screen.
>>> (though both idea and eclipse users CAN choose to use maven plugin to do
>>> it lol)
>>>
>>> The plugin is:
>>> eclipse_2020-08-29_00-28-02.png
>>> (14 K)
>>>
>>> <https://mail.google.com/mail/u/0?ui=2&ik=40323997ff&attid=0.1&permmsgid=msg-a:r-2567034696490897823&view=att&disp=safe&realattid=f_keegbc8a0>
>>>
>>>
>>> and the outcome gui page is:
>>> eclipse_2020-08-29_00-30-29.png
>>> (236 K)
>>>
>>> <https://mail.google.com/mail/u/0?ui=2&ik=40323997ff&attid=0.2&permmsgid=msg-a:r-2567034696490897823&view=att&disp=safe&realattid=f_keegd69v1>
>>>
>>>
>>> Well, it seems at least usable :)
>>>
>>> Xeno Amess <xe...@gmail.com> 于2020年8月28日周五 下午11:08写道:
>>>
>>>> >  Keep in mind that not everyone uses IJ, for example, I use Eclipse.
>>>> Yep.
>>>> And not every jetbrains library requires people use idea.
>>>> I think Eclipse can supports those annotations.
>>>> Let me, have a test :)
>>>>
>>>>
>>>> Gary Gregory <ga...@gmail.com> 于2020年8月28日周五 下午11:04写道:
>>>>
>>>>> Keep in mind that not everyone uses IJ, for example, I use Eclipse.
>>>>>
>>>>> Gary
>>>>>
>>>>> On Fri, Aug 28, 2020 at 10:54 AM Xeno Amess <xe...@gmail.com>
>>>>> wrote:
>>>>>
>>>>> > >  IntelliJ specifies Runtime retention so they can interact
>>>>> > with IntelliJ's internal JRE, which adds additional assertions into
>>>>> the
>>>>> > code to enforce the annotations.
>>>>> >
>>>>> > seems never.
>>>>> > see this demo repo.
>>>>> > https://github.com/XenoAmess/demo_jetbrains_annotation
>>>>> >
>>>>> > And I looked up the sources and see every annotation classes be
>>>>> > with RetentionPolicy.CLASS or RetentionPolicy.SOURCE
>>>>> >
>>>>> > HOWEVER, I was talking about org.jetbrainss.annotations.
>>>>> > but for jsr305, which is google java codes, I will not be very
>>>>> surprised if
>>>>> > they have different ideas.
>>>>> >
>>>>> > Miguel Muñoz <sw...@gmail.com> 于2020年8月28日周五 下午1:54写道:
>>>>> >
>>>>> > > Good question. IntelliJ specifies Runtime retention so they can
>>>>> interact
>>>>> > > with IntelliJ's internal JRE, which adds additional assertions
>>>>> into the
>>>>> > > code to enforce the annotations. So even though they have Runtime
>>>>> > > retention, they're still a development-phase tool. In production,
>>>>> they
>>>>> > > don't need to be retained at runtime. Personally, I never need the
>>>>> > Runtime
>>>>> > > retention feature, so if we write our own annotations, we can give
>>>>> them
>>>>> > > compile-time retention and they'll work fine. That's often how I
>>>>> work. In
>>>>> > > fact, I often use my own annotations, which don't have Runtime
>>>>> retention,
>>>>> > > and they work fine, so I don't miss that feature.
>>>>> > >
>>>>> > > — Miguel Muñoz
>>>>> > >
>>>>> > > On Tue, Aug 25, 2020 at 12:36 PM Jochen Wiedmann <
>>>>> > > jochen.wiedmann@gmail.com>
>>>>> > > wrote:
>>>>> > >
>>>>> > > > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
>>>>> > > >
>>>>> > > > > AFAIK that means Maven won't download the dependency.
>>>>> > > > > Surely that makes it harder for the developer?
>>>>> > > >
>>>>> > > > No, it means that Maven won't add the dependency to a
>>>>> distribution.
>>>>> > > >
>>>>> > > > However, I've got a question: These annotations have
>>>>> > > > @Retention(Runtime). (See
>>>>> > > >
>>>>> > > >
>>>>> > >
>>>>> >
>>>>> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
>>>>> > > > .)
>>>>> > > > Aren't we enforcing the presence of the respective jar at
>>>>> runtime?
>>>>> > > >
>>>>> > > >
>>>>> > > > Jochen
>>>>> > > >
>>>>> > > > --
>>>>> > > >
>>>>> > > > Look, that's why there's rules, understand? So that you think
>>>>> before
>>>>> > > > you break 'em.
>>>>> > > >
>>>>> > > >     -- (Terry Pratchett, Thief of Time)
>>>>> > > >
>>>>> > > >
>>>>> ---------------------------------------------------------------------
>>>>> > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>>>> > > > For additional commands, e-mail: dev-help@commons.apache.org
>>>>> > > >
>>>>> > > >
>>>>> > >
>>>>> >
>>>>>
>>>>

Re: opinions about @NotNull and @Nullable ?

Posted by Xeno Amess <xe...@gmail.com>.
https://imgur.com/gGRHH5i
https://imgur.com/THMdel1
will try imgur

Gary Gregory <ga...@gmail.com> 于2020年8月29日周六 上午12:44写道:

> The PNG links yield Temporary Error (404).
>
> Gary
>
> On Fri, Aug 28, 2020 at 12:31 PM Xeno Amess <xe...@gmail.com> wrote:
>
>> @Gary Gregory <ga...@gmail.com>
>> the outcome is:
>> Eclipse users CAN use those annotations, but MUST install a
>> eclipse-plugin to detect those bugs and show them on screen.
>> (though both idea and eclipse users CAN choose to use maven plugin to do
>> it lol)
>>
>> The plugin is:
>> eclipse_2020-08-29_00-28-02.png
>> (14 K)
>>
>> <https://mail.google.com/mail/u/0?ui=2&ik=40323997ff&attid=0.1&permmsgid=msg-a:r-2567034696490897823&view=att&disp=safe&realattid=f_keegbc8a0>
>>
>>
>> and the outcome gui page is:
>> eclipse_2020-08-29_00-30-29.png
>> (236 K)
>>
>> <https://mail.google.com/mail/u/0?ui=2&ik=40323997ff&attid=0.2&permmsgid=msg-a:r-2567034696490897823&view=att&disp=safe&realattid=f_keegd69v1>
>>
>>
>> Well, it seems at least usable :)
>>
>> Xeno Amess <xe...@gmail.com> 于2020年8月28日周五 下午11:08写道:
>>
>>> >  Keep in mind that not everyone uses IJ, for example, I use Eclipse.
>>> Yep.
>>> And not every jetbrains library requires people use idea.
>>> I think Eclipse can supports those annotations.
>>> Let me, have a test :)
>>>
>>>
>>> Gary Gregory <ga...@gmail.com> 于2020年8月28日周五 下午11:04写道:
>>>
>>>> Keep in mind that not everyone uses IJ, for example, I use Eclipse.
>>>>
>>>> Gary
>>>>
>>>> On Fri, Aug 28, 2020 at 10:54 AM Xeno Amess <xe...@gmail.com>
>>>> wrote:
>>>>
>>>> > >  IntelliJ specifies Runtime retention so they can interact
>>>> > with IntelliJ's internal JRE, which adds additional assertions into
>>>> the
>>>> > code to enforce the annotations.
>>>> >
>>>> > seems never.
>>>> > see this demo repo.
>>>> > https://github.com/XenoAmess/demo_jetbrains_annotation
>>>> >
>>>> > And I looked up the sources and see every annotation classes be
>>>> > with RetentionPolicy.CLASS or RetentionPolicy.SOURCE
>>>> >
>>>> > HOWEVER, I was talking about org.jetbrainss.annotations.
>>>> > but for jsr305, which is google java codes, I will not be very
>>>> surprised if
>>>> > they have different ideas.
>>>> >
>>>> > Miguel Muñoz <sw...@gmail.com> 于2020年8月28日周五 下午1:54写道:
>>>> >
>>>> > > Good question. IntelliJ specifies Runtime retention so they can
>>>> interact
>>>> > > with IntelliJ's internal JRE, which adds additional assertions into
>>>> the
>>>> > > code to enforce the annotations. So even though they have Runtime
>>>> > > retention, they're still a development-phase tool. In production,
>>>> they
>>>> > > don't need to be retained at runtime. Personally, I never need the
>>>> > Runtime
>>>> > > retention feature, so if we write our own annotations, we can give
>>>> them
>>>> > > compile-time retention and they'll work fine. That's often how I
>>>> work. In
>>>> > > fact, I often use my own annotations, which don't have Runtime
>>>> retention,
>>>> > > and they work fine, so I don't miss that feature.
>>>> > >
>>>> > > — Miguel Muñoz
>>>> > >
>>>> > > On Tue, Aug 25, 2020 at 12:36 PM Jochen Wiedmann <
>>>> > > jochen.wiedmann@gmail.com>
>>>> > > wrote:
>>>> > >
>>>> > > > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
>>>> > > >
>>>> > > > > AFAIK that means Maven won't download the dependency.
>>>> > > > > Surely that makes it harder for the developer?
>>>> > > >
>>>> > > > No, it means that Maven won't add the dependency to a
>>>> distribution.
>>>> > > >
>>>> > > > However, I've got a question: These annotations have
>>>> > > > @Retention(Runtime). (See
>>>> > > >
>>>> > > >
>>>> > >
>>>> >
>>>> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
>>>> > > > .)
>>>> > > > Aren't we enforcing the presence of the respective jar at runtime?
>>>> > > >
>>>> > > >
>>>> > > > Jochen
>>>> > > >
>>>> > > > --
>>>> > > >
>>>> > > > Look, that's why there's rules, understand? So that you think
>>>> before
>>>> > > > you break 'em.
>>>> > > >
>>>> > > >     -- (Terry Pratchett, Thief of Time)
>>>> > > >
>>>> > > >
>>>> ---------------------------------------------------------------------
>>>> > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>>> > > > For additional commands, e-mail: dev-help@commons.apache.org
>>>> > > >
>>>> > > >
>>>> > >
>>>> >
>>>>
>>>

Re: opinions about @NotNull and @Nullable ?

Posted by Gary Gregory <ga...@gmail.com>.
The PNG links yield Temporary Error (404).

Gary

On Fri, Aug 28, 2020 at 12:31 PM Xeno Amess <xe...@gmail.com> wrote:

> @Gary Gregory <ga...@gmail.com>
> the outcome is:
> Eclipse users CAN use those annotations, but MUST install a eclipse-plugin
> to detect those bugs and show them on screen.
> (though both idea and eclipse users CAN choose to use maven plugin to do
> it lol)
>
> The plugin is:
> eclipse_2020-08-29_00-28-02.png
> (14 K)
>
> <https://mail.google.com/mail/u/0?ui=2&ik=40323997ff&attid=0.1&permmsgid=msg-a:r-2567034696490897823&view=att&disp=safe&realattid=f_keegbc8a0>
>
>
> and the outcome gui page is:
> eclipse_2020-08-29_00-30-29.png
> (236 K)
>
> <https://mail.google.com/mail/u/0?ui=2&ik=40323997ff&attid=0.2&permmsgid=msg-a:r-2567034696490897823&view=att&disp=safe&realattid=f_keegd69v1>
>
>
> Well, it seems at least usable :)
>
> Xeno Amess <xe...@gmail.com> 于2020年8月28日周五 下午11:08写道:
>
>> >  Keep in mind that not everyone uses IJ, for example, I use Eclipse.
>> Yep.
>> And not every jetbrains library requires people use idea.
>> I think Eclipse can supports those annotations.
>> Let me, have a test :)
>>
>>
>> Gary Gregory <ga...@gmail.com> 于2020年8月28日周五 下午11:04写道:
>>
>>> Keep in mind that not everyone uses IJ, for example, I use Eclipse.
>>>
>>> Gary
>>>
>>> On Fri, Aug 28, 2020 at 10:54 AM Xeno Amess <xe...@gmail.com> wrote:
>>>
>>> > >  IntelliJ specifies Runtime retention so they can interact
>>> > with IntelliJ's internal JRE, which adds additional assertions into the
>>> > code to enforce the annotations.
>>> >
>>> > seems never.
>>> > see this demo repo.
>>> > https://github.com/XenoAmess/demo_jetbrains_annotation
>>> >
>>> > And I looked up the sources and see every annotation classes be
>>> > with RetentionPolicy.CLASS or RetentionPolicy.SOURCE
>>> >
>>> > HOWEVER, I was talking about org.jetbrainss.annotations.
>>> > but for jsr305, which is google java codes, I will not be very
>>> surprised if
>>> > they have different ideas.
>>> >
>>> > Miguel Muñoz <sw...@gmail.com> 于2020年8月28日周五 下午1:54写道:
>>> >
>>> > > Good question. IntelliJ specifies Runtime retention so they can
>>> interact
>>> > > with IntelliJ's internal JRE, which adds additional assertions into
>>> the
>>> > > code to enforce the annotations. So even though they have Runtime
>>> > > retention, they're still a development-phase tool. In production,
>>> they
>>> > > don't need to be retained at runtime. Personally, I never need the
>>> > Runtime
>>> > > retention feature, so if we write our own annotations, we can give
>>> them
>>> > > compile-time retention and they'll work fine. That's often how I
>>> work. In
>>> > > fact, I often use my own annotations, which don't have Runtime
>>> retention,
>>> > > and they work fine, so I don't miss that feature.
>>> > >
>>> > > — Miguel Muñoz
>>> > >
>>> > > On Tue, Aug 25, 2020 at 12:36 PM Jochen Wiedmann <
>>> > > jochen.wiedmann@gmail.com>
>>> > > wrote:
>>> > >
>>> > > > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
>>> > > >
>>> > > > > AFAIK that means Maven won't download the dependency.
>>> > > > > Surely that makes it harder for the developer?
>>> > > >
>>> > > > No, it means that Maven won't add the dependency to a distribution.
>>> > > >
>>> > > > However, I've got a question: These annotations have
>>> > > > @Retention(Runtime). (See
>>> > > >
>>> > > >
>>> > >
>>> >
>>> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
>>> > > > .)
>>> > > > Aren't we enforcing the presence of the respective jar at runtime?
>>> > > >
>>> > > >
>>> > > > Jochen
>>> > > >
>>> > > > --
>>> > > >
>>> > > > Look, that's why there's rules, understand? So that you think
>>> before
>>> > > > you break 'em.
>>> > > >
>>> > > >     -- (Terry Pratchett, Thief of Time)
>>> > > >
>>> > > >
>>> ---------------------------------------------------------------------
>>> > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>> > > > For additional commands, e-mail: dev-help@commons.apache.org
>>> > > >
>>> > > >
>>> > >
>>> >
>>>
>>

Re: opinions about @NotNull and @Nullable ?

Posted by Xeno Amess <xe...@gmail.com>.
@Gary Gregory <ga...@gmail.com>
the outcome is:
Eclipse users CAN use those annotations, but MUST install a eclipse-plugin
to detect those bugs and show them on screen.
(though both idea and eclipse users CAN choose to use maven plugin to do it
lol)

The plugin is:
eclipse_2020-08-29_00-28-02.png
(14 K)
<https://mail.google.com/mail/u/0?ui=2&ik=40323997ff&attid=0.1&permmsgid=msg-a:r-2567034696490897823&view=att&disp=safe&realattid=f_keegbc8a0>


and the outcome gui page is:
eclipse_2020-08-29_00-30-29.png
(236 K)
<https://mail.google.com/mail/u/0?ui=2&ik=40323997ff&attid=0.2&permmsgid=msg-a:r-2567034696490897823&view=att&disp=safe&realattid=f_keegd69v1>


Well, it seems at least usable :)

Xeno Amess <xe...@gmail.com> 于2020年8月28日周五 下午11:08写道:

> >  Keep in mind that not everyone uses IJ, for example, I use Eclipse.
> Yep.
> And not every jetbrains library requires people use idea.
> I think Eclipse can supports those annotations.
> Let me, have a test :)
>
>
> Gary Gregory <ga...@gmail.com> 于2020年8月28日周五 下午11:04写道:
>
>> Keep in mind that not everyone uses IJ, for example, I use Eclipse.
>>
>> Gary
>>
>> On Fri, Aug 28, 2020 at 10:54 AM Xeno Amess <xe...@gmail.com> wrote:
>>
>> > >  IntelliJ specifies Runtime retention so they can interact
>> > with IntelliJ's internal JRE, which adds additional assertions into the
>> > code to enforce the annotations.
>> >
>> > seems never.
>> > see this demo repo.
>> > https://github.com/XenoAmess/demo_jetbrains_annotation
>> >
>> > And I looked up the sources and see every annotation classes be
>> > with RetentionPolicy.CLASS or RetentionPolicy.SOURCE
>> >
>> > HOWEVER, I was talking about org.jetbrainss.annotations.
>> > but for jsr305, which is google java codes, I will not be very
>> surprised if
>> > they have different ideas.
>> >
>> > Miguel Muñoz <sw...@gmail.com> 于2020年8月28日周五 下午1:54写道:
>> >
>> > > Good question. IntelliJ specifies Runtime retention so they can
>> interact
>> > > with IntelliJ's internal JRE, which adds additional assertions into
>> the
>> > > code to enforce the annotations. So even though they have Runtime
>> > > retention, they're still a development-phase tool. In production, they
>> > > don't need to be retained at runtime. Personally, I never need the
>> > Runtime
>> > > retention feature, so if we write our own annotations, we can give
>> them
>> > > compile-time retention and they'll work fine. That's often how I
>> work. In
>> > > fact, I often use my own annotations, which don't have Runtime
>> retention,
>> > > and they work fine, so I don't miss that feature.
>> > >
>> > > — Miguel Muñoz
>> > >
>> > > On Tue, Aug 25, 2020 at 12:36 PM Jochen Wiedmann <
>> > > jochen.wiedmann@gmail.com>
>> > > wrote:
>> > >
>> > > > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
>> > > >
>> > > > > AFAIK that means Maven won't download the dependency.
>> > > > > Surely that makes it harder for the developer?
>> > > >
>> > > > No, it means that Maven won't add the dependency to a distribution.
>> > > >
>> > > > However, I've got a question: These annotations have
>> > > > @Retention(Runtime). (See
>> > > >
>> > > >
>> > >
>> >
>> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
>> > > > .)
>> > > > Aren't we enforcing the presence of the respective jar at runtime?
>> > > >
>> > > >
>> > > > Jochen
>> > > >
>> > > > --
>> > > >
>> > > > Look, that's why there's rules, understand? So that you think before
>> > > > you break 'em.
>> > > >
>> > > >     -- (Terry Pratchett, Thief of Time)
>> > > >
>> > > >
>> ---------------------------------------------------------------------
>> > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> > > > For additional commands, e-mail: dev-help@commons.apache.org
>> > > >
>> > > >
>> > >
>> >
>>
>

Re: opinions about @NotNull and @Nullable ?

Posted by Xeno Amess <xe...@gmail.com>.
>  Keep in mind that not everyone uses IJ, for example, I use Eclipse.
Yep.
And not every jetbrains library requires people use idea.
I think Eclipse can supports those annotations.
Let me, have a test :)


Gary Gregory <ga...@gmail.com> 于2020年8月28日周五 下午11:04写道:

> Keep in mind that not everyone uses IJ, for example, I use Eclipse.
>
> Gary
>
> On Fri, Aug 28, 2020 at 10:54 AM Xeno Amess <xe...@gmail.com> wrote:
>
> > >  IntelliJ specifies Runtime retention so they can interact
> > with IntelliJ's internal JRE, which adds additional assertions into the
> > code to enforce the annotations.
> >
> > seems never.
> > see this demo repo.
> > https://github.com/XenoAmess/demo_jetbrains_annotation
> >
> > And I looked up the sources and see every annotation classes be
> > with RetentionPolicy.CLASS or RetentionPolicy.SOURCE
> >
> > HOWEVER, I was talking about org.jetbrainss.annotations.
> > but for jsr305, which is google java codes, I will not be very surprised
> if
> > they have different ideas.
> >
> > Miguel Muñoz <sw...@gmail.com> 于2020年8月28日周五 下午1:54写道:
> >
> > > Good question. IntelliJ specifies Runtime retention so they can
> interact
> > > with IntelliJ's internal JRE, which adds additional assertions into the
> > > code to enforce the annotations. So even though they have Runtime
> > > retention, they're still a development-phase tool. In production, they
> > > don't need to be retained at runtime. Personally, I never need the
> > Runtime
> > > retention feature, so if we write our own annotations, we can give them
> > > compile-time retention and they'll work fine. That's often how I work.
> In
> > > fact, I often use my own annotations, which don't have Runtime
> retention,
> > > and they work fine, so I don't miss that feature.
> > >
> > > — Miguel Muñoz
> > >
> > > On Tue, Aug 25, 2020 at 12:36 PM Jochen Wiedmann <
> > > jochen.wiedmann@gmail.com>
> > > wrote:
> > >
> > > > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
> > > >
> > > > > AFAIK that means Maven won't download the dependency.
> > > > > Surely that makes it harder for the developer?
> > > >
> > > > No, it means that Maven won't add the dependency to a distribution.
> > > >
> > > > However, I've got a question: These annotations have
> > > > @Retention(Runtime). (See
> > > >
> > > >
> > >
> >
> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
> > > > .)
> > > > Aren't we enforcing the presence of the respective jar at runtime?
> > > >
> > > >
> > > > Jochen
> > > >
> > > > --
> > > >
> > > > Look, that's why there's rules, understand? So that you think before
> > > > you break 'em.
> > > >
> > > >     -- (Terry Pratchett, Thief of Time)
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > > For additional commands, e-mail: dev-help@commons.apache.org
> > > >
> > > >
> > >
> >
>

Re: opinions about @NotNull and @Nullable ?

Posted by Gary Gregory <ga...@gmail.com>.
Keep in mind that not everyone uses IJ, for example, I use Eclipse.

Gary

On Fri, Aug 28, 2020 at 10:54 AM Xeno Amess <xe...@gmail.com> wrote:

> >  IntelliJ specifies Runtime retention so they can interact
> with IntelliJ's internal JRE, which adds additional assertions into the
> code to enforce the annotations.
>
> seems never.
> see this demo repo.
> https://github.com/XenoAmess/demo_jetbrains_annotation
>
> And I looked up the sources and see every annotation classes be
> with RetentionPolicy.CLASS or RetentionPolicy.SOURCE
>
> HOWEVER, I was talking about org.jetbrainss.annotations.
> but for jsr305, which is google java codes, I will not be very surprised if
> they have different ideas.
>
> Miguel Muñoz <sw...@gmail.com> 于2020年8月28日周五 下午1:54写道:
>
> > Good question. IntelliJ specifies Runtime retention so they can interact
> > with IntelliJ's internal JRE, which adds additional assertions into the
> > code to enforce the annotations. So even though they have Runtime
> > retention, they're still a development-phase tool. In production, they
> > don't need to be retained at runtime. Personally, I never need the
> Runtime
> > retention feature, so if we write our own annotations, we can give them
> > compile-time retention and they'll work fine. That's often how I work. In
> > fact, I often use my own annotations, which don't have Runtime retention,
> > and they work fine, so I don't miss that feature.
> >
> > — Miguel Muñoz
> >
> > On Tue, Aug 25, 2020 at 12:36 PM Jochen Wiedmann <
> > jochen.wiedmann@gmail.com>
> > wrote:
> >
> > > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
> > >
> > > > AFAIK that means Maven won't download the dependency.
> > > > Surely that makes it harder for the developer?
> > >
> > > No, it means that Maven won't add the dependency to a distribution.
> > >
> > > However, I've got a question: These annotations have
> > > @Retention(Runtime). (See
> > >
> > >
> >
> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
> > > .)
> > > Aren't we enforcing the presence of the respective jar at runtime?
> > >
> > >
> > > Jochen
> > >
> > > --
> > >
> > > Look, that's why there's rules, understand? So that you think before
> > > you break 'em.
> > >
> > >     -- (Terry Pratchett, Thief of Time)
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > For additional commands, e-mail: dev-help@commons.apache.org
> > >
> > >
> >
>

Re: opinions about @NotNull and @Nullable ?

Posted by Miguel Muñoz <sw...@gmail.com>.
Thank you for pointing that out. The IntelliJ annotations used to have
Runtime retention, but they now have Class retention.

— Miguel Muñoz

On Fri, Aug 28, 2020 at 7:54 AM Xeno Amess <xe...@gmail.com> wrote:

> >  IntelliJ specifies Runtime retention so they can interact
> with IntelliJ's internal JRE, which adds additional assertions into the
> code to enforce the annotations.
>
> seems never.
> see this demo repo.
> https://github.com/XenoAmess/demo_jetbrains_annotation
>
> And I looked up the sources and see every annotation classes be
> with RetentionPolicy.CLASS or RetentionPolicy.SOURCE
>
> HOWEVER, I was talking about org.jetbrainss.annotations.
> but for jsr305, which is google java codes, I will not be very surprised if
> they have different ideas.
>
> Miguel Muñoz <sw...@gmail.com> 于2020年8月28日周五 下午1:54写道:
>
> > Good question. IntelliJ specifies Runtime retention so they can interact
> > with IntelliJ's internal JRE, which adds additional assertions into the
> > code to enforce the annotations. So even though they have Runtime
> > retention, they're still a development-phase tool. In production, they
> > don't need to be retained at runtime. Personally, I never need the
> Runtime
> > retention feature, so if we write our own annotations, we can give them
> > compile-time retention and they'll work fine. That's often how I work. In
> > fact, I often use my own annotations, which don't have Runtime retention,
> > and they work fine, so I don't miss that feature.
> >
> > — Miguel Muñoz
> >
> > On Tue, Aug 25, 2020 at 12:36 PM Jochen Wiedmann <
> > jochen.wiedmann@gmail.com>
> > wrote:
> >
> > > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
> > >
> > > > AFAIK that means Maven won't download the dependency.
> > > > Surely that makes it harder for the developer?
> > >
> > > No, it means that Maven won't add the dependency to a distribution.
> > >
> > > However, I've got a question: These annotations have
> > > @Retention(Runtime). (See
> > >
> > >
> >
> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
> > > .)
> > > Aren't we enforcing the presence of the respective jar at runtime?
> > >
> > >
> > > Jochen
> > >
> > > --
> > >
> > > Look, that's why there's rules, understand? So that you think before
> > > you break 'em.
> > >
> > >     -- (Terry Pratchett, Thief of Time)
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > For additional commands, e-mail: dev-help@commons.apache.org
> > >
> > >
> >
>

Re: opinions about @NotNull and @Nullable ?

Posted by Xeno Amess <xe...@gmail.com>.
>  IntelliJ specifies Runtime retention so they can interact
with IntelliJ's internal JRE, which adds additional assertions into the
code to enforce the annotations.

seems never.
see this demo repo.
https://github.com/XenoAmess/demo_jetbrains_annotation

And I looked up the sources and see every annotation classes be
with RetentionPolicy.CLASS or RetentionPolicy.SOURCE

HOWEVER, I was talking about org.jetbrainss.annotations.
but for jsr305, which is google java codes, I will not be very surprised if
they have different ideas.

Miguel Muñoz <sw...@gmail.com> 于2020年8月28日周五 下午1:54写道:

> Good question. IntelliJ specifies Runtime retention so they can interact
> with IntelliJ's internal JRE, which adds additional assertions into the
> code to enforce the annotations. So even though they have Runtime
> retention, they're still a development-phase tool. In production, they
> don't need to be retained at runtime. Personally, I never need the Runtime
> retention feature, so if we write our own annotations, we can give them
> compile-time retention and they'll work fine. That's often how I work. In
> fact, I often use my own annotations, which don't have Runtime retention,
> and they work fine, so I don't miss that feature.
>
> — Miguel Muñoz
>
> On Tue, Aug 25, 2020 at 12:36 PM Jochen Wiedmann <
> jochen.wiedmann@gmail.com>
> wrote:
>
> > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
> >
> > > AFAIK that means Maven won't download the dependency.
> > > Surely that makes it harder for the developer?
> >
> > No, it means that Maven won't add the dependency to a distribution.
> >
> > However, I've got a question: These annotations have
> > @Retention(Runtime). (See
> >
> >
> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
> > .)
> > Aren't we enforcing the presence of the respective jar at runtime?
> >
> >
> > Jochen
> >
> > --
> >
> > Look, that's why there's rules, understand? So that you think before
> > you break 'em.
> >
> >     -- (Terry Pratchett, Thief of Time)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
>

Re: opinions about @NotNull and @Nullable ?

Posted by Miguel Muñoz <sw...@gmail.com>.
Good question. IntelliJ specifies Runtime retention so they can interact
with IntelliJ's internal JRE, which adds additional assertions into the
code to enforce the annotations. So even though they have Runtime
retention, they're still a development-phase tool. In production, they
don't need to be retained at runtime. Personally, I never need the Runtime
retention feature, so if we write our own annotations, we can give them
compile-time retention and they'll work fine. That's often how I work. In
fact, I often use my own annotations, which don't have Runtime retention,
and they work fine, so I don't miss that feature.

— Miguel Muñoz

On Tue, Aug 25, 2020 at 12:36 PM Jochen Wiedmann <jo...@gmail.com>
wrote:

> On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
>
> > AFAIK that means Maven won't download the dependency.
> > Surely that makes it harder for the developer?
>
> No, it means that Maven won't add the dependency to a distribution.
>
> However, I've got a question: These annotations have
> @Retention(Runtime). (See
>
> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
> .)
> Aren't we enforcing the presence of the respective jar at runtime?
>
>
> Jochen
>
> --
>
> Look, that's why there's rules, understand? So that you think before
> you break 'em.
>
>     -- (Terry Pratchett, Thief of Time)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

Re: opinions about @NotNull and @Nullable ?

Posted by Miguel Muñoz <sw...@gmail.com>.
I find them to be useful in two ways.
1) The document which parameters and return values may be null, and which
can't.

2) I use them in conjunction with IntelliJ's Constant Conditions and
Exceptions inspection. (This inspection lets me specify what annotations to
use for Nullable and NotNull, so I'm not restricted to IntelliJ's
annotations.
When I use it this way, I usually default to @NotNull, so I only need to
specify @Nullable.
Also, I use them in combination with their @Contract annotation. When I do
this, I get a lot of blowback from other developers, because it smells like
Design-By-Contract. It's actually a (small) subset of Design by Contract.
I've used Design by Contract, and it's a pain in the buns. But I've also
used IntelliJ's subset of DOC, and it's very easy. Contract is mainly
useful when you want to specify under what conditions a method will throw
an Exception. So if a null input parameter always throws an Exception, you
can specify this in a Contract, which helps IntelliJ track nullability
problems. I'm not sure we should use it in Apache's code.

— Miguel Muñoz

On Wed, Aug 26, 2020 at 6:48 AM Matt Sicker <bo...@gmail.com> wrote:

> FindBugs and SpotBugs support the annotations. I mentioned that instead of
> the javax package version of the annotations for the JPMS reason mentioned
> by someone else earlier. That’s what we’re using in Jenkins (along with a
> mix of which annotation sets are used, but that’s the nature of a plugin
> ecosystem), and it works for downstream users, too.
>
> On Wed, Aug 26, 2020 at 08:40 Gary Gregory <ga...@gmail.com> wrote:
>
> > Does SpotBugs use these annotations? If not, can SB make use of any
> >
> > annotations?
> >
> >
> >
> > Gary
> >
> >
> >
> > On Wed, Aug 26, 2020 at 2:30 AM Romain Manni-Bucau <
> rmannibucau@gmail.com>
> >
> > wrote:
> >
> >
> >
> > > For what it is worth:
> >
> > >
> >
> > > 1. Generally speaking - and IMHO - these annotations only make sense
> in a
> >
> > > particular tooling setup(s) - like considering values which can be null
> > by
> >
> > > code analysis and not by spec (@NotNull) - which I'm not sure we have
> so
> > it
> >
> > > is mainly about making it consumer friendly but how do we guarantee our
> >
> > > meta are right and don't create false positives? Until we can guarantee
> > it,
> >
> > > it sounds like we can only bring drawbacks by adding it and users can
> >
> > > trivially solve it since if he already uses @NotNull he puts it in his
> > code
> >
> > > at a higher level anyway.
> >
> > > 2. Please don't use javax.annotation.* since, thanks JPMS, it can make
> > the
> >
> > > code not compilable on java >= 9 - a package must be owned by a single
> >
> > > module. (Not)Nullable  static check is generally about the annotation
> >
> > > simple name and not the package so you can just duplicate the 1-2
> >
> > > annotations you want in [lang], it is a saner compromise in today's
> >
> > > ecosystem.
> >
> > >
> >
> > > Romain Manni-Bucau
> >
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> >
> > > <https://rmannibucau.metawerx.net/> | Old Blog
> >
> > > <http://rmannibucau.wordpress.com> | Github <
> >
> > > https://github.com/rmannibucau> |
> >
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> >
> > > <
> >
> > >
> >
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> >
> > > >
> >
> > >
> >
> > >
> >
> > > Le mer. 26 août 2020 à 01:30, Matt Sicker <bo...@gmail.com> a écrit :
> >
> > >
> >
> > > > Runtime retention still doesn’t require the annotations to be present
> > on
> >
> > > > the classpath unless you perform reflection on them (I forget the
> >
> > > > specifics). It’s a feature specific to annotations.
> >
> > > >
> >
> > > > On Tue, Aug 25, 2020 at 14:36 Jochen Wiedmann <
> > jochen.wiedmann@gmail.com
> >
> > > >
> >
> > > > wrote:
> >
> > > >
> >
> > > > > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
> >
> > > > >
> >
> > > > >
> >
> > > > >
> >
> > > > > > AFAIK that means Maven won't download the dependency.
> >
> > > > >
> >
> > > > > > Surely that makes it harder for the developer?
> >
> > > > >
> >
> > > > >
> >
> > > > >
> >
> > > > > No, it means that Maven won't add the dependency to a distribution.
> >
> > > > >
> >
> > > > >
> >
> > > > >
> >
> > > > > However, I've got a question: These annotations have
> >
> > > > >
> >
> > > > > @Retention(Runtime). (See
> >
> > > > >
> >
> > > > >
> >
> > > > >
> >
> > > >
> >
> > >
> >
> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
> >
> > > > > .)
> >
> > > > >
> >
> > > > > Aren't we enforcing the presence of the respective jar at runtime?
> >
> > > > >
> >
> > > > >
> >
> > > > >
> >
> > > > >
> >
> > > > >
> >
> > > > > Jochen
> >
> > > > >
> >
> > > > >
> >
> > > > >
> >
> > > > > --
> >
> > > > >
> >
> > > > >
> >
> > > > >
> >
> > > > > Look, that's why there's rules, understand? So that you think
> before
> >
> > > > >
> >
> > > > > you break 'em.
> >
> > > > >
> >
> > > > >
> >
> > > > >
> >
> > > > >     -- (Terry Pratchett, Thief of Time)
> >
> > > > >
> >
> > > > >
> >
> > > > >
> >
> > > > >
> ---------------------------------------------------------------------
> >
> > > > >
> >
> > > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> >
> > > > >
> >
> > > > > For additional commands, e-mail: dev-help@commons.apache.org
> >
> > > > >
> >
> > > > >
> >
> > > > >
> >
> > > > > --
> >
> > > > Matt Sicker <bo...@gmail.com>
> >
> > > >
> >
> > >
> >
> > --
> Matt Sicker <bo...@gmail.com>
>

Re: opinions about @NotNull and @Nullable ?

Posted by Matt Sicker <bo...@gmail.com>.
FindBugs and SpotBugs support the annotations. I mentioned that instead of
the javax package version of the annotations for the JPMS reason mentioned
by someone else earlier. That’s what we’re using in Jenkins (along with a
mix of which annotation sets are used, but that’s the nature of a plugin
ecosystem), and it works for downstream users, too.

On Wed, Aug 26, 2020 at 08:40 Gary Gregory <ga...@gmail.com> wrote:

> Does SpotBugs use these annotations? If not, can SB make use of any
>
> annotations?
>
>
>
> Gary
>
>
>
> On Wed, Aug 26, 2020 at 2:30 AM Romain Manni-Bucau <rm...@gmail.com>
>
> wrote:
>
>
>
> > For what it is worth:
>
> >
>
> > 1. Generally speaking - and IMHO - these annotations only make sense in a
>
> > particular tooling setup(s) - like considering values which can be null
> by
>
> > code analysis and not by spec (@NotNull) - which I'm not sure we have so
> it
>
> > is mainly about making it consumer friendly but how do we guarantee our
>
> > meta are right and don't create false positives? Until we can guarantee
> it,
>
> > it sounds like we can only bring drawbacks by adding it and users can
>
> > trivially solve it since if he already uses @NotNull he puts it in his
> code
>
> > at a higher level anyway.
>
> > 2. Please don't use javax.annotation.* since, thanks JPMS, it can make
> the
>
> > code not compilable on java >= 9 - a package must be owned by a single
>
> > module. (Not)Nullable  static check is generally about the annotation
>
> > simple name and not the package so you can just duplicate the 1-2
>
> > annotations you want in [lang], it is a saner compromise in today's
>
> > ecosystem.
>
> >
>
> > Romain Manni-Bucau
>
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>
> > <https://rmannibucau.metawerx.net/> | Old Blog
>
> > <http://rmannibucau.wordpress.com> | Github <
>
> > https://github.com/rmannibucau> |
>
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
>
> > <
>
> >
> https://www.packtpub.com/application-development/java-ee-8-high-performance
>
> > >
>
> >
>
> >
>
> > Le mer. 26 août 2020 à 01:30, Matt Sicker <bo...@gmail.com> a écrit :
>
> >
>
> > > Runtime retention still doesn’t require the annotations to be present
> on
>
> > > the classpath unless you perform reflection on them (I forget the
>
> > > specifics). It’s a feature specific to annotations.
>
> > >
>
> > > On Tue, Aug 25, 2020 at 14:36 Jochen Wiedmann <
> jochen.wiedmann@gmail.com
>
> > >
>
> > > wrote:
>
> > >
>
> > > > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
>
> > > >
>
> > > >
>
> > > >
>
> > > > > AFAIK that means Maven won't download the dependency.
>
> > > >
>
> > > > > Surely that makes it harder for the developer?
>
> > > >
>
> > > >
>
> > > >
>
> > > > No, it means that Maven won't add the dependency to a distribution.
>
> > > >
>
> > > >
>
> > > >
>
> > > > However, I've got a question: These annotations have
>
> > > >
>
> > > > @Retention(Runtime). (See
>
> > > >
>
> > > >
>
> > > >
>
> > >
>
> >
> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
>
> > > > .)
>
> > > >
>
> > > > Aren't we enforcing the presence of the respective jar at runtime?
>
> > > >
>
> > > >
>
> > > >
>
> > > >
>
> > > >
>
> > > > Jochen
>
> > > >
>
> > > >
>
> > > >
>
> > > > --
>
> > > >
>
> > > >
>
> > > >
>
> > > > Look, that's why there's rules, understand? So that you think before
>
> > > >
>
> > > > you break 'em.
>
> > > >
>
> > > >
>
> > > >
>
> > > >     -- (Terry Pratchett, Thief of Time)
>
> > > >
>
> > > >
>
> > > >
>
> > > > ---------------------------------------------------------------------
>
> > > >
>
> > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>
> > > >
>
> > > > For additional commands, e-mail: dev-help@commons.apache.org
>
> > > >
>
> > > >
>
> > > >
>
> > > > --
>
> > > Matt Sicker <bo...@gmail.com>
>
> > >
>
> >
>
> --
Matt Sicker <bo...@gmail.com>

Re: opinions about @NotNull and @Nullable ?

Posted by Gary Gregory <ga...@gmail.com>.
Does SpotBugs use these annotations? If not, can SB make use of any
annotations?

Gary

On Wed, Aug 26, 2020 at 2:30 AM Romain Manni-Bucau <rm...@gmail.com>
wrote:

> For what it is worth:
>
> 1. Generally speaking - and IMHO - these annotations only make sense in a
> particular tooling setup(s) - like considering values which can be null by
> code analysis and not by spec (@NotNull) - which I'm not sure we have so it
> is mainly about making it consumer friendly but how do we guarantee our
> meta are right and don't create false positives? Until we can guarantee it,
> it sounds like we can only bring drawbacks by adding it and users can
> trivially solve it since if he already uses @NotNull he puts it in his code
> at a higher level anyway.
> 2. Please don't use javax.annotation.* since, thanks JPMS, it can make the
> code not compilable on java >= 9 - a package must be owned by a single
> module. (Not)Nullable  static check is generally about the annotation
> simple name and not the package so you can just duplicate the 1-2
> annotations you want in [lang], it is a saner compromise in today's
> ecosystem.
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> <
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> >
>
>
> Le mer. 26 août 2020 à 01:30, Matt Sicker <bo...@gmail.com> a écrit :
>
> > Runtime retention still doesn’t require the annotations to be present on
> > the classpath unless you perform reflection on them (I forget the
> > specifics). It’s a feature specific to annotations.
> >
> > On Tue, Aug 25, 2020 at 14:36 Jochen Wiedmann <jochen.wiedmann@gmail.com
> >
> > wrote:
> >
> > > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
> > >
> > >
> > >
> > > > AFAIK that means Maven won't download the dependency.
> > >
> > > > Surely that makes it harder for the developer?
> > >
> > >
> > >
> > > No, it means that Maven won't add the dependency to a distribution.
> > >
> > >
> > >
> > > However, I've got a question: These annotations have
> > >
> > > @Retention(Runtime). (See
> > >
> > >
> > >
> >
> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
> > > .)
> > >
> > > Aren't we enforcing the presence of the respective jar at runtime?
> > >
> > >
> > >
> > >
> > >
> > > Jochen
> > >
> > >
> > >
> > > --
> > >
> > >
> > >
> > > Look, that's why there's rules, understand? So that you think before
> > >
> > > you break 'em.
> > >
> > >
> > >
> > >     -- (Terry Pratchett, Thief of Time)
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > >
> > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > >
> > > For additional commands, e-mail: dev-help@commons.apache.org
> > >
> > >
> > >
> > > --
> > Matt Sicker <bo...@gmail.com>
> >
>

Re: opinions about @NotNull and @Nullable ?

Posted by Xeno Amess <xe...@gmail.com>.
> my point is if we want to go that path, which validation do we add to
ensure it is correct

Oh I see what you mean.
I think there exist some toolchains which can do this, but I have no
experience in doing the auto-validation myself.
Maybe some source analyze plugin like pmd-maven-plugin can do this.

> (@Null/@NotNull is mainly about making the validation feedback faster by
shortcutting code path analysis and/or validating spec vs impl, not just
providing meta static analysis tools already have to make it clear).

Well, not quite exactly.
static analysis can only generate the current state, but will not expose
the design.

For example, if I have a function a, this function is designed to MIGHT
return null.
But in current implementation, it will not throw null in any ways.
But it is sure it is designed to MIGHT return null because of some reasons,
like, for extendability for some //TODO things.

Then add a @Nullable to the return value seems a good choice.

Of course there might exist some other ways to show each functions' param's
Nullable or not, but annotations sound like the most convenient way.

Romain Manni-Bucau <rm...@gmail.com> 于2020年8月26日周三 下午2:50写道:

> Le mer. 26 août 2020 à 08:42, Xeno Amess <xe...@gmail.com> a écrit :
>
> > >  how do we guarantee our meta are right and don't create false
> positives
> > If we cannot even make the meta correct, then means we cannot make sure
> > which function can return Null, which can not,
> > Then why do you think our customers can do.
> >
>
> Because it is validated as mentioned and report errors/warnings (or even
> fail the build).
>
> So my point is if we want to go that path, which validation do we add to
> ensure it is correct (we can use tests to have calling code for that) -
> else we should skip that feature and replace it by either an external
> descriptor (saw some XML around that kind of feature)  or just static
> analysis tools which do exactly the same work without any meta
> (@Null/@NotNull is mainly about making the validation feedback faster by
> shortcutting code path analysis and/or validating spec vs impl, not just
> providing meta static analysis tools already have to make it clear).
>
>
> > And if people who write these libs are not sure which function can
> > receive Null parameters, sounds like adding it will at least make
> > developers sure their logics.
> >
> > Romain Manni-Bucau <rm...@gmail.com> 于2020年8月26日周三 下午2:30写道:
> >
> > > For what it is worth:
> > >
> > > 1. Generally speaking - and IMHO - these annotations only make sense
> in a
> > > particular tooling setup(s) - like considering values which can be null
> > by
> > > code analysis and not by spec (@NotNull) - which I'm not sure we have
> so
> > it
> > > is mainly about making it consumer friendly but how do we guarantee our
> > > meta are right and don't create false positives? Until we can guarantee
> > it,
> > > it sounds like we can only bring drawbacks by adding it and users can
> > > trivially solve it since if he already uses @NotNull he puts it in his
> > code
> > > at a higher level anyway.
> > > 2. Please don't use javax.annotation.* since, thanks JPMS, it can make
> > the
> > > code not compilable on java >= 9 - a package must be owned by a single
> > > module. (Not)Nullable  static check is generally about the annotation
> > > simple name and not the package so you can just duplicate the 1-2
> > > annotations you want in [lang], it is a saner compromise in today's
> > > ecosystem.
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <https://rmannibucau.metawerx.net/> | Old Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> > > <
> > >
> >
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> > > >
> > >
> > >
> > > Le mer. 26 août 2020 à 01:30, Matt Sicker <bo...@gmail.com> a écrit :
> > >
> > > > Runtime retention still doesn’t require the annotations to be present
> > on
> > > > the classpath unless you perform reflection on them (I forget the
> > > > specifics). It’s a feature specific to annotations.
> > > >
> > > > On Tue, Aug 25, 2020 at 14:36 Jochen Wiedmann <
> > jochen.wiedmann@gmail.com
> > > >
> > > > wrote:
> > > >
> > > > > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
> > > > >
> > > > >
> > > > >
> > > > > > AFAIK that means Maven won't download the dependency.
> > > > >
> > > > > > Surely that makes it harder for the developer?
> > > > >
> > > > >
> > > > >
> > > > > No, it means that Maven won't add the dependency to a distribution.
> > > > >
> > > > >
> > > > >
> > > > > However, I've got a question: These annotations have
> > > > >
> > > > > @Retention(Runtime). (See
> > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
> > > > > .)
> > > > >
> > > > > Aren't we enforcing the presence of the respective jar at runtime?
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Jochen
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > >
> > > > >
> > > > >
> > > > > Look, that's why there's rules, understand? So that you think
> before
> > > > >
> > > > > you break 'em.
> > > > >
> > > > >
> > > > >
> > > > >     -- (Terry Pratchett, Thief of Time)
> > > > >
> > > > >
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > >
> > > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > > >
> > > > > For additional commands, e-mail: dev-help@commons.apache.org
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > Matt Sicker <bo...@gmail.com>
> > > >
> > >
> >
>

Re: opinions about @NotNull and @Nullable ?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Le mer. 26 août 2020 à 08:42, Xeno Amess <xe...@gmail.com> a écrit :

> >  how do we guarantee our meta are right and don't create false positives
> If we cannot even make the meta correct, then means we cannot make sure
> which function can return Null, which can not,
> Then why do you think our customers can do.
>

Because it is validated as mentioned and report errors/warnings (or even
fail the build).

So my point is if we want to go that path, which validation do we add to
ensure it is correct (we can use tests to have calling code for that) -
else we should skip that feature and replace it by either an external
descriptor (saw some XML around that kind of feature)  or just static
analysis tools which do exactly the same work without any meta
(@Null/@NotNull is mainly about making the validation feedback faster by
shortcutting code path analysis and/or validating spec vs impl, not just
providing meta static analysis tools already have to make it clear).


> And if people who write these libs are not sure which function can
> receive Null parameters, sounds like adding it will at least make
> developers sure their logics.
>
> Romain Manni-Bucau <rm...@gmail.com> 于2020年8月26日周三 下午2:30写道:
>
> > For what it is worth:
> >
> > 1. Generally speaking - and IMHO - these annotations only make sense in a
> > particular tooling setup(s) - like considering values which can be null
> by
> > code analysis and not by spec (@NotNull) - which I'm not sure we have so
> it
> > is mainly about making it consumer friendly but how do we guarantee our
> > meta are right and don't create false positives? Until we can guarantee
> it,
> > it sounds like we can only bring drawbacks by adding it and users can
> > trivially solve it since if he already uses @NotNull he puts it in his
> code
> > at a higher level anyway.
> > 2. Please don't use javax.annotation.* since, thanks JPMS, it can make
> the
> > code not compilable on java >= 9 - a package must be owned by a single
> > module. (Not)Nullable  static check is generally about the annotation
> > simple name and not the package so you can just duplicate the 1-2
> > annotations you want in [lang], it is a saner compromise in today's
> > ecosystem.
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <https://rmannibucau.metawerx.net/> | Old Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> > <
> >
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> > >
> >
> >
> > Le mer. 26 août 2020 à 01:30, Matt Sicker <bo...@gmail.com> a écrit :
> >
> > > Runtime retention still doesn’t require the annotations to be present
> on
> > > the classpath unless you perform reflection on them (I forget the
> > > specifics). It’s a feature specific to annotations.
> > >
> > > On Tue, Aug 25, 2020 at 14:36 Jochen Wiedmann <
> jochen.wiedmann@gmail.com
> > >
> > > wrote:
> > >
> > > > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
> > > >
> > > >
> > > >
> > > > > AFAIK that means Maven won't download the dependency.
> > > >
> > > > > Surely that makes it harder for the developer?
> > > >
> > > >
> > > >
> > > > No, it means that Maven won't add the dependency to a distribution.
> > > >
> > > >
> > > >
> > > > However, I've got a question: These annotations have
> > > >
> > > > @Retention(Runtime). (See
> > > >
> > > >
> > > >
> > >
> >
> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
> > > > .)
> > > >
> > > > Aren't we enforcing the presence of the respective jar at runtime?
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Jochen
> > > >
> > > >
> > > >
> > > > --
> > > >
> > > >
> > > >
> > > > Look, that's why there's rules, understand? So that you think before
> > > >
> > > > you break 'em.
> > > >
> > > >
> > > >
> > > >     -- (Terry Pratchett, Thief of Time)
> > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > >
> > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > >
> > > > For additional commands, e-mail: dev-help@commons.apache.org
> > > >
> > > >
> > > >
> > > > --
> > > Matt Sicker <bo...@gmail.com>
> > >
> >
>

Re: opinions about @NotNull and @Nullable ?

Posted by Xeno Amess <xe...@gmail.com>.
>  However, I've got a question: These annotations have
@Retention(Runtime). (See
https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
.)
Aren't we enforcing the presence of the respective jar at runtime?

Hi.
Usually, for Annotations, it have 3 ways to choose from, at the Annotations
defined.
If I understand correctly, only RUNTIME annotations will really needed for
runtime.

If you don't need any RUNTIME annotations, you can just make this lib
<scope>provide<scope>
Otherwise, you must treat that lib as a normal dependency.

see java.lang.annotation.RetentionPolicy for details.

/*
 * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

package java.lang.annotation;

/**
 * Annotation retention policy.  The constants of this enumerated type
 * describe the various policies for retaining annotations.  They are used
 * in conjunction with the {@link Retention} meta-annotation type to specify
 * how long annotations are to be retained.
 *
 * @author  Joshua Bloch
 * @since 1.5
 */
public enum RetentionPolicy {
    /**
     * Annotations are to be discarded by the compiler.
     */
    SOURCE,

    /**
     * Annotations are to be recorded in the class file by the compiler
     * but need not be retained by the VM at run time.  This is the default
     * behavior.
     */
    CLASS,

    /**
     * Annotations are to be recorded in the class file by the compiler and
     * retained by the VM at run time, so they may be read reflectively.
     *
     * @see java.lang.reflect.AnnotatedElement
     */
    RUNTIME
}

Well I never use jsr305 so I'm not sure how they implement it.
But I can make sure in jetbrains.annotations, @NotNull and @Nullable are
using CLASS.


Xeno Amess <xe...@gmail.com> 于2020年8月26日周三 下午2:42写道:

> >  how do we guarantee our meta are right and don't create false positives
> If we cannot even make the meta correct, then means we cannot make sure
> which function can return Null, which can not,
> Then why do you think our customers can do.
> And if people who write these libs are not sure which function can
> receive Null parameters, sounds like adding it will at least make
> developers sure their logics.
>
> Romain Manni-Bucau <rm...@gmail.com> 于2020年8月26日周三 下午2:30写道:
>
>> For what it is worth:
>>
>> 1. Generally speaking - and IMHO - these annotations only make sense in a
>> particular tooling setup(s) - like considering values which can be null by
>> code analysis and not by spec (@NotNull) - which I'm not sure we have so
>> it
>> is mainly about making it consumer friendly but how do we guarantee our
>> meta are right and don't create false positives? Until we can guarantee
>> it,
>> it sounds like we can only bring drawbacks by adding it and users can
>> trivially solve it since if he already uses @NotNull he puts it in his
>> code
>> at a higher level anyway.
>> 2. Please don't use javax.annotation.* since, thanks JPMS, it can make the
>> code not compilable on java >= 9 - a package must be owned by a single
>> module. (Not)Nullable  static check is generally about the annotation
>> simple name and not the package so you can just duplicate the 1-2
>> annotations you want in [lang], it is a saner compromise in today's
>> ecosystem.
>>
>> Romain Manni-Bucau
>> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>> <https://rmannibucau.metawerx.net/> | Old Blog
>> <http://rmannibucau.wordpress.com> | Github <
>> https://github.com/rmannibucau> |
>> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
>> <
>> https://www.packtpub.com/application-development/java-ee-8-high-performance
>> >
>>
>>
>> Le mer. 26 août 2020 à 01:30, Matt Sicker <bo...@gmail.com> a écrit :
>>
>> > Runtime retention still doesn’t require the annotations to be present on
>> > the classpath unless you perform reflection on them (I forget the
>> > specifics). It’s a feature specific to annotations.
>> >
>> > On Tue, Aug 25, 2020 at 14:36 Jochen Wiedmann <
>> jochen.wiedmann@gmail.com>
>> > wrote:
>> >
>> > > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
>> > >
>> > >
>> > >
>> > > > AFAIK that means Maven won't download the dependency.
>> > >
>> > > > Surely that makes it harder for the developer?
>> > >
>> > >
>> > >
>> > > No, it means that Maven won't add the dependency to a distribution.
>> > >
>> > >
>> > >
>> > > However, I've got a question: These annotations have
>> > >
>> > > @Retention(Runtime). (See
>> > >
>> > >
>> > >
>> >
>> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
>> > > .)
>> > >
>> > > Aren't we enforcing the presence of the respective jar at runtime?
>> > >
>> > >
>> > >
>> > >
>> > >
>> > > Jochen
>> > >
>> > >
>> > >
>> > > --
>> > >
>> > >
>> > >
>> > > Look, that's why there's rules, understand? So that you think before
>> > >
>> > > you break 'em.
>> > >
>> > >
>> > >
>> > >     -- (Terry Pratchett, Thief of Time)
>> > >
>> > >
>> > >
>> > > ---------------------------------------------------------------------
>> > >
>> > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> > >
>> > > For additional commands, e-mail: dev-help@commons.apache.org
>> > >
>> > >
>> > >
>> > > --
>> > Matt Sicker <bo...@gmail.com>
>> >
>>
>

Re: opinions about @NotNull and @Nullable ?

Posted by Xeno Amess <xe...@gmail.com>.
>  how do we guarantee our meta are right and don't create false positives
If we cannot even make the meta correct, then means we cannot make sure
which function can return Null, which can not,
Then why do you think our customers can do.
And if people who write these libs are not sure which function can
receive Null parameters, sounds like adding it will at least make
developers sure their logics.

Romain Manni-Bucau <rm...@gmail.com> 于2020年8月26日周三 下午2:30写道:

> For what it is worth:
>
> 1. Generally speaking - and IMHO - these annotations only make sense in a
> particular tooling setup(s) - like considering values which can be null by
> code analysis and not by spec (@NotNull) - which I'm not sure we have so it
> is mainly about making it consumer friendly but how do we guarantee our
> meta are right and don't create false positives? Until we can guarantee it,
> it sounds like we can only bring drawbacks by adding it and users can
> trivially solve it since if he already uses @NotNull he puts it in his code
> at a higher level anyway.
> 2. Please don't use javax.annotation.* since, thanks JPMS, it can make the
> code not compilable on java >= 9 - a package must be owned by a single
> module. (Not)Nullable  static check is generally about the annotation
> simple name and not the package so you can just duplicate the 1-2
> annotations you want in [lang], it is a saner compromise in today's
> ecosystem.
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> <
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> >
>
>
> Le mer. 26 août 2020 à 01:30, Matt Sicker <bo...@gmail.com> a écrit :
>
> > Runtime retention still doesn’t require the annotations to be present on
> > the classpath unless you perform reflection on them (I forget the
> > specifics). It’s a feature specific to annotations.
> >
> > On Tue, Aug 25, 2020 at 14:36 Jochen Wiedmann <jochen.wiedmann@gmail.com
> >
> > wrote:
> >
> > > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
> > >
> > >
> > >
> > > > AFAIK that means Maven won't download the dependency.
> > >
> > > > Surely that makes it harder for the developer?
> > >
> > >
> > >
> > > No, it means that Maven won't add the dependency to a distribution.
> > >
> > >
> > >
> > > However, I've got a question: These annotations have
> > >
> > > @Retention(Runtime). (See
> > >
> > >
> > >
> >
> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
> > > .)
> > >
> > > Aren't we enforcing the presence of the respective jar at runtime?
> > >
> > >
> > >
> > >
> > >
> > > Jochen
> > >
> > >
> > >
> > > --
> > >
> > >
> > >
> > > Look, that's why there's rules, understand? So that you think before
> > >
> > > you break 'em.
> > >
> > >
> > >
> > >     -- (Terry Pratchett, Thief of Time)
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > >
> > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > >
> > > For additional commands, e-mail: dev-help@commons.apache.org
> > >
> > >
> > >
> > > --
> > Matt Sicker <bo...@gmail.com>
> >
>

Re: opinions about @NotNull and @Nullable ?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
For what it is worth:

1. Generally speaking - and IMHO - these annotations only make sense in a
particular tooling setup(s) - like considering values which can be null by
code analysis and not by spec (@NotNull) - which I'm not sure we have so it
is mainly about making it consumer friendly but how do we guarantee our
meta are right and don't create false positives? Until we can guarantee it,
it sounds like we can only bring drawbacks by adding it and users can
trivially solve it since if he already uses @NotNull he puts it in his code
at a higher level anyway.
2. Please don't use javax.annotation.* since, thanks JPMS, it can make the
code not compilable on java >= 9 - a package must be owned by a single
module. (Not)Nullable  static check is generally about the annotation
simple name and not the package so you can just duplicate the 1-2
annotations you want in [lang], it is a saner compromise in today's
ecosystem.

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


Le mer. 26 août 2020 à 01:30, Matt Sicker <bo...@gmail.com> a écrit :

> Runtime retention still doesn’t require the annotations to be present on
> the classpath unless you perform reflection on them (I forget the
> specifics). It’s a feature specific to annotations.
>
> On Tue, Aug 25, 2020 at 14:36 Jochen Wiedmann <jo...@gmail.com>
> wrote:
>
> > On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
> >
> >
> >
> > > AFAIK that means Maven won't download the dependency.
> >
> > > Surely that makes it harder for the developer?
> >
> >
> >
> > No, it means that Maven won't add the dependency to a distribution.
> >
> >
> >
> > However, I've got a question: These annotations have
> >
> > @Retention(Runtime). (See
> >
> >
> >
> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
> > .)
> >
> > Aren't we enforcing the presence of the respective jar at runtime?
> >
> >
> >
> >
> >
> > Jochen
> >
> >
> >
> > --
> >
> >
> >
> > Look, that's why there's rules, understand? So that you think before
> >
> > you break 'em.
> >
> >
> >
> >     -- (Terry Pratchett, Thief of Time)
> >
> >
> >
> > ---------------------------------------------------------------------
> >
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> >
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
> >
> > --
> Matt Sicker <bo...@gmail.com>
>

Re: opinions about @NotNull and @Nullable ?

Posted by Matt Sicker <bo...@gmail.com>.
Runtime retention still doesn’t require the annotations to be present on
the classpath unless you perform reflection on them (I forget the
specifics). It’s a feature specific to annotations.

On Tue, Aug 25, 2020 at 14:36 Jochen Wiedmann <jo...@gmail.com>
wrote:

> On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:
>
>
>
> > AFAIK that means Maven won't download the dependency.
>
> > Surely that makes it harder for the developer?
>
>
>
> No, it means that Maven won't add the dependency to a distribution.
>
>
>
> However, I've got a question: These annotations have
>
> @Retention(Runtime). (See
>
>
> https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html
> .)
>
> Aren't we enforcing the presence of the respective jar at runtime?
>
>
>
>
>
> Jochen
>
>
>
> --
>
>
>
> Look, that's why there's rules, understand? So that you think before
>
> you break 'em.
>
>
>
>     -- (Terry Pratchett, Thief of Time)
>
>
>
> ---------------------------------------------------------------------
>
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
>
> --
Matt Sicker <bo...@gmail.com>

Re: opinions about @NotNull and @Nullable ?

Posted by Jochen Wiedmann <jo...@gmail.com>.
On Tue, Aug 25, 2020 at 9:08 PM sebb <se...@gmail.com> wrote:

> AFAIK that means Maven won't download the dependency.
> Surely that makes it harder for the developer?

No, it means that Maven won't add the dependency to a distribution.

However, I've got a question: These annotations have
@Retention(Runtime). (See
https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nullable.html.)
Aren't we enforcing the presence of the respective jar at runtime?


Jochen

-- 

Look, that's why there's rules, understand? So that you think before
you break 'em.

    -- (Terry Pratchett, Thief of Time)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: opinions about @NotNull and @Nullable ?

Posted by Matt Sicker <bo...@gmail.com>.
Annotations like this don't need to be present at runtime. They can
exist only in the source code like that.

On Tue, 25 Aug 2020 at 14:08, sebb <se...@gmail.com> wrote:
>
> On Tue, 25 Aug 2020 at 19:48, Xeno Amess <xe...@gmail.com> wrote:
> >
> > in maven, dependency can be <scope>provided</scope>
>
> AFAIK that means Maven won't download the dependency.
> Surely that makes it harder for the developer?
>
> > sebb <se...@gmail.com> 于2020年8月26日周三 上午2:45写道:
> >
> > > Won't this mean that every component has to have a dependency on the
> > > tag library?
> > >
> > >
> > > On Tue, 25 Aug 2020 at 14:45, Matt Sicker <bo...@gmail.com> wrote:
> > > >
> > > > We use the findbugs annotations fairly extensively in Jenkins, and with
> > > the
> > > > proper plugins, it’s helped a lot for nullability checking.
> > > >
> > > > On Mon, Aug 24, 2020 at 23:54 Xeno Amess <xe...@gmail.com> wrote:
> > > >
> > > > > Hi.
> > > > >
> > > > > Today I see a pr have similar ideas with this, so I will suggest we
> > > > >
> > > > > consider it again.
> > > > >
> > > > > at [LANG-1598 <https://issues.apache.org/jira/browse/LANG-1598>]
> > > > >
> > > > > He suggest a google annotations repo, and I'd prefer the one from
> > > > >
> > > > > jetbrains, but that is not key point.
> > > > >
> > > > > Key point is, should we consider about adding such Annotations?
> > > > >
> > > > > Adding such annotations can help:
> > > > >
> > > > > 1. make people who want to modify the function sure whether each
> > > > >
> > > > > param/return value can be null, and make sure do not change it.
> > > > >
> > > > > It has better readability than any other ways.
> > > > >
> > > > > 2. make people who invoke these functions have a clear idea whether
> > > this
> > > > >
> > > > > function can return null.
> > > > >
> > > > > And more importantly maybe, let the ide also knows whether this
> > > function
> > > > >
> > > > > can return null.
> > > > >
> > > > > That will simplify a lot of human time to check.
> > > > >
> > > > >
> > > > >
> > > > > Any ideas?
> > > > >
> > > > >
> > > > >
> > > > > Xeno Amess <xe...@gmail.com> 于2020年4月24日周五 下午6:50写道:
> > > > >
> > > > >
> > > > >
> > > > > > I want to know about your opinions about @NotNull and @Nullable.
> > > > >
> > > > > >
> > > > >
> > > > > > Should we use it in every function?
> > > > >
> > > > > > Or we use it  only at some misleading places?
> > > > >
> > > > > > Or simply not use them at all?
> > > > >
> > > > > >
> > > > >
> > > > > > thx.
> > > > >
> > > > > >
> > > > >
> > > > > >
> > > > >
> > > > > --
> > > > Matt Sicker <bo...@gmail.com>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > For additional commands, e-mail: dev-help@commons.apache.org
> > >
> > >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>


-- 
Matt Sicker <bo...@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: opinions about @NotNull and @Nullable ?

Posted by sebb <se...@gmail.com>.
On Tue, 25 Aug 2020 at 19:48, Xeno Amess <xe...@gmail.com> wrote:
>
> in maven, dependency can be <scope>provided</scope>

AFAIK that means Maven won't download the dependency.
Surely that makes it harder for the developer?

> sebb <se...@gmail.com> 于2020年8月26日周三 上午2:45写道:
>
> > Won't this mean that every component has to have a dependency on the
> > tag library?
> >
> >
> > On Tue, 25 Aug 2020 at 14:45, Matt Sicker <bo...@gmail.com> wrote:
> > >
> > > We use the findbugs annotations fairly extensively in Jenkins, and with
> > the
> > > proper plugins, it’s helped a lot for nullability checking.
> > >
> > > On Mon, Aug 24, 2020 at 23:54 Xeno Amess <xe...@gmail.com> wrote:
> > >
> > > > Hi.
> > > >
> > > > Today I see a pr have similar ideas with this, so I will suggest we
> > > >
> > > > consider it again.
> > > >
> > > > at [LANG-1598 <https://issues.apache.org/jira/browse/LANG-1598>]
> > > >
> > > > He suggest a google annotations repo, and I'd prefer the one from
> > > >
> > > > jetbrains, but that is not key point.
> > > >
> > > > Key point is, should we consider about adding such Annotations?
> > > >
> > > > Adding such annotations can help:
> > > >
> > > > 1. make people who want to modify the function sure whether each
> > > >
> > > > param/return value can be null, and make sure do not change it.
> > > >
> > > > It has better readability than any other ways.
> > > >
> > > > 2. make people who invoke these functions have a clear idea whether
> > this
> > > >
> > > > function can return null.
> > > >
> > > > And more importantly maybe, let the ide also knows whether this
> > function
> > > >
> > > > can return null.
> > > >
> > > > That will simplify a lot of human time to check.
> > > >
> > > >
> > > >
> > > > Any ideas?
> > > >
> > > >
> > > >
> > > > Xeno Amess <xe...@gmail.com> 于2020年4月24日周五 下午6:50写道:
> > > >
> > > >
> > > >
> > > > > I want to know about your opinions about @NotNull and @Nullable.
> > > >
> > > > >
> > > >
> > > > > Should we use it in every function?
> > > >
> > > > > Or we use it  only at some misleading places?
> > > >
> > > > > Or simply not use them at all?
> > > >
> > > > >
> > > >
> > > > > thx.
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > --
> > > Matt Sicker <bo...@gmail.com>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: opinions about @NotNull and @Nullable ?

Posted by Xeno Amess <xe...@gmail.com>.
in maven, dependency can be <scope>provided</scope>

sebb <se...@gmail.com> 于2020年8月26日周三 上午2:45写道:

> Won't this mean that every component has to have a dependency on the
> tag library?
>
>
> On Tue, 25 Aug 2020 at 14:45, Matt Sicker <bo...@gmail.com> wrote:
> >
> > We use the findbugs annotations fairly extensively in Jenkins, and with
> the
> > proper plugins, it’s helped a lot for nullability checking.
> >
> > On Mon, Aug 24, 2020 at 23:54 Xeno Amess <xe...@gmail.com> wrote:
> >
> > > Hi.
> > >
> > > Today I see a pr have similar ideas with this, so I will suggest we
> > >
> > > consider it again.
> > >
> > > at [LANG-1598 <https://issues.apache.org/jira/browse/LANG-1598>]
> > >
> > > He suggest a google annotations repo, and I'd prefer the one from
> > >
> > > jetbrains, but that is not key point.
> > >
> > > Key point is, should we consider about adding such Annotations?
> > >
> > > Adding such annotations can help:
> > >
> > > 1. make people who want to modify the function sure whether each
> > >
> > > param/return value can be null, and make sure do not change it.
> > >
> > > It has better readability than any other ways.
> > >
> > > 2. make people who invoke these functions have a clear idea whether
> this
> > >
> > > function can return null.
> > >
> > > And more importantly maybe, let the ide also knows whether this
> function
> > >
> > > can return null.
> > >
> > > That will simplify a lot of human time to check.
> > >
> > >
> > >
> > > Any ideas?
> > >
> > >
> > >
> > > Xeno Amess <xe...@gmail.com> 于2020年4月24日周五 下午6:50写道:
> > >
> > >
> > >
> > > > I want to know about your opinions about @NotNull and @Nullable.
> > >
> > > >
> > >
> > > > Should we use it in every function?
> > >
> > > > Or we use it  only at some misleading places?
> > >
> > > > Or simply not use them at all?
> > >
> > > >
> > >
> > > > thx.
> > >
> > > >
> > >
> > > >
> > >
> > > --
> > Matt Sicker <bo...@gmail.com>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

Re: opinions about @NotNull and @Nullable ?

Posted by sebb <se...@gmail.com>.
Won't this mean that every component has to have a dependency on the
tag library?


On Tue, 25 Aug 2020 at 14:45, Matt Sicker <bo...@gmail.com> wrote:
>
> We use the findbugs annotations fairly extensively in Jenkins, and with the
> proper plugins, it’s helped a lot for nullability checking.
>
> On Mon, Aug 24, 2020 at 23:54 Xeno Amess <xe...@gmail.com> wrote:
>
> > Hi.
> >
> > Today I see a pr have similar ideas with this, so I will suggest we
> >
> > consider it again.
> >
> > at [LANG-1598 <https://issues.apache.org/jira/browse/LANG-1598>]
> >
> > He suggest a google annotations repo, and I'd prefer the one from
> >
> > jetbrains, but that is not key point.
> >
> > Key point is, should we consider about adding such Annotations?
> >
> > Adding such annotations can help:
> >
> > 1. make people who want to modify the function sure whether each
> >
> > param/return value can be null, and make sure do not change it.
> >
> > It has better readability than any other ways.
> >
> > 2. make people who invoke these functions have a clear idea whether this
> >
> > function can return null.
> >
> > And more importantly maybe, let the ide also knows whether this function
> >
> > can return null.
> >
> > That will simplify a lot of human time to check.
> >
> >
> >
> > Any ideas?
> >
> >
> >
> > Xeno Amess <xe...@gmail.com> 于2020年4月24日周五 下午6:50写道:
> >
> >
> >
> > > I want to know about your opinions about @NotNull and @Nullable.
> >
> > >
> >
> > > Should we use it in every function?
> >
> > > Or we use it  only at some misleading places?
> >
> > > Or simply not use them at all?
> >
> > >
> >
> > > thx.
> >
> > >
> >
> > >
> >
> > --
> Matt Sicker <bo...@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: opinions about @NotNull and @Nullable ?

Posted by Miguel Muñoz <sw...@gmail.com>.
Matt: Apache uses findBugs to assist Apache developers to catch bugs in the
Apache code. Xeno's suggestion isn't for Apache developers, it's for our
users. It's intended to help Apache users write better code. I have used
annotations like this for years in my application code. They're very
helpful, especially when used with IntelliJ's "Constant Conditions and
Exceptions" code inspection. Adding it to Apache's code would not only help
me further, it would reduce the resistance I get from other developers. I
think it's a very good idea.

A lot of people have been using Optional to prevent NullPointerExceptions,
and many are now figuring out that it doesn't really help with that.
(That's not what Optional was invented for.) But it shows how there's a
hunger to address this issue in Java. The annotations suggested by Xeno are
a much better solution.

— Miguel Muñoz

P.S. This is a bit off-topic, but I have an essay where I keep track of
many different ways where Optional is used very badly, often adding new
ways to introduce bugs in our code. Anyone who's interested can find it at
https://github.com/SwingGuy1024/Blog/blob/master/Bad%20Uses%20of%20Optional.md

— MM

On Tue, Aug 25, 2020 at 6:45 AM Matt Sicker <bo...@gmail.com> wrote:

> We use the findbugs annotations fairly extensively in Jenkins, and with the
> proper plugins, it’s helped a lot for nullability checking.
>
> On Mon, Aug 24, 2020 at 23:54 Xeno Amess <xe...@gmail.com> wrote:
>
> > Hi.
> >
> > Today I see a pr have similar ideas with this, so I will suggest we
> >
> > consider it again.
> >
> > at [LANG-1598 <https://issues.apache.org/jira/browse/LANG-1598>]
> >
> > He suggest a google annotations repo, and I'd prefer the one from
> >
> > jetbrains, but that is not key point.
> >
> > Key point is, should we consider about adding such Annotations?
> >
> > Adding such annotations can help:
> >
> > 1. make people who want to modify the function sure whether each
> >
> > param/return value can be null, and make sure do not change it.
> >
> > It has better readability than any other ways.
> >
> > 2. make people who invoke these functions have a clear idea whether this
> >
> > function can return null.
> >
> > And more importantly maybe, let the ide also knows whether this function
> >
> > can return null.
> >
> > That will simplify a lot of human time to check.
> >
> >
> >
> > Any ideas?
> >
> >
> >
> > Xeno Amess <xe...@gmail.com> 于2020年4月24日周五 下午6:50写道:
> >
> >
> >
> > > I want to know about your opinions about @NotNull and @Nullable.
> >
> > >
> >
> > > Should we use it in every function?
> >
> > > Or we use it  only at some misleading places?
> >
> > > Or simply not use them at all?
> >
> > >
> >
> > > thx.
> >
> > >
> >
> > >
> >
> > --
> Matt Sicker <bo...@gmail.com>
>

Re: opinions about @NotNull and @Nullable ?

Posted by Matt Sicker <bo...@gmail.com>.
We use the findbugs annotations fairly extensively in Jenkins, and with the
proper plugins, it’s helped a lot for nullability checking.

On Mon, Aug 24, 2020 at 23:54 Xeno Amess <xe...@gmail.com> wrote:

> Hi.
>
> Today I see a pr have similar ideas with this, so I will suggest we
>
> consider it again.
>
> at [LANG-1598 <https://issues.apache.org/jira/browse/LANG-1598>]
>
> He suggest a google annotations repo, and I'd prefer the one from
>
> jetbrains, but that is not key point.
>
> Key point is, should we consider about adding such Annotations?
>
> Adding such annotations can help:
>
> 1. make people who want to modify the function sure whether each
>
> param/return value can be null, and make sure do not change it.
>
> It has better readability than any other ways.
>
> 2. make people who invoke these functions have a clear idea whether this
>
> function can return null.
>
> And more importantly maybe, let the ide also knows whether this function
>
> can return null.
>
> That will simplify a lot of human time to check.
>
>
>
> Any ideas?
>
>
>
> Xeno Amess <xe...@gmail.com> 于2020年4月24日周五 下午6:50写道:
>
>
>
> > I want to know about your opinions about @NotNull and @Nullable.
>
> >
>
> > Should we use it in every function?
>
> > Or we use it  only at some misleading places?
>
> > Or simply not use them at all?
>
> >
>
> > thx.
>
> >
>
> >
>
> --
Matt Sicker <bo...@gmail.com>