Skip to content

batch of javadoc revisions for clarity and completeness - #671

Merged
kevinb9n merged 13 commits into
jspecify:mainfrom
kevinb9n:main
Jul 17, 2026
Merged

kevinb9n merged 13 commits into
jspecify:mainfrom
kevinb9n:main

Conversation

@kevinb9n

Copy link
Copy Markdown
Collaborator

I honestly don't remember everything I did here or why :-) so let's just go ahead and discuss how to make it best from here!

@google-cla

google-cla Bot commented Sep 26, 2024

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@kevinb9n
kevinb9n requested a review from netdpb September 26, 2024 00:47

@netdpb netdpb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is good editing!

Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
@kevinb9n

Copy link
Copy Markdown
Collaborator Author

Sorry for the delay; I am still embroiled in the epic journey of getting approval to sign the CLA.

@cpovirk cpovirk added this to the 1.0.1? milestone Jun 30, 2026
@kevinb9n
kevinb9n marked this pull request as draft July 10, 2026 17:51
@kevinb9n

Copy link
Copy Markdown
Collaborator Author

This is not in "PTAL" status just yet but it's coming.

@kevinb9n
kevinb9n marked this pull request as ready for review July 14, 2026 18:45
@kevinb9n

Copy link
Copy Markdown
Collaborator Author

I believe I addressed everything above, but at this point this is basically a whole new PR and should just be reviewed holistically.

Happy to back out of any of these changes, whatever works.

@kevinb9n

Copy link
Copy Markdown
Collaborator Author

I'm also happy to make subsequent editing passes after this goes in if anyone wants, such as to maybe trim it all down.

@cpovirk cpovirk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

Comment thread src/main/java/org/jspecify/annotations/NonNull.java Outdated
*
* <p>For a comprehensive introduction to JSpecify, please see <a
* href="https://jspecify.dev">jspecify.org</a>.
* <p>The {@linkplain org.jspecify.annotations package documentation} has some important general

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old "For a comprehensive introduction..." opening set the stage here a bit more for readers."

We could keep that general approach with something like:

"For some general information common to all four nulless annotations, see the package documentation. For a comprehensive introduction...."

(and similarly in the other files once we have something that we're happy with)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay this here in NonNull.java is my current proposal to duplicate to the other places.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Where do I go for the unimportant general information?" :)

So I might cut that one word, but I don't mind it even as much as the joke suggests.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, maybe it's not even that important? Can go either way. Will leave this open just a bit before I start cloning.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'm still overall more a fan of opening with "For some [important] general information..." than with "The package documentation," and I might like "See the package documentation..." somewhere in between how much I like those two, but I'm also still willing to let this go.)

Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
* annotations of that type are synonymous with {@code @NullMarked}. It has the same meaning
* as it does anywhere else.
* <li>These annotations have no meaning when applied to a <b>record component</b> declaration (as
* in {@code record Foo(@NullMarked String bar) {}}). ({@link Nullable} and {@link NonNull}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you asked somewhere about where/whether to bother with {@link Nullable @Nullable} and likewise for @NonNull. I guess I'm in favor of always bothering?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying what I hope is a consistent policy, which is that if it seems like we're talking about what you see or write at the use-site then we need the @. I think that ended up applying in most cases.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way though, I mean, these annotations do get copied to a generated accessor method, so I guess that could have an effect?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I think these were the only ones that jumped out to me as possibly "missing" the @. Above, we say "where @nullable and @nonnull are not applicable," and here we say "Nullable and NonNull are still meaningful," so, while I'm sure we can argue that there's a difference there, it seems unlikely that the average reader would expect a difference.
  • Yes, they would end up being copied to the generated accessor method, so they would have an effect downstream. We were aware of that when we made our decision, but I think we might have felt more "We have bigger fish to fry" than "We feel that this is overwhelmingly the correct decision." I think that our goal was more to discourage people from writing it than to pretend that it wouldn't have an effect downstream.

@netdpb

netdpb commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Can you resolve the merge conflicts?

Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java
Comment thread src/main/java/org/jspecify/annotations/Nullable.java
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread .gitignore
@kevinb9n

Copy link
Copy Markdown
Collaborator Author

Okay I've finally finished my round of updates, merged, pushed and all that. Sorry about the flood of premature emails.

@cpovirk cpovirk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran out of time at the end of my day, but have a few comments in case you want to start on them early or in case they save anyone else the time of typing something similar.

Comment thread src/main/java/org/jspecify/annotations/package-info.java
Comment thread .gitignore
*
* <p>For a comprehensive introduction to JSpecify, please see <a
* href="https://jspecify.dev">jspecify.org</a>.
* <p>The {@linkplain org.jspecify.annotations package documentation} has some important general

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Where do I go for the unimportant general information?" :)

So I might cut that one word, but I don't mind it even as much as the joke suggests.

* Indicates that the annotated <a href="https://github.com/jspecify/jspecify/wiki/type-usages">type
* usage</a> (commonly a parameter type or return type) is considered to <i>exclude</i> {@code null}
* as a value; rarely needed within {@linkplain NullMarked null-marked} code.
* as a value; rarely needed within {@linkplain NullMarked null-marked} context.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have definitely used "context" in discussions of this before. My thoughts are:

  • I am trying to remember whether we discussed it and decided to try to move toward / away from it. But I don't remember. I could also be thinking of some different word, like "scope." Oh, yes, here we go.
  • My brain expects "a null-marked context." (Here's a post in which you used it both ways :)) Gemini cites JLS precedent at me:
    • "in a static context"
    • "in an assignment context"
    • "in a boolean/numeric context"
      • (I see only "in a numeric arithmetic context" in a quick search.)

@kevinb9n kevinb9n Jul 16, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JLS uses the word in two ways, as shown by your first example versus the others. The others are, like a "countable" noun, a single context is a place where some single thing gets plugged in. Chief example of course being "type context".

"In a static context" is different and if I were editing the JLS I might consider phrasing it "in static context" instead of implying it is a countable thing like the other cases. And this is the sense in which I'm trying to use the word here now. Purely: "hey what kind of context are we currently in here, A or B?" Our case is the cleaner one since I think "static context" is relative to which containing class you're talking about.

Good 'nuff?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For "type context," I'm seeing "a type context," "type contexts," and "any type context," right?

It's reasonable to argue that the JLS should drop the "the" as a more general rule, and I don't need to push on that if you just want to buck the trend, but to check: Are we in agreement that you are in fact bucking the JLS trend, or is there more that hasn't yet registered with me?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what your first question means, but those are all valid phrases treating type contexts as the "countable kind of context" if you want to think of it that way.

Then there are the other kind, of which we've noted two examples, "static context", and "null-marked context". The way I see it, as far as a user knows maybe JSpecify does have weird rules to learn of the form "sure, that's true for that null-marked context, but not for the other null-marked context that is three null-marked contexts down from where you are." It's relevant that we don't have any rules like that, so I thinks, I'll drop the "a".

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I think I prefer "code" to "context": Even with you explanation, "null-marked context" continues to jump out to me, and I'd expect it to jump out a bit to a decent number of other users. Plus, it's longer, and it's one of those words that is used so widely for Java class names (and often in ways that would have me clutching my pearls) that it doesn't really add anything from my perspective. I am not particularly invested in the phrasing here, either, but I assume you have a sales pitch for "context," and I'm up for trying to evaluate it if that sounds like a good time to you.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is oh very subjective, but for whatever reason, "null-marked code" gives me slightly more of a "but what do they mean by 'code'? What is the definition of 'code' here?" reaction. Whereas somehow when I hit "context" I don't feel like it might be implying something specific I have to go learn about. I dunno.

Comment thread src/main/java/org/jspecify/annotations/NonNull.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NonNull.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
* annotations of that type are synonymous with {@code @NullMarked}. It has the same meaning
* as it does anywhere else.
* <li>These annotations have no meaning when applied to a <b>record component</b> declaration (as
* in {@code record Foo(@NullMarked String bar) {}}). ({@link Nullable} and {@link NonNull}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I think these were the only ones that jumped out to me as possibly "missing" the @. Above, we say "where @nullable and @nonnull are not applicable," and here we say "Nullable and NonNull are still meaningful," so, while I'm sure we can argue that there's a difference there, it seems unlikely that the average reader would expect a difference.
  • Yes, they would end up being copied to the generated accessor method, so they would have an effect downstream. We were aware of that when we made our decision, but I think we might have felt more "We have bigger fish to fry" than "We feel that this is overwhelmingly the correct decision." I think that our goal was more to discourage people from writing it than to pretend that it wouldn't have an effect downstream.

*
* <p>For a comprehensive introduction to JSpecify, please see <a
* href="https://jspecify.dev">jspecify.org</a>.
* <p>The {@linkplain org.jspecify.annotations package documentation} has some important general

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'm still overall more a fan of opening with "For some [important] general information..." than with "The package documentation," and I might like "See the package documentation..." somewhere in between how much I like those two, but I'm also still willing to let this go.)

Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java
Comment thread src/main/java/org/jspecify/annotations/Nullable.java Outdated
Comment thread src/main/java/org/jspecify/annotations/Nullable.java
* Indicates that the annotated <a href="https://github.com/jspecify/jspecify/wiki/type-usages">type
* usage</a> (commonly a parameter type or return type) is considered to <i>exclude</i> {@code null}
* as a value; rarely needed within {@linkplain NullMarked null-marked} code.
* as a value; rarely needed within {@linkplain NullMarked null-marked} context.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I think I prefer "code" to "context": Even with you explanation, "null-marked context" continues to jump out to me, and I'd expect it to jump out a bit to a decent number of other users. Plus, it's longer, and it's one of those words that is used so widely for Java class names (and often in ways that would have me clutching my pearls) that it doesn't really add anything from my perspective. I am not particularly invested in the phrasing here, either, but I assume you have a sales pitch for "context," and I'm up for trying to evaluate it if that sounds like a good time to you.

Comment thread src/main/java/org/jspecify/annotations/NullUnmarked.java
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
Comment thread src/main/java/org/jspecify/annotations/NullMarked.java Outdated
@kevinb9n
kevinb9n merged commit f01eac9 into jspecify:main Jul 17, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants