Skip to content

Nullability of arguments and return values #206

Closed Answered by omix
paul35621 asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you for your question.
Nullability annotations are primarily for Kotlin, as Kotlin supports nullable and non-nullable types.

  • Everywhere the C++ Qt API has a T* argument, QtJambiGenerator creates a Java @Nullable T argument.
  • For every const V& with a copyable value type V the Java API is @NonNull V. However, you can assign null to it in Java. Java null is converted in the default-constructed value V().
  • A C++ T& argument is mapped to Java @StrictNonNull T. This annotation causes Kotlin compiler to give a compilation error in case you assign null. If you send null in Java, a NullPointerException will appear.
  • There are methods in Qt accepting a T* pointer but don't allow a null pointer…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@paul35621
Comment options

@paul35621
Comment options

Answer selected by omix
# for free to join this conversation on GitHub. Already have an account? # to comment
Category
Q&A
Labels
None yet
2 participants