From cde8922d6eb8b0507f5cd77ce19252f09f5e302f Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 29 Oct 2024 20:37:47 +0300 Subject: [PATCH] Use JsonIOException for unchecked exceptions instead of RuntimeException in ConstructorConstructor --- .../com/google/gson/internal/ConstructorConstructor.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java b/gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java index 7a7dc70b8d..83f26e8f3d 100644 --- a/gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java +++ b/gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java @@ -270,15 +270,13 @@ private static ObjectConstructor newDefaultConstructor( // Note: InstantiationException should be impossible because check at start of method made // sure that class is not abstract catch (InstantiationException e) { - throw new RuntimeException( + throw new JsonIOException( "Failed to invoke constructor '" + ReflectionHelper.constructorToString(constructor) + "' with no args", e); } catch (InvocationTargetException e) { - // TODO: don't wrap if cause is unchecked? - // TODO: JsonParseException ? - throw new RuntimeException( + throw new JsonIOException( "Failed to invoke constructor '" + ReflectionHelper.constructorToString(constructor) + "' with no args",