Skip to content

Commit

Permalink
Mark Files.createTempDir and FileBackedOutputStream as `@J2ObjCIn…
Browse files Browse the repository at this point in the history
…compatible`.

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
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed May 19, 2023
1 parent 3a8d7e4 commit 56dc928
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,6 +55,7 @@
@Beta
@J2ktIncompatible
@GwtIncompatible
@J2ObjCIncompatible
@ElementTypesAreNonnullByDefault
public final class FileBackedOutputStream extends OutputStream {
private final int fileThreshold;
Expand Down
2 changes: 2 additions & 0 deletions android/guava/src/com/google/common/io/Files.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions guava/src/com/google/common/io/FileBackedOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,6 +55,7 @@
@Beta
@J2ktIncompatible
@GwtIncompatible
@J2ObjCIncompatible
@ElementTypesAreNonnullByDefault
public final class FileBackedOutputStream extends OutputStream {
private final int fileThreshold;
Expand Down
2 changes: 2 additions & 0 deletions guava/src/com/google/common/io/Files.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 56dc928

Please sign in to comment.