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 eee80b8..2bcca68 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 @@ -1,16 +1,16 @@ package fr.pandacube.lib.core.json; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Function; - 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.bind.ReflectiveTypeAdapterFactory; +import com.google.gson.internal.reflect.ReflectionHelper; import com.google.gson.reflect.TypeToken; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; + /** * Provides pre-instanciated {@link Gson} instances, all with support for Java records and additionnal * {@link TypeAdapterFactory} provided with {@link #registerTypeAdapterFactory(TypeAdapterFactory)}. @@ -91,11 +91,12 @@ public class Json { private static boolean hasGsonNativeRecordSupport() { - for (Class innerClasses : ReflectiveTypeAdapterFactory.class.getDeclaredClasses()) { - if (innerClasses.getSimpleName().equals("RecordAdapter")) - return true; + try { + ReflectionHelper.class.getDeclaredField("RECORD_HELPER"); + return true; + } catch (NoSuchFieldException e) { + return false; } - return false; }