if (findHash(realClass, false).longValue() != hash)
throw throwNewUnusableEntryException(
new IncompatibleClassChangeError(realClass + " changed"));
Entry entryObj = (Entry) realClass.newInstance();
Field[] fields = getFields(realClass);
/*
* Loop through the fields, ensuring no primitives and
* checking for wildcards.
*/
int nvals = 0; // index into this.values[]
for (int i = 0; i < fields.length; i++) {
Throwable nested = null;
try {
if (!usableField(fields[i]))
continue;
final MarshalledInstance val = values[nvals++];
Object value = (val == null ? null : val.get(integrity));
fields[i].set(entryObj, value);
} catch (Throwable e) {
nested = e;
}
if (nested != null) { // some problem occurred
if (badFields == null) {
badFields = new ArrayList(fields.length);
except = new ArrayList(fields.length);
}
badFields.add(fields[i].getName());
except.add(nested);
}
}
/* See if any fields have vanished from the class,
* because of the hashing this should never happen but
* throwing an exception that provides more info
* (instead of AssertionError) seems harmless.
*/
if (nvals < values.length) {
throw throwNewUnusableEntryException(
entryObj, // should this be null?
null, // array of bad-field names
new Throwable[] { // array of exceptions
new IncompatibleClassChangeError(
"A usable field has been removed from " +
entryObj.getClass().getName() +
" since this EntryRep was created")
});
}
// if there were any bad fields, throw the exception