From 56dc928a2558d50d426ce500307abcaa4a557d8c Mon Sep 17 00:00:00 2001 From: cpovirk Date: Fri, 19 May 2023 15:20:39 -0700 Subject: [PATCH] Mark `Files.createTempDir` and `FileBackedOutputStream` as `@J2ObjCIncompatible`. While we believe they're secure under iOS (thanks to OS-level protections on the temporary directory), we are looking into reimplementing them atop `java.nio.file` to improve security under other platforms. And if we do so, then we need to add `java.nio.file` to the JRE deps of every J2ObjC user, possibly increasing app size (at least until improvements to J2ObjC land). After discussion with the J2ObjC team, we've settled on hiding the APIs from J2ObjC for now. Inside Google, the APIs already had no J2ObjC users. If you use them outside Google, let us know, and we can make them available there. RELNOTES=`io`: Marked `Files.createTempDir` and `FileBackedOutputStream` as `@J2ObjCIncompatible`. Contact us if you need to use them under J2ObjC. PiperOrigin-RevId: 533564397 --- .../guava/src/com/google/common/io/FileBackedOutputStream.java | 2 ++ android/guava/src/com/google/common/io/Files.java | 2 ++ guava/src/com/google/common/io/FileBackedOutputStream.java | 2 ++ guava/src/com/google/common/io/Files.java | 2 ++ 4 files changed, 8 insertions(+) diff --git a/android/guava/src/com/google/common/io/FileBackedOutputStream.java b/android/guava/src/com/google/common/io/FileBackedOutputStream.java index dc89ba772835..d1b2a436013b 100644 --- a/android/guava/src/com/google/common/io/FileBackedOutputStream.java +++ b/android/guava/src/com/google/common/io/FileBackedOutputStream.java @@ -21,6 +21,7 @@ import com.google.common.annotations.J2ktIncompatible; import com.google.common.annotations.VisibleForTesting; import com.google.errorprone.annotations.concurrent.GuardedBy; +import com.google.j2objc.annotations.J2ObjCIncompatible; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -54,6 +55,7 @@ @Beta @J2ktIncompatible @GwtIncompatible +@J2ObjCIncompatible @ElementTypesAreNonnullByDefault public final class FileBackedOutputStream extends OutputStream { private final int fileThreshold; diff --git a/android/guava/src/com/google/common/io/Files.java b/android/guava/src/com/google/common/io/Files.java index 6612648bcb35..498faf97ed41 100644 --- a/android/guava/src/com/google/common/io/Files.java +++ b/android/guava/src/com/google/common/io/Files.java @@ -34,6 +34,7 @@ import com.google.common.hash.HashFunction; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.InlineMe; +import com.google.j2objc.annotations.J2ObjCIncompatible; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -426,6 +427,7 @@ public static boolean equal(File file1, File file2) throws IOException { */ @Beta @Deprecated + @J2ObjCIncompatible public static File createTempDir() { File baseDir = new File(System.getProperty("java.io.tmpdir")); @SuppressWarnings("GoodTime") // reading system time without TimeSource diff --git a/guava/src/com/google/common/io/FileBackedOutputStream.java b/guava/src/com/google/common/io/FileBackedOutputStream.java index dc89ba772835..d1b2a436013b 100644 --- a/guava/src/com/google/common/io/FileBackedOutputStream.java +++ b/guava/src/com/google/common/io/FileBackedOutputStream.java @@ -21,6 +21,7 @@ import com.google.common.annotations.J2ktIncompatible; import com.google.common.annotations.VisibleForTesting; import com.google.errorprone.annotations.concurrent.GuardedBy; +import com.google.j2objc.annotations.J2ObjCIncompatible; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -54,6 +55,7 @@ @Beta @J2ktIncompatible @GwtIncompatible +@J2ObjCIncompatible @ElementTypesAreNonnullByDefault public final class FileBackedOutputStream extends OutputStream { private final int fileThreshold; diff --git a/guava/src/com/google/common/io/Files.java b/guava/src/com/google/common/io/Files.java index 6612648bcb35..498faf97ed41 100644 --- a/guava/src/com/google/common/io/Files.java +++ b/guava/src/com/google/common/io/Files.java @@ -34,6 +34,7 @@ import com.google.common.hash.HashFunction; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.InlineMe; +import com.google.j2objc.annotations.J2ObjCIncompatible; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -426,6 +427,7 @@ public static boolean equal(File file1, File file2) throws IOException { */ @Beta @Deprecated + @J2ObjCIncompatible public static File createTempDir() { File baseDir = new File(System.getProperty("java.io.tmpdir")); @SuppressWarnings("GoodTime") // reading system time without TimeSource