question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support Java nullability annotations

See original GitHub issue

[@lucaswerkmeister] Several frameworks have attempted to improve on Java’s nullability support by introducing annotations for something being @Nullable or @NotNull/@NonNull/@Nonnull. We should recognize these annotations, and warn or error if:

  • a Java @Nullable value (method return type, or field) is assigned to a Ceylon non-optional value or a Java @NotNull, or
  • a Ceylon optional value or a Java @Nullable value is assigned to a Java @NotNull value (method parameter, setter parameter, or field).

Behavior on unannotated elements should not change. Some frameworks define only one annotation because the other is the default, but we can’t detect that.

Test cases / examples: https://gist.github.com/lucaswerkmeister/07556232a9bd060dd593

Annotations to support (suggestion, potentially incomplete; list from Kotlin):

Alternatively, we could assume that any annotation named @Nullable, @NotNull, @NonNull, @Nonnull has this meaning. I think that’s probably a reasonable assumption.

[Migrated from ceylon/ceylon-model#8]

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
FroMagecommented, Jun 30, 2016

OK, changed setters to inherit annotations from getter if there’s none on the setter param. Closing.

0reactions
gavinkingcommented, Jun 30, 2016

Cool!

Read more comments on GitHub >

github_iconTop Results From Across the Web

@Nullable and @NotNull | IntelliJ IDEA Documentation
@Nullable and @NotNull annotations let you check nullability of a variable, parameter, or return value. They help you control contracts ...
Read more >
Support @Nullable annotations? · Issue #1693 - GitHub
It's javax.annotation.Nonnull . So basically here was my setup : .vscode/settings.json. { "java.settings.url ...
Read more >
Spring Null-Safety Annotations - Baeldung
A quick and practical guide to null-safety annotations in Spring.
Read more >
Using null annotations - IBM
The Eclipse Java compiler can be configured to use three distinct annotation types ... Annotations @NonNull and @Nullable are supported in these locations:....
Read more >
Problems with Nullability Annotations - PSPDFKit
Android's nullability annotations are a powerful tool for augmenting Java's incomplete type system. However, there are various pitfalls of nullability ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found