From cdbb9992dcbb756f7dff1537319428e1d0a4118e Mon Sep 17 00:00:00 2001 From: Steven Toribio <34755817+turbotoribio@users.noreply.github.com> Date: Thu, 16 Nov 2023 10:22:29 -0800 Subject: [PATCH] wow (#8158) --- java/src/main/java/com/google/flatbuffers/Utf8Old.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/java/src/main/java/com/google/flatbuffers/Utf8Old.java b/java/src/main/java/com/google/flatbuffers/Utf8Old.java index 3dac714bb67..c568105a01c 100644 --- a/java/src/main/java/com/google/flatbuffers/Utf8Old.java +++ b/java/src/main/java/com/google/flatbuffers/Utf8Old.java @@ -42,8 +42,15 @@ private static class Cache { } } + // ThreadLocal.withInitial() is not used to make the following code compatible with Android API + // level 23. private static final ThreadLocal CACHE = - ThreadLocal.withInitial(() -> new Cache()); + new ThreadLocal() { + @Override + protected Cache initialValue() { + return new Cache(); + } + }; // Play some games so that the old encoder doesn't pay twice for computing // the length of the encoded string.