Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2641

Add JSR-305-compatible NonNull annotations to the driver API

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.7.0
    • Affects Version/s: None
    • Component/s: API
    • None

      Annotating the public API with NonNull annotations will allow tools like IntelliJ and other JVM languages like Kotlin to enforce constraints on application code that uses the driver.

      See for an example the recent support for null-safety added to Spring Framework 5.0 here.

      A couple of strange things about JSR-305 that need to be considered:

      • It was never actually approved and incorporated into the JDK. Rather, it's available at the following Maven coordinates: com.google.code.findbugs:jsr305:3.0.2
      • The package javax.annotation is exported by the java.xml.ws.annotation module in Java 9, and, though it's deprecated and slated for removal, I think that will conflict with any other module that also contains classes in the same package (like the JSR-305 one). However, this doesn't appear to affect Spring, perhaps because the JSR-305 jar file is a compileOnly dependency.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: