(Field field, Class<?> type)
| 1495 | } |
| 1496 | |
| 1497 | private Object initializeField(Field field, Class<?> type) { |
| 1498 | Object value = null; |
| 1499 | if (Structure.class.isAssignableFrom(type) |
| 1500 | && !(ByReference.class.isAssignableFrom(type))) { |
| 1501 | try { |
| 1502 | value = newInstance((Class<? extends Structure>) type, PLACEHOLDER_MEMORY); |
| 1503 | setFieldValue(field, value); |
| 1504 | } |
| 1505 | catch(IllegalArgumentException e) { |
| 1506 | String msg = "Can't determine size of nested structure"; |
| 1507 | throw new IllegalArgumentException(msg, e); |
| 1508 | } |
| 1509 | } |
| 1510 | else if (NativeMapped.class.isAssignableFrom(type)) { |
| 1511 | NativeMappedConverter tc = NativeMappedConverter.getInstance(type); |
| 1512 | value = tc.defaultValue(); |
| 1513 | setFieldValue(field, value); |
| 1514 | } |
| 1515 | return value; |
| 1516 | } |
| 1517 | |
| 1518 | private int addPadding(int calculatedSize) { |
| 1519 | return addPadding(calculatedSize, structAlignment); |
no test coverage detected