diff --git a/java/util/src/main/java/com/google/protobuf/util/Durations.java b/java/util/src/main/java/com/google/protobuf/util/Durations.java index bbcac19b05fa9..1dd153229a690 100644 --- a/java/util/src/main/java/com/google/protobuf/util/Durations.java +++ b/java/util/src/main/java/com/google/protobuf/util/Durations.java @@ -20,6 +20,7 @@ import static com.google.protobuf.util.Timestamps.NANOS_PER_SECOND; import com.google.common.annotations.GwtIncompatible; +import com.google.common.annotations.J2ktIncompatible; import com.google.common.base.Strings; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.CompileTimeConstant; @@ -144,6 +145,7 @@ public static boolean isPositive(Duration duration) { */ @CanIgnoreReturnValue @GwtIncompatible("Depends on String.format which is not supported in Xplat.") + @J2ktIncompatible @J2ObjCIncompatible public static Duration checkNotNegative(Duration duration) { checkArgument(!isNegative(duration), "duration (%s) must not be negative", toString(duration)); @@ -158,6 +160,7 @@ public static Duration checkNotNegative(Duration duration) { */ @CanIgnoreReturnValue @GwtIncompatible("Depends on String.format which is not supported in Xplat.") + @J2ktIncompatible @J2ObjCIncompatible public static Duration checkPositive(Duration duration) { checkArgument(isPositive(duration), "duration (%s) must be positive", toString(duration)); @@ -201,6 +204,7 @@ public static Duration checkValid(Duration.Builder durationBuilder) { * @throws IllegalArgumentException if the given duration is not in the valid range. */ @GwtIncompatible("Depends on String.format which is not supported in Xplat.") + @J2ktIncompatible @J2ObjCIncompatible public static String toString(Duration duration) { checkValid(duration); @@ -230,6 +234,7 @@ public static String toString(Duration duration) { * @throws ParseException if the string is not in the duration format */ @GwtIncompatible("ParseException is not supported in Xplat") + @J2ktIncompatible @J2ObjCIncompatible public static Duration parse(String value) throws ParseException { // Must end with "s". @@ -281,6 +286,7 @@ public static Duration parse(String value) throws ParseException { * @throws IllegalArgumentException if parsing fails */ @GwtIncompatible("ParseException is not supported in Xplat") + @J2ktIncompatible @J2ObjCIncompatible public static Duration parseUnchecked(@CompileTimeConstant String value) { try { diff --git a/java/util/src/main/java/com/google/protobuf/util/Timestamps.java b/java/util/src/main/java/com/google/protobuf/util/Timestamps.java index 8d60a93e93a1e..40146e942e6a8 100644 --- a/java/util/src/main/java/com/google/protobuf/util/Timestamps.java +++ b/java/util/src/main/java/com/google/protobuf/util/Timestamps.java @@ -14,6 +14,7 @@ import static com.google.common.math.LongMath.checkedSubtract; import com.google.common.annotations.GwtIncompatible; +import com.google.common.annotations.J2ktIncompatible; import com.google.common.base.Strings; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.CompileTimeConstant; @@ -66,6 +67,7 @@ public final class Timestamps { @GwtIncompatible("Date formatting is not supported in non JVM java.time") @J2ObjCIncompatible + @J2ktIncompatible private static final ThreadLocal timestampFormat = new ThreadLocal() { @Override @@ -76,6 +78,7 @@ protected SimpleDateFormat initialValue() { @GwtIncompatible("Date formatting is not supported in non JVM java.time") @J2ObjCIncompatible + @J2ktIncompatible private static SimpleDateFormat createTimestampFormat() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH); GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); @@ -200,6 +203,7 @@ public static Timestamp checkValid(Timestamp.Builder timestampBuilder) { * @throws IllegalArgumentException if the given timestamp is not in the valid range. */ @GwtIncompatible("Depends on String.format which is not supported in Xplat.") + @J2ktIncompatible @J2ObjCIncompatible public static String toString(Timestamp timestamp) { checkValid(timestamp); @@ -231,6 +235,7 @@ public static String toString(Timestamp timestamp) { * @throws ParseException if parsing fails */ @GwtIncompatible("ParseException is not supported in Xplat") + @J2ktIncompatible @J2ObjCIncompatible public static Timestamp parse(String value) throws ParseException { int dayOffset = value.indexOf('T'); @@ -298,6 +303,7 @@ public static Timestamp parse(String value) throws ParseException { * @throws IllegalArgumentException if parsing fails */ @GwtIncompatible("Depends on String.format which is not supported in Xplat.") + @J2ktIncompatible @J2ObjCIncompatible public static Timestamp parseUnchecked(@CompileTimeConstant String value) { try { @@ -312,21 +318,25 @@ public static Timestamp parseUnchecked(@CompileTimeConstant String value) { // the following 3 constants contain references to java.time.Instant methods (if that class is // available at runtime); otherwise, they are null. @GwtIncompatible("Uses reflection to access methods of java.time.Instant") + @J2ktIncompatible @J2ObjCIncompatible @Nullable private static final Method INSTANT_NOW = instantMethod("now"); @GwtIncompatible("Uses reflection to access methods of java.time.Instant") + @J2ktIncompatible @J2ObjCIncompatible @Nullable private static final Method INSTANT_GET_EPOCH_SECOND = instantMethod("getEpochSecond"); @GwtIncompatible("Uses reflection to access methods of java.time.Instant") + @J2ktIncompatible @J2ObjCIncompatible @Nullable private static final Method INSTANT_GET_NANO = instantMethod("getNano"); @GwtIncompatible("Uses reflection to access methods of java.time.Instant") + @J2ktIncompatible @J2ObjCIncompatible @Nullable private static Method instantMethod(String methodName) { @@ -345,6 +355,7 @@ private static Method instantMethod(String methodName) { * instance to read the current time. */ @GwtIncompatible("Uses reflection to access methods of java.time.Instant") + @J2ktIncompatible @J2ObjCIncompatible @SuppressWarnings("nullness") public static Timestamp now() { @@ -515,6 +526,7 @@ static Timestamp normalizedTimestamp(long seconds, int nanos) { } @GwtIncompatible("Depends on String.format which is not supported in Xplat.") + @J2ktIncompatible @J2ObjCIncompatible private static long parseTimezoneOffset(String value) throws ParseException { int pos = value.indexOf(':'); @@ -533,6 +545,7 @@ private static long parseTimezoneOffset(String value) throws ParseException { } @GwtIncompatible("Depends on String.format which is not supported in Xplat.") + @J2ktIncompatible @J2ObjCIncompatible static int parseNanos(String value) throws ParseException { int result = 0; @@ -550,6 +563,7 @@ static int parseNanos(String value) throws ParseException { /** Format the nano part of a timestamp or a duration. */ @GwtIncompatible("Depends on String.format which is not supported in Xplat.") + @J2ktIncompatible @J2ObjCIncompatible static String formatNanos(int nanos) { // Determine whether to use 3, 6, or 9 digits for the nano part.