From fdfb67757f71b8bf51887c32e3c268c822fbff81 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Wed, 15 Mar 2023 14:47:16 +0100 Subject: [PATCH] Fix check Gson record support. May not work if Gson internal classes are not accessible. --- .../src/main/java/fr/pandacube/lib/core/json/Json.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/json/Json.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/json/Json.java index 2bcca68..37e62fc 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/json/Json.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/json/Json.java @@ -4,8 +4,8 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapterFactory; -import com.google.gson.internal.reflect.ReflectionHelper; import com.google.gson.reflect.TypeToken; +import fr.pandacube.lib.util.Log; import java.util.ArrayList; import java.util.List; @@ -92,8 +92,11 @@ public class Json { private static boolean hasGsonNativeRecordSupport() { try { - ReflectionHelper.class.getDeclaredField("RECORD_HELPER"); + com.google.gson.internal.reflect.ReflectionHelper.class.getDeclaredField("RECORD_HELPER"); return true; + } catch (NoClassDefFoundError e) { + Log.warning("Unable to check Gson supporting records. Assuming it does not. " + e); + return false; } catch (NoSuchFieldException e) { return false; }