-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java @Nullable annotations in generated classes #1115
Comments
Unless I'm missing something, nullable was never standardized in Java? JSR305 was shot down, and then we've never got any official support for these anywhere in vendor-provided Java classes? If that's true, this complicates generation of such annotations quite a bit — i.e. instead of following one standard (which will still probably need at less on/off flag), we'll need to support X different ways, e.g.:
|
Searching GitHub for all Nullable in Java, we can find that there are ~3.2M files using it. We can also explore how popular are specific implementations:
|
Yeah, what libraries usually do is allow configuring what annotation class to use as a nullable annotation. That way we, for example, could specify |
Overall, sounds good then. We could add something like |
I agree, although calling it "class" seems a bit technically inaccurate (apparently, the correct Java term is "annotation type"). I'd rather call it |
Ok, so the action plan roughly seems like is:
@roded Do you think you'll be interested in contributing any of these? |
@GreyCat Theoretically I'd be glad to. But I'm swamped for the next few months and I don't think I'll be able to find the time to contribute unfortunately. So long as this does not pick up more votes, feel free to keep this open till I do though. |
We use Checkerframework to ensure a project's null-safety.
In our case, this is done by assuming that all fields and parameters are annotated by
@NotNull
implicitly while nullable fields and parameters are explicitly annotated by a@Nullable
annotations.The generated Kaitai classes do have some nullable constructor parameters which fail the null-safty check in a project in which Checkerframework is enabled.
It would be nice to be able to instruct Kaitai to add a (customizable)
@Nullable
annotation where appropriate.The text was updated successfully, but these errors were encountered: