|
2 | 2 |
|
3 | 3 | import java.lang.reflect.Array; |
4 | 4 | import java.lang.reflect.Field; |
5 | | - |
| 5 | +import java.lang.reflect.InvocationTargetException; |
6 | 6 | import java.sql.Connection; |
7 | 7 | import java.sql.SQLException; |
8 | 8 | import java.sql.Timestamp; |
@@ -265,9 +265,7 @@ public int compare(final Field a, final Field b) { |
265 | 265 | for (final Field f : fields) { |
266 | 266 | final DatabaseFieldDescriptor databaseFieldDescriptor = getDatabaseFieldDescriptor(f); |
267 | 267 | if (databaseFieldDescriptor != null) { |
268 | | - if (!f.isAccessible()) { |
269 | | - f.setAccessible(true); |
270 | | - } |
| 268 | + f.trySetAccessible(); |
271 | 269 |
|
272 | 270 | Object value; |
273 | 271 | try { |
@@ -417,28 +415,44 @@ private static Object applyTransformer(final Field f, final DatabaseFieldDescrip |
417 | 415 | try { |
418 | 416 | @SuppressWarnings("unchecked") |
419 | 417 | final ValueTransformer<Object, Object> transformer = (ValueTransformer<Object, Object>) |
420 | | - databaseFieldDescriptor.getTransformer().newInstance(); |
| 418 | + databaseFieldDescriptor.getTransformer().getDeclaredConstructor().newInstance(); |
421 | 419 |
|
422 | 420 | // transform the value by the transformer into a database value: |
423 | 421 | value = transformer.marshalToDb(value); |
424 | 422 | } catch (final InstantiationException e) { |
425 | 423 | throw new IllegalArgumentException("Could not instantiate transformer of field " + f.getName(), e); |
426 | 424 | } catch (final IllegalAccessException e) { |
427 | 425 | throw new IllegalArgumentException("Could not instantiate transformer of field " + f.getName(), e); |
| 426 | + } catch (final InvocationTargetException e) { |
| 427 | + throw new IllegalArgumentException("Could not instantiate transformer of field " + f.getName(), e); |
| 428 | + } catch (IllegalArgumentException e) { |
| 429 | + throw new IllegalArgumentException("Could not instantiate transformer of field " + f.getName(), e); |
| 430 | + } catch (NoSuchMethodException e) { |
| 431 | + throw new IllegalArgumentException("Could not instantiate transformer of field " + f.getName(), e); |
| 432 | + } catch (SecurityException e) { |
| 433 | + throw new IllegalArgumentException("Could not instantiate transformer of field " + f.getName(), e); |
428 | 434 | } |
429 | 435 | } |
430 | 436 |
|
431 | 437 | Class<? extends ObjectMapper<?>> mapperClass = databaseFieldDescriptor.getMapper(); |
432 | 438 | if (mapperClass != null && mapperClass != DefaultObjectMapper.class) { |
433 | 439 | try { |
434 | 440 | @SuppressWarnings("unchecked") |
435 | | - ObjectMapper<Object> mapper = (ObjectMapper<Object>) mapperClass.newInstance(); |
| 441 | + ObjectMapper<Object> mapper = (ObjectMapper<Object>) mapperClass.getDeclaredConstructor().newInstance(); |
436 | 442 |
|
437 | 443 | value = mapper.marshalToDb(value); |
438 | 444 | } catch (InstantiationException e) { |
439 | 445 | throw new IllegalArgumentException("Could not instantiate mapper of field " + f.getName(), e); |
440 | 446 | } catch (IllegalAccessException e) { |
441 | 447 | throw new IllegalArgumentException("Could not instantiate mapper of field " + f.getName(), e); |
| 448 | + } catch (IllegalArgumentException e) { |
| 449 | + throw new IllegalArgumentException("Could not instantiate mapper of field " + f.getName(), e); |
| 450 | + } catch (InvocationTargetException e) { |
| 451 | + throw new IllegalArgumentException("Could not instantiate mapper of field " + f.getName(), e); |
| 452 | + } catch (NoSuchMethodException e) { |
| 453 | + throw new IllegalArgumentException("Could not instantiate mapper of field " + f.getName(), e); |
| 454 | + } catch (SecurityException e) { |
| 455 | + throw new IllegalArgumentException("Could not instantiate mapper of field " + f.getName(), e); |
442 | 456 | } |
443 | 457 | } |
444 | 458 |
|
|
0 commit comments