55import org .javawebstack .abstractdata .mapper .exception .MapperWrongTypeException ;
66import org .javawebstack .abstractdata .util .Helpers ;
77
8+ import java .lang .reflect .Constructor ;
9+ import java .lang .reflect .InvocationTargetException ;
810import java .sql .Timestamp ;
911import java .text .NumberFormat ;
1012import java .text .ParseException ;
@@ -303,7 +305,9 @@ public Object fromAbstract(MapperContext context, AbstractElement element, Class
303305 throw new MapperException ("Unmappable type '" + type .getName () + "'" );
304306 AbstractObject o = element .object ();
305307 try {
306- Object obj = type .newInstance ();
308+ Constructor constructor = type .getDeclaredConstructor ();
309+ constructor .setAccessible (true );
310+ Object obj = constructor .newInstance ();
307311 AbstractObject additional = spec .getAdditionalField () == null ? null : new AbstractObject ();
308312 List <String > fieldNames = spec .getFieldSpecs ().stream ().map (s -> s .getField ().getName ()).collect (Collectors .toList ());
309313 for (String k : o .keys ()) {
@@ -330,7 +334,7 @@ public Object fromAbstract(MapperContext context, AbstractElement element, Class
330334 if (additional != null )
331335 spec .getAdditionalField ().set (obj , additional );
332336 return obj ;
333- } catch (InstantiationException | IllegalAccessException e ) {
337+ } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e ) {
334338 throw new MapperException (e .getMessage ());
335339 }
336340 }
0 commit comments