You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The signatures of {require,check,verify}NonNull [working decision: nullable, but see #226] #176
library-use-caseQuestion of how a particular library should be annotated; could potentially affect design or docsneeds-decision-post-1.0Issues needing a finalized decision that they are post 1.0nullnessFor issues specific to nullness analysis.
It will be helpful to users for JSpecify to state, as an example, correct types for methods like requireNonNull and verifyNotNull.
I propose that these methods take a @NonNull formal parameter and return a @NonNull result.
The reason for this is that in a correct execution of the program, null never flows to these methods.
(This is a discussion about the specification, not about the behavior of any tool. Specific tools may choose to treat these methods specially, such as not issuing warnings for uses of them that may lead to a NullPointerException.)
There is definitely more to be said about these, and I'd like us to work out at least part of the story before 1.0.
First, the reason I say only "part of the story": I do hope that we can postpone an "authoritative" statement about the signature of any particular JDK method until after 1.0: For now, it would be a huge victory if tools agreed on what a method annotated in a given way means, even without agreeing on which annotations should be "present" on which particular JDK methods. (If nothing else, it would be hard to change the meaning of annotations later -- not that changing the annotations of a JDK method is trivial, either!) Nonetheless, I do believe that the JDK signatures are important to eventually discuss. Offhand, I might classify them as the most important post-1.0 task.
But the part that I do think is important to work out before 1.0 is (I think) the deeper part. As you have noted in the past, requireNonNull is an especially vivid example of the fundamental disagreement over what it means to annotate something as @Nullable, and we lack a "definition of @Nullable."
As it happens, I am working on some Javadoc for @Nullable -- nominally as part of the project of writing Javadoc for @DefaultNonNull so that we can name that, but also to try to resume peeling off the outer layer of the @Nullable question. I have come to think that, if anything, the question at stake with requireNonNull is deeper than "just" @Nullable: It's a question of what types mean to us. How close do we want to aim to Haskell, in which (I'm told, supposedly with only minor exaggeration) "If your program compiles, it computes the right answer," as opposed to a more mechanistic approach to types, in which "This method requires a Foo" means nothing more than "The compiler will fight you if you try to pass something that might not be a Foo?" [edit: I need to restate this in a way that does not appeal to tool behavior.]
I have thoughts, which I am going to try to keep to myself for the moment, since I do want to make sure I actually carry through on my promises about @DefaultNonNull, etc. But I wanted to write something here now, since I hate to leave people completely hanging when they bring up something that I do think we need to address. I will keep an eye on this thread, even though I will be trying not to contribute more myself just yet.
[edits: previously: #29. Also, eventually consider whether the fact that requireNonNull is in the standard library should nudge us in some direction: It requires no runtime dependency, and it may be specially supported by JEP-358 someday.]
[edit: much later relevant PR that I forgot to cite this issue from: google/guava#7090]
We need to finalize the definition of @Nullable before any release or announcement.
We don't need to finalize the nullness of every JDK method, but we need a definition that leaves no leeway for confusion. Given the definition of @Nullable, any two engineers should agree on the specification for every JDK method. If we cannot do that, then even we don't understand the specification! Making a release with in such a confused state would introduce confusion rather than clarity.
A tool might choose to ship with a different JDK that is more or less restrictive than the true specification. However, that difference should be clear to everyone.
As an example, the correct specification for System.out is @Nullable, because there exist correct executions in which System.out is null. (But maybe you have a different idea of what @Nullable should mean? Without a specification, these discussions are confusing and perhaps moot.) The Checker Framework chooses to ship with a more restrictive JDK that forbids some correct programs. That is, the Checker Framework issues false positive warnings for some correct programs that set System.out to null and that never crash.
Even though setOut(null) executes successfully at runtime, we would not want to allow it.
...
I do think it's pretty clear that, as long as "normal users" can't ever see that null value, we'd want out to be treated as non-null.
A tool might make these choices.
However, it is the wrong approach to thinking about the specification. A specification should be unambiguous and objective (not subjective). Discussions about a specification should never depend on ill-defined notions of "normal users" and "what we'd want".
Again, I'm not criticizing this statement as a tool choice.
I think it would be very helpful for us, in every discussion, to distinguish between
the specification and
tool behavior.
I think that will lead to less confusion and better outcomes.
I promised in the meeting to retract my statement above about what "compiles" and what the "compiler" does. I fully endorse the need to draw a clear line between specification from tool behavior. I believe that I can more accurately describe my conception of a "type" without appealing to tool behavior. But the onus is still on me to do that, as well as to say why I think it's worth reinventing that conception when the Checker Framework has already provided one (as have others).
To tie that back to this issue: I expect my eventual writeup to argue that a definition of @Nullable does not necessarily provide a single correct answer for the specification of every method. But as you say, we really do need to discuss that definition before that claim can make any sense.
Again, you have given me plenty to think about on this front, so I am the one who needs to respond to that. That said, I have one quick question:
I had been assuming that the Checker Framework JDK was written to be, as far as possible, a specification rather than a definition of tool behavior. It sounds like I had this wrong, and in fact you consider it to fall into the "tool behavior" bucket? As you say above, there's nothing wrong with that choice; I just want to stop interpreting the Checker Framework JDK as your view of a specification if in fact that is not how it is intended.
I had been assuming that the Checker Framework JDK was written to be, as far as possible, a specification rather than a definition of tool behavior. It sounds like I had this wrong, and in fact you consider it to fall into the "tool behavior" bucket?
Your new understanding is correct.
Our goal is to make the Checker Framework JDK as close to the true specification as possible. Whenever they diverge, there is supposed to be a comment. That comment was missing for System.out, which I just fixed; sorry for the confusion.
Please let me know of any other instances of undocumented divergence.
I feel this question is somewhat analogous to arguing whether the following method is legal in the normal Java type system:
public void requiresFoo(Object o) {
if (!(o instanceof Foo)) {
throw new ClassCastException("Not Foo");
}
}
Which I believe it is.
Obviously not every program that calls this method with the "correct" Object type is free of runtime errors (related to type), just like not every program calling requireNonNull(@Nullable Object o) is free of NPEs. But the Java type system allows encoding this type of escape hatch methods, and I don't believe that's a flaw.
Am I missing something major with the analogy?
As a general point of opinion, I feel a definition of @Nullable that entirely precludes this sort of escape hatch might not be useful, to the point that every tool will have to break it or special case it in some way. I understand the idea of keeping definition and implementation separate, but a definition that will require nearly all usable implementations to break it in the same predictable way is a bad definition for the purposes of setting a standard.
I agree we want an unambiguous definition here, if one exists. And I do hope that it does. I just want to also argue that even a confused definition is better than one that demands to be broken by every implementation.
Edit: I just read far along into @wmdietl's doc to realize my analogy is exactly the same he brings up here, but with a more clearly useful method. Either way, I think that analogy will be intuitive to Java developers, even if it leads to a weaker definition/specification.
I think methods like requireNonNull and verifyNotNull are special in that they have no function other than to be a runtime check. They're the kind of thing that other languages provide at the language level (like Kotlin's !!) or that you use when you don't want to use language-level asserts.
As a runtime check that complements a compile-time check, their principal use is to contextualize the error that null will cause in case the compile-time check fails, either by documenting it in source code for readers, or by adding a message describing the null case, or by associating the error with a better stack context, as in the case where the dereference happens in some callback that will be executed in a different thread:
void doSomething(Object notNull) {
requireNonNull(notNull); // throw NOW, not later
executor.submit(() -> notNull.toString());
}
That being said, it's perfectly reasonable to pass a nullable type to them, as in the following example:
/**
* @param what must not be null if {@code nullOkay} is false
*/
void method(boolean nullOkay, @Nullable Object what) {
if (!nullOkay) {
requireNonNull(what);
}
...
}
I feel this question is somewhat analogous to arguing whether the following method is legal in the normal Java type system:
public void requiresFoo(Object o) {
if (!(o instanceof Foo)) {
throw new ClassCastException("Not Foo");
}
}
Just to address this analogue first, yes, there's nothing bogus about it, it just didn't take advantage of the "shift-left" capabilities available to it, for whatever reason.
Before I get into the actual issue, I just want to point out that #29 (which Chris referenced above) is a full-on duplicate of this issue and there was a lot of discussion on it. So I'm gonna try to put all that together before pretending to have an opinion.
changed the title [-]The signature of `requireNonNull` and `verifyNotNull`[/-][+]The signatures of `requireNonNull`, `checkNotNull`, `verifyNotNull`[/+]on Jun 19, 2021
I reread #29 but I'm not sure any of it needs to be brought forward.
Why is this not as simple as this:
What is any example for which we want to tell the user here it's wrong to call one of these methods? What kind of call would deserve some sort of complaint?
(By this I do not mean a "reference definitely non-null, call unnecessary" warning; that's the least of our concerns right now.)
I can't think of any, except ones that are too weird to even take seriously.
"No input is wrong" ---> use most general parameter type.
(I did reread the checker framework's rationale, but it opens, "As an example, consider the Nullness Checker. Its goal is to guarantee that your program does not crash due to a null value." And I believe it really is that goal, which is particular to CF and not shared by all JSpecify members, that the stance on that page stems from.)
In our world, there are hundreds of ways that a reference can be non-null yet not statically recognizable as such. It would be ironic if the best method for the user to call in this situation gave them a compile-time error.
It seems to me that there are three distinct levels of "nullness" from a static analysis perspective. "Definitely null", "definitely not null", and "maybe null". It is likely an error for non-test code to pass a "definitely null" value to Objects.requireNonNull(), but not an error to pass a "maybe null", because testing a "maybe null" value for nullness is the entire purpose of requireNonNull(). If a value is statically known to be "definitely not null", there's no need to check it, so it really only makes sense to pass "maybe null" values. As kevinb9n says, to forbid "maybe null" as a valid argument to requireNonNull() is to forbid the best method for the situation.
Certainly, any method that unconditionally calls requireNonNull() on one of its arguments should annotate that argument as @NonNull. But that's up to the author, not the specification to decide. Calling requireNonNull() on the value returned by a method with a @Nullable return is perfectly valid, if the method is expected to never return null in that specific context. For example, retrieving a value from a collection, when that collection instance is expected to not contain null values, but the collection class does not forbid them.
It is correct to raise a warning or error when passing a "definitely null" value to requireNonNull(). However, it should be up to the tool user, not the specification, what they want to happen when "maybe null" values are passed to methods like requireNonNull().
To me, this indicates a use case for a @NullCheck (or similar) special-use annotation for methods that throw on null by design. A parameter annotated @NullCheck would cause a static analysis tool to do one of a) nothing, b) issue a warning , or c) issue an error when a "maybe null" value is passed to it, configurable by the tool's user. Allowing separate configuration for @NullCheck and @NonNull warning/error behavior gives users flexibility to meet their particular requirements.
The signature would then be <T> @NonNull T requireNonNull(@NullCheck T obj).
In a high-assurance application I would likely choose option c), and individually document/suppress each instance, but not all code needs that level of strictness.
Thanks @Mooninaut and sorry we didn't respond yet. Your 3 categories correspond to these types (using String as example):
String - definitely non-null
NullType - definitely null, continues to be non-denotable
@Nullable String - String U NullType
I think checkers will be able to track "definitely null" for purposes of issuing "redundant null check" warnings, but I do want to classify that as a lesser type of warning/error than actual type errors, for what that's worth. Overall I don't think we worry much about it.
I also came to the conclusion that we're going to need a special annotation to use with methods like requireNonNull.
Specifically, this would be a parameter annotation that declares, "this method promises not to complete normally if this parameter is null". This is what would allow checkers to "learn" about the non-nullness of a ref-transparent expression below the point where that expression is passed to requireNonNull etc. And that's useful/important.
Fortunately, if these methods require a specialized marking, that takes the pressure off this particular issue/question. I will maintain that the parameters are still very much nullable in this scenario. (A lot of the discussion that had been insisting they be non-nullable turned out to be thinking of a different method, castNonNull, which is not in the set we're talking about here.)
But, the new issue I'm gonna file for the annotation can encompass this nullable question, so I think we'll be closing this one soon.
changed the title [-]The signatures of `requireNonNull`, `checkNotNull`, `verifyNotNull`[/-][+]The signatures of `{require,check,verify}NonNull` [working decision: nullable, but see #226][/+]on Jan 27, 2022
For the record: this issue was seemingly about the question of whether these parameters would be nullable or non-null. We've agreed that they are nullable. Note that a castNonNull method is a different kind and might not be nullable [WRONG; see clarification]. Some of the trouble we had with the discussion might, I think, have been averted if we had assumed there would be a special marking for these special methods (#226).
A lot of the discussion that had been insisting they be non-nullable turned out to be thinking of a different method, castNonNull, which is not in the set we're talking about here
Not sure about this characterization unless I missed something, since I believe castNonNull/castToNonNull is the one case that was always generally agreed to be taking a @Nullable argument (because it acts as a type cast, which is already an escape hatch from sound static typing).
That said, this doesn't change the resolution. The agreement is that for {require,check,verify}NonNull the annotation of the parameter is @Nullable with an extra specification that they are supposed to fail at runtime on any null value (#226).
I believe the other checker/library that was being discussed then supports distinct "check" and "cast" use cases, where one has a nullable parameter and one non-null, and these each make sense for their particular case. I think I probably just switched them in what I wrote above.
The libraries in the issue title don't make the same distinction and are all of the nullable variety.
library-use-caseQuestion of how a particular library should be annotated; could potentially affect design or docsneeds-decision-post-1.0Issues needing a finalized decision that they are post 1.0nullnessFor issues specific to nullness analysis.
Activity
cpovirk commentedon Feb 16, 2021
There is definitely more to be said about these, and I'd like us to work out at least part of the story before 1.0.
First, the reason I say only "part of the story": I do hope that we can postpone an "authoritative" statement about the signature of any particular JDK method until after 1.0: For now, it would be a huge victory if tools agreed on what a method annotated in a given way means, even without agreeing on which annotations should be "present" on which particular JDK methods. (If nothing else, it would be hard to change the meaning of annotations later -- not that changing the annotations of a JDK method is trivial, either!) Nonetheless, I do believe that the JDK signatures are important to eventually discuss. Offhand, I might classify them as the most important post-1.0 task.
But the part that I do think is important to work out before 1.0 is (I think) the deeper part. As you have noted in the past,
requireNonNullis an especially vivid example of the fundamental disagreement over what it means to annotate something as@Nullable, and we lack a "definition of@Nullable."As it happens, I am working on some Javadoc for
@Nullable-- nominally as part of the project of writing Javadoc for@DefaultNonNullso that we can name that, but also to try to resume peeling off the outer layer of the@Nullablequestion. I have come to think that, if anything, the question at stake withrequireNonNullis deeper than "just"@Nullable: It's a question of what types mean to us. How close do we want to aim to Haskell, in which (I'm told, supposedly with only minor exaggeration) "If your programcompiles, it computes the right answer," as opposed to a more mechanistic approach to types, in which "This method requires aFoo" means nothing more than "The compiler will fight youif you try to pass something that might not be aFoo?" [edit: I need to restate this in a way that does not appeal to tool behavior.]I have thoughts, which I am going to try to keep to myself for the moment, since I do want to make sure I actually carry through on my promises about
@DefaultNonNull, etc. But I wanted to write something here now, since I hate to leave people completely hanging when they bring up something that I do think we need to address. I will keep an eye on this thread, even though I will be trying not to contribute more myself just yet.[edits: previously: #29. Also, eventually consider whether the fact that
requireNonNullis in the standard library should nudge us in some direction: It requires no runtime dependency, and it may be specially supported by JEP-358 someday.][edit: much later relevant PR that I forgot to cite this issue from: google/guava#7090]
mernst commentedon Feb 17, 2021
We need to finalize the definition of
@Nullablebefore any release or announcement.We don't need to finalize the nullness of every JDK method, but we need a definition that leaves no leeway for confusion. Given the definition of
@Nullable, any two engineers should agree on the specification for every JDK method. If we cannot do that, then even we don't understand the specification! Making a release with in such a confused state would introduce confusion rather than clarity.A tool might choose to ship with a different JDK that is more or less restrictive than the true specification. However, that difference should be clear to everyone.
As an example, the correct specification for
System.outis@Nullable, because there exist correct executions in whichSystem.outis null. (But maybe you have a different idea of what@Nullableshould mean? Without a specification, these discussions are confusing and perhaps moot.) The Checker Framework chooses to ship with a more restrictive JDK that forbids some correct programs. That is, the Checker Framework issues false positive warnings for some correct programs that setSystem.outto null and that never crash.In a discussion of
System.out, you said:A tool might make these choices.
However, it is the wrong approach to thinking about the specification. A specification should be unambiguous and objective (not subjective). Discussions about a specification should never depend on ill-defined notions of "normal users" and "what we'd want".
Again, I'm not criticizing this statement as a tool choice.
I think it would be very helpful for us, in every discussion, to distinguish between
I think that will lead to less confusion and better outcomes.
cpovirk commentedon Feb 17, 2021
I promised in the meeting to retract my statement above about what "compiles" and what the "compiler" does. I fully endorse the need to draw a clear line between specification from tool behavior. I believe that I can more accurately describe my conception of a "type" without appealing to tool behavior. But the onus is still on me to do that, as well as to say why I think it's worth reinventing that conception when the Checker Framework has already provided one (as have others).
To tie that back to this issue: I expect my eventual writeup to argue that a definition of
@Nullabledoes not necessarily provide a single correct answer for the specification of every method. But as you say, we really do need to discuss that definition before that claim can make any sense.Again, you have given me plenty to think about on this front, so I am the one who needs to respond to that. That said, I have one quick question:
I had been assuming that the Checker Framework JDK was written to be, as far as possible, a specification rather than a definition of tool behavior. It sounds like I had this wrong, and in fact you consider it to fall into the "tool behavior" bucket? As you say above, there's nothing wrong with that choice; I just want to stop interpreting the Checker Framework JDK as your view of a specification if in fact that is not how it is intended.
mernst commentedon Feb 18, 2021
Your new understanding is correct.
Our goal is to make the Checker Framework JDK as close to the true specification as possible. Whenever they diverge, there is supposed to be a comment. That comment was missing for
System.out, which I just fixed; sorry for the confusion.Please let me know of any other instances of undocumented divergence.
lazaroclapp commentedon Mar 2, 2021
I feel this question is somewhat analogous to arguing whether the following method is legal in the normal Java type system:
Which I believe it is.
Obviously not every program that calls this method with the "correct"
Objecttype is free of runtime errors (related to type), just like not every program callingrequireNonNull(@Nullable Object o)is free of NPEs. But the Java type system allows encoding this type of escape hatch methods, and I don't believe that's a flaw.Am I missing something major with the analogy?
As a general point of opinion, I feel a definition of
@Nullablethat entirely precludes this sort of escape hatch might not be useful, to the point that every tool will have to break it or special case it in some way. I understand the idea of keeping definition and implementation separate, but a definition that will require nearly all usable implementations to break it in the same predictable way is a bad definition for the purposes of setting a standard.I agree we want an unambiguous definition here, if one exists. And I do hope that it does. I just want to also argue that even a confused definition is better than one that demands to be broken by every implementation.
Edit: I just read far along into @wmdietl's doc to realize my analogy is exactly the same he brings up here, but with a more clearly useful method. Either way, I think that analogy will be intuitive to Java developers, even if it leads to a weaker definition/specification.
netdpb commentedon Mar 3, 2021
I think methods like
requireNonNullandverifyNotNullare special in that they have no function other than to be a runtime check. They're the kind of thing that other languages provide at the language level (like Kotlin's!!) or that you use when you don't want to use language-levelasserts.As a runtime check that complements a compile-time check, their principal use is to contextualize the error that null will cause in case the compile-time check fails, either by documenting it in source code for readers, or by adding a message describing the null case, or by associating the error with a better stack context, as in the case where the dereference happens in some callback that will be executed in a different thread:
That being said, it's perfectly reasonable to pass a nullable type to them, as in the following example:
kevinb9n commentedon Jun 15, 2021
Just to address this analogue first, yes, there's nothing bogus about it, it just didn't take advantage of the "shift-left" capabilities available to it, for whatever reason.
Before I get into the actual issue, I just want to point out that #29 (which Chris referenced above) is a full-on duplicate of this issue and there was a lot of discussion on it. So I'm gonna try to put all that together before pretending to have an opinion.
[-]The signature of `requireNonNull` and `verifyNotNull`[/-][+]The signatures of `requireNonNull`, `checkNotNull`, `verifyNotNull`[/+]kevinb9n commentedon Jun 19, 2021
I reread #29 but I'm not sure any of it needs to be brought forward.
Why is this not as simple as this:
What is any example for which we want to tell the user here it's wrong to call one of these methods? What kind of call would deserve some sort of complaint?
(By this I do not mean a "reference definitely non-null, call unnecessary" warning; that's the least of our concerns right now.)
I can't think of any, except ones that are too weird to even take seriously.
"No input is wrong" ---> use most general parameter type.
kevinb9n commentedon Jun 19, 2021
(I did reread the checker framework's rationale, but it opens, "As an example, consider the Nullness Checker. Its goal is to guarantee that your program does not crash due to a null value." And I believe it really is that goal, which is particular to CF and not shared by all JSpecify members, that the stance on that page stems from.)
In our world, there are hundreds of ways that a reference can be non-null yet not statically recognizable as such. It would be ironic if the best method for the user to call in this situation gave them a compile-time error.
Mooninaut commentedon Sep 30, 2021
It seems to me that there are three distinct levels of "nullness" from a static analysis perspective. "Definitely null", "definitely not null", and "maybe null". It is likely an error for non-test code to pass a "definitely null" value to
Objects.requireNonNull(), but not an error to pass a "maybe null", because testing a "maybe null" value for nullness is the entire purpose ofrequireNonNull(). If a value is statically known to be "definitely not null", there's no need to check it, so it really only makes sense to pass "maybe null" values. As kevinb9n says, to forbid "maybe null" as a valid argument torequireNonNull()is to forbid the best method for the situation.Certainly, any method that unconditionally calls
requireNonNull()on one of its arguments should annotate that argument as@NonNull. But that's up to the author, not the specification to decide. CallingrequireNonNull()on the value returned by a method with a@Nullablereturn is perfectly valid, if the method is expected to never return null in that specific context. For example, retrieving a value from a collection, when that collection instance is expected to not contain null values, but the collection class does not forbid them.It is correct to raise a warning or error when passing a "definitely null" value to
requireNonNull(). However, it should be up to the tool user, not the specification, what they want to happen when "maybe null" values are passed to methods likerequireNonNull().To me, this indicates a use case for a
@NullCheck(or similar) special-use annotation for methods that throw on null by design. A parameter annotated@NullCheckwould cause a static analysis tool to do one of a) nothing, b) issue a warning , or c) issue an error when a "maybe null" value is passed to it, configurable by the tool's user. Allowing separate configuration for@NullCheckand@NonNullwarning/error behavior gives users flexibility to meet their particular requirements.The signature would then be
<T> @NonNull T requireNonNull(@NullCheck T obj).In a high-assurance application I would likely choose option c), and individually document/suppress each instance, but not all code needs that level of strictness.
kevinb9n commentedon Jan 19, 2022
Thanks @Mooninaut and sorry we didn't respond yet. Your 3 categories correspond to these types (using
Stringas example):String- definitely non-null@Nullable String- String U NullTypeI think checkers will be able to track "definitely null" for purposes of issuing "redundant null check" warnings, but I do want to classify that as a lesser type of warning/error than actual type errors, for what that's worth. Overall I don't think we worry much about it.
I also came to the conclusion that we're going to need a special annotation to use with methods like
requireNonNull.Specifically, this would be a parameter annotation that declares, "this method promises not to complete normally if this parameter is null". This is what would allow checkers to "learn" about the non-nullness of a ref-transparent expression below the point where that expression is passed to
requireNonNulletc. And that's useful/important.Fortunately, if these methods require a specialized marking, that takes the pressure off this particular issue/question. I will maintain that the parameters are still very much nullable in this scenario. (A lot of the discussion that had been insisting they be non-nullable turned out to be thinking of a different method, castNonNull, which is not in the set we're talking about here.)
But, the new issue I'm gonna file for the annotation can encompass this nullable question, so I think we'll be closing this one soon.
kevinb9n commentedon Jan 19, 2022
Filed #226
[-]The signatures of `requireNonNull`, `checkNotNull`, `verifyNotNull`[/-][+]The signatures of `{require,check,verify}NonNull` [working decision: nullable, but see #226][/+]kevinb9n commentedon Feb 1, 2022
For the record: this issue was seemingly about the question of whether these parameters would be nullable or non-null. We've agreed that they are nullable. Note that a
castNonNullmethod is a different kind and might not be nullable [WRONG; see clarification]. Some of the trouble we had with the discussion might, I think, have been averted if we had assumed there would be a special marking for these special methods (#226).lazaroclapp commentedon Feb 2, 2022
Not sure about this characterization unless I missed something, since I believe
castNonNull/castToNonNullis the one case that was always generally agreed to be taking a@Nullableargument (because it acts as a type cast, which is already an escape hatch from sound static typing).That said, this doesn't change the resolution. The agreement is that for
{require,check,verify}NonNullthe annotation of the parameter is@Nullablewith an extra specification that they are supposed to fail at runtime on anynullvalue (#226).kevinb9n commentedon Feb 2, 2022
Whoops.
I believe the other checker/library that was being discussed then supports distinct "check" and "cast" use cases, where one has a nullable parameter and one non-null, and these each make sense for their particular case. I think I probably just switched them in what I wrote above.
The libraries in the issue title don't make the same distinction and are all of the nullable variety.
Did I get it right this time maybe?