From e7fac68c97616c39869689d837abcfe63ae012a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Kalliom=C3=A4ki?= Date: Tue, 20 Mar 2018 16:32:49 +0100 Subject: [PATCH] Introduce Nullable annotation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Patrik Höglund Reviewed-by: Mirko Bonadei Cr-Commit-Position: refs/heads/master@{#22526} --- rtc_base/BUILD.gn | 10 ++++++++++ rtc_base/java/src/org/webrtc/ThreadUtils.java | 3 ++- tools_webrtc/libs/generate_licenses.py | 4 +++- webrtc.gni | 9 ++++++++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index 61b92f67e3..2ab391e6b8 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -1380,5 +1380,15 @@ if (is_android) { "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 3cc80d39ca..a403870906 100644 --- a/rtc_base/java/src/org/webrtc/ThreadUtils.java +++ b/rtc_base/java/src/org/webrtc/ThreadUtils.java @@ -16,13 +16,14 @@ import android.os.SystemClock; 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 03df3936ca..884628bcb8 100755 --- a/tools_webrtc/libs/generate_licenses.py +++ b/tools_webrtc/libs/generate_licenses.py @@ -24,6 +24,7 @@ import subprocess 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 @@ LIB_TO_LICENSES_DICT = { '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 @@ CHECKOUT_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir)) 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 f2a196ed61..f91aa01579 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -496,8 +496,15 @@ if (is_android) { "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 }