diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/Assertions.java b/library/common/src/main/java/com/google/android/exoplayer2/util/Assertions.java index f83e918d4a..aae75620c1 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/Assertions.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/Assertions.java @@ -108,7 +108,12 @@ public final class Assertions { * @return The non-null reference that was validated. * @throws IllegalStateException If {@code reference} is null. */ - @SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"}) + @SuppressWarnings({ + "contracts.postcondition.not.satisfied", + "nullness:contracts.postcondition", + "return.type.incompatible", + "nullness:return" + }) @EnsuresNonNull({"#1"}) @Pure public static T checkStateNotNull(@Nullable T reference) { @@ -128,7 +133,12 @@ public final class Assertions { * @return The non-null reference that was validated. * @throws IllegalStateException If {@code reference} is null. */ - @SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"}) + @SuppressWarnings({ + "contracts.postcondition.not.satisfied", + "nullness:contracts.postcondition", + "return.type.incompatible", + "nullness:return" + }) @EnsuresNonNull({"#1"}) @Pure public static T checkStateNotNull(@Nullable T reference, Object errorMessage) { @@ -146,7 +156,12 @@ public final class Assertions { * @return The non-null reference that was validated. * @throws NullPointerException If {@code reference} is null. */ - @SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"}) + @SuppressWarnings({ + "contracts.postcondition.not.satisfied", + "nullness:contracts.postcondition", + "return.type.incompatible", + "nullness:return" + }) @EnsuresNonNull({"#1"}) @Pure public static T checkNotNull(@Nullable T reference) { @@ -166,7 +181,12 @@ public final class Assertions { * @return The non-null reference that was validated. * @throws NullPointerException If {@code reference} is null. */ - @SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"}) + @SuppressWarnings({ + "contracts.postcondition.not.satisfied", + "nullness:contracts.postcondition", + "return.type.incompatible", + "nullness:return" + }) @EnsuresNonNull({"#1"}) @Pure public static T checkNotNull(@Nullable T reference, Object errorMessage) { @@ -183,7 +203,12 @@ public final class Assertions { * @return The non-null, non-empty string that was validated. * @throws IllegalArgumentException If {@code string} is null or 0-length. */ - @SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"}) + @SuppressWarnings({ + "contracts.postcondition.not.satisfied", + "nullness:contracts.postcondition", + "return.type.incompatible", + "nullness:return" + }) @EnsuresNonNull({"#1"}) @Pure public static String checkNotEmpty(@Nullable String string) { @@ -202,7 +227,12 @@ public final class Assertions { * @return The non-null, non-empty string that was validated. * @throws IllegalArgumentException If {@code string} is null or 0-length. */ - @SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"}) + @SuppressWarnings({ + "contracts.postcondition.not.satisfied", + "nullness:contracts.postcondition", + "return.type.incompatible", + "nullness:return" + }) @EnsuresNonNull({"#1"}) @Pure public static String checkNotEmpty(@Nullable String string, Object errorMessage) { diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/BundleUtil.java b/library/common/src/main/java/com/google/android/exoplayer2/util/BundleUtil.java index 1c1e139d80..2fd251a168 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/BundleUtil.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/BundleUtil.java @@ -61,7 +61,7 @@ public final class BundleUtil { } // Method.invoke may take null "key". - @SuppressWarnings("nullness:argument.type.incompatible") + @SuppressWarnings({"nullness:argument.type.incompatible", "nullness:argument"}) @Nullable private static IBinder getBinderByReflection(Bundle bundle, @Nullable String key) { @Nullable Method getIBinder = getIBinderMethod; @@ -85,7 +85,7 @@ public final class BundleUtil { } // Method.invoke may take null "key" and "binder". - @SuppressWarnings("nullness:argument.type.incompatible") + @SuppressWarnings({"nullness:argument.type.incompatible", "nullness:argument"}) private static void putBinderByReflection( Bundle bundle, @Nullable String key, @Nullable IBinder binder) { @Nullable Method putIBinder = putIBinderMethod; diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/ListenerSet.java b/library/common/src/main/java/com/google/android/exoplayer2/util/ListenerSet.java index 81715e8b98..6dbceee659 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/ListenerSet.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/ListenerSet.java @@ -102,7 +102,7 @@ public final class ListenerSet { flushingEvents = new ArrayDeque<>(); queuedEvents = new ArrayDeque<>(); // It's safe to use "this" because we don't send a message before exiting the constructor. - @SuppressWarnings("methodref.receiver.bound.invalid") + @SuppressWarnings({"methodref.receiver.bound.invalid", "nullness:methodref.receiver.bound"}) HandlerWrapper handler = clock.createHandler(looper, this::handleMessage); this.handler = handler; } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableNalUnitBitArray.java b/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableNalUnitBitArray.java index 46a532040e..2a3acc4b35 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableNalUnitBitArray.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableNalUnitBitArray.java @@ -35,7 +35,11 @@ public final class ParsableNalUnitBitArray { * @param offset The byte offset in {@code data} to start reading from. * @param limit The byte offset of the end of the bitstream in {@code data}. */ - @SuppressWarnings({"initialization.fields.uninitialized", "method.invocation.invalid"}) + @SuppressWarnings({ + "initialization.fields.uninitialized", + "method.invocation.invalid", + "nullness:method.invocation" + }) public ParsableNalUnitBitArray(byte[] data, int offset, int limit) { reset(data, offset, limit); } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java b/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java index 97afa6a67d..4f541118ff 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java @@ -335,14 +335,24 @@ public final class Util { * *

Use {@link Assertions#checkNotNull(Object)} to throw if the value is null. */ - @SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"}) + @SuppressWarnings({ + "contracts.postcondition.not.satisfied", + "nullness:contracts.postcondition", + "return.type.incompatible", + "nullness:return" + }) @EnsuresNonNull("#1") public static T castNonNull(@Nullable T value) { return value; } /** Casts a nullable type array to a non-null type array without runtime null check. */ - @SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"}) + @SuppressWarnings({ + "contracts.postcondition.not.satisfied", + "nullness:contracts.postcondition", + "return.type.incompatible", + "nullness:return" + }) @EnsuresNonNull("#1") public static T[] castNonNullTypeArray(@NullableType T[] value) { return value; @@ -356,7 +366,12 @@ public final class Util { * @param length The output array length. Must be less or equal to the length of the input array. * @return The copied array. */ - @SuppressWarnings({"nullness:argument.type.incompatible", "nullness:return.type.incompatible"}) + @SuppressWarnings({ + "nullness:argument.type.incompatible", + "nullness:argument", + "nullness:return.type.incompatible", + "nullness:return" + }) public static T[] nullSafeArrayCopy(T[] input, int length) { Assertions.checkArgument(length <= input.length); return Arrays.copyOf(input, length); @@ -370,7 +385,12 @@ public final class Util { * @param to The end of the range to be copied, exclusive. * @return The copied array. */ - @SuppressWarnings({"nullness:argument.type.incompatible", "nullness:return.type.incompatible"}) + @SuppressWarnings({ + "nullness:argument.type.incompatible", + "nullness:argument", + "nullness:return.type.incompatible", + "nullness:return" + }) public static T[] nullSafeArrayCopyOfRange(T[] input, int from, int to) { Assertions.checkArgument(0 <= from); Assertions.checkArgument(to <= input.length); @@ -397,7 +417,7 @@ public final class Util { * @param second The second array. * @return The concatenated result. */ - @SuppressWarnings({"nullness:assignment.type.incompatible"}) + @SuppressWarnings({"nullness:assignment.type.incompatible", "nullness:assignment"}) public static T[] nullSafeArrayConcatenation(T[] first, T[] second) { T[] concatenation = Arrays.copyOf(first, first.length + second.length); System.arraycopy( @@ -491,7 +511,12 @@ public final class Util { * callback is required. * @return A {@link Handler} with the specified callback on the current {@link Looper} thread. */ - @SuppressWarnings({"nullness:argument.type.incompatible", "nullness:return.type.incompatible"}) + @SuppressWarnings({ + "nullness:argument.type.incompatible", + "nullness:argument", + "nullness:return.type.incompatible", + "nullness:return" + }) public static Handler createHandler( Looper looper, @Nullable Handler.@UnknownInitialization Callback callback) { return new Handler(looper, callback); @@ -1212,7 +1237,11 @@ public final class Util { */ // incompatible types in argument. // dereference of possibly-null reference matcher.group(9) - @SuppressWarnings({"nullness:argument.type.incompatible", "nullness:dereference.of.nullable"}) + @SuppressWarnings({ + "nullness:argument.type.incompatible", + "nullness:argument", + "nullness:dereference.of.nullable" + }) public static long parseXsDateTime(String value) throws ParserException { Matcher matcher = XS_DATE_TIME_PATTERN.matcher(value); if (!matcher.matches()) {