Introduce Nullable annotation.

Just adds the annotation to base_java for now to check that this does
not break any downstream targets.

Bug: webrtc:8881
Change-Id: I9425020e36be5e52447cec592a4474a9eb09b5bd
Reviewed-on: https://webrtc-review.googlesource.com/51960
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22526}
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index 61b92f6..2ab391e 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -1380,5 +1380,15 @@
       "java/src/org/webrtc/Size.java",
       "java/src/org/webrtc/ThreadUtils.java",
     ]
+
+    javac_args = [
+      "-Xep:ParameterNotNullable:ERROR",
+      "-Xep:FieldMissingNullable:ERROR",
+      "-Xep:ReturnMissingNullable:ERROR",
+    ]
+
+    deps = [
+      "//third_party/jsr-305:jsr_305_javalib",
+    ]
   }
 }
diff --git a/rtc_base/java/src/org/webrtc/ThreadUtils.java b/rtc_base/java/src/org/webrtc/ThreadUtils.java
index 3cc80d3..a403870 100644
--- a/rtc_base/java/src/org/webrtc/ThreadUtils.java
+++ b/rtc_base/java/src/org/webrtc/ThreadUtils.java
@@ -16,13 +16,14 @@
 import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
+import javax.annotation.Nullable;
 
 public class ThreadUtils {
   /**
    * Utility class to be used for checking that a method is called on the correct thread.
    */
   public static class ThreadChecker {
-    private Thread thread = Thread.currentThread();
+    @Nullable private Thread thread = Thread.currentThread();
 
     public void checkIsOnValidThread() {
       if (thread == null) {
diff --git a/tools_webrtc/libs/generate_licenses.py b/tools_webrtc/libs/generate_licenses.py
index 03df393..884628b 100755
--- a/tools_webrtc/libs/generate_licenses.py
+++ b/tools_webrtc/libs/generate_licenses.py
@@ -24,6 +24,7 @@
 LIB_TO_LICENSES_DICT = {
     'android_tools': ['third_party/android_tools/LICENSE'],
     'auto': ['third_party/auto/src/LICENSE.txt'],
+    'bazel': ['third_party/bazel/LICENSE'],
     'boringssl': ['third_party/boringssl/src/LICENSE'],
     'errorprone': ['third_party/errorprone/LICENSE'],
     'expat': ['third_party/expat/files/COPYING'],
@@ -31,6 +32,7 @@
     'guava': ['third_party/guava/LICENSE'],
     'ijar': ['third_party/ijar/LICENSE'],
     'jsoncpp': ['third_party/jsoncpp/LICENSE'],
+    'jsr-305': ['third_party/jsr-305/src/ri/LICENSE'],
     'libc++': ['buildtools/third_party/libc++/trunk/LICENSE.TXT'],
     'libc++abi': ['buildtools/third_party/libc++abi/trunk/LICENSE.TXT'],
     'libevent': ['base/third_party/libevent/LICENSE'],
@@ -54,7 +56,7 @@
 sys.path.append(os.path.join(CHECKOUT_ROOT, 'build'))
 import find_depot_tools
 
-THIRD_PARTY_LIB_REGEX = r'^.*/third_party/([\w+]+).*$'
+THIRD_PARTY_LIB_REGEX = r'^.*/third_party/([\w\-+]+).*$'
 
 class LicenseBuilder(object):
 
diff --git a/webrtc.gni b/webrtc.gni
index f2a196e..f91aa01 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -496,8 +496,15 @@
                                "visibility",
                              ])
 
+      javac_args = []
+
       # Treat warnings as errors.
-      javac_args = [ "-Werror" ]
+      javac_args += [ "-Werror" ]
+
+      # Add any arguments defined by the invoker.
+      if (defined(invoker.javac_args)) {
+        javac_args += invoker.javac_args
+      }
 
       no_build_hooks = true
     }