Skip to content
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

Request: add nullability annotations for functions #5402

Closed
AndroidDeveloperLB opened this issue Jan 17, 2019 · 8 comments
Closed

Request: add nullability annotations for functions #5402

AndroidDeveloperLB opened this issue Jan 17, 2019 · 8 comments
Assignees

Comments

@AndroidDeveloperLB
Copy link

For example, to SimpleExoPlayer.getVideoFormat() , which could return null:

  /**
   * Returns the video format currently being played, or null if no video is being played.
   */
  public Format getVideoFormat() {
    return videoFormat;
  }

This is especially important when developing using Kotlin, as the IDE doesn't consider Java returned values as nullable by default when writing on Kotlin.

@tonihei tonihei self-assigned this Jan 17, 2019
@tonihei
Copy link
Collaborator

tonihei commented Jan 17, 2019

Thanks for reporting. We'll fix that one.

Note that we added all the nullable annotations only recently and we may have missed some parts of the most used APIs.

@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented Jan 17, 2019

Thank you.
Speaking of Kotlin, does it also make sense to make the library in Kotlin, or is it a useless thing to do?

@tonihei
Copy link
Collaborator

tonihei commented Jan 17, 2019

Java and Kotlin are interoperable, so there is no point in having the library in both languages.

@AndroidDeveloperLB
Copy link
Author

That's not entirely true. They work fine with each other, but when coding via the IDE, you will notice issues between them, that the IDE doesn't help you with, as opposed to when writing only in Kotlin on both cases.

For example this case. On Kotlin you'd have to set nullability, but on Java, you don't have to, and since the IDE still can't handle nullability issues between them, it can always be an issue.

@tonihei
Copy link
Collaborator

tonihei commented Jan 17, 2019

Well, we do try to make sure it can be used in Kotlin and Java in the same way, that's why we are adding the annotations. We also did a few other things (e.g. moving Runnables to the last argument in each method to allow usages of the improved Kotlin syntax).

Besides that, the code is running fine in both languages and all improvements are only around ease of use and not actual functionality.

@AndroidDeveloperLB
Copy link
Author

Of course.
I just asked if it might be better, because as much as I like Java, Kotlin helps more in those things
:)

ojw28 pushed a commit that referenced this issue Jan 17, 2019
@tonihei
Copy link
Collaborator

tonihei commented Jan 18, 2019

Closing as fixed.

@tonihei tonihei closed this as completed Jan 18, 2019
@AndroidDeveloperLB
Copy link
Author

@tonihei Thank you!

ojw28 pushed a commit that referenced this issue Jan 21, 2019
@google google locked and limited conversation to collaborators Aug 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants