// Regression test for 22460222, the sub class. // The field gaps order was wrong. If there were two gaps of different sizes, // and the larger one was needed, it wouldn't be found.
class GapOrder extends GapOrderBase { // The base class is 9 bytes. The entire class should be packed as: // // 00: oooo oooo // 08: b-ss rrrr // 16: rrrr iiii // 24: dddd dddd // // The problem was, the packer wasn't finding the gap where iiii should go, // because the gap where ss goes was given priority. Instead it packed as: // 00: oooo oooo // 08: b--- rrrr // 16: rrrr ---- // 24: dddd dddd // 32: iiii ss public Object r1; public Object r2; publicdouble d; publicint i; publicshort s;
staticprivatevoid CheckField(String fieldName, int expected) {
Field field = null; try {
field = GapOrder.class.getField(fieldName);
} catch (ReflectiveOperationException e) {
System.out.println(fieldName + " not found in GapOrder."); return;
}
int actual = -1; try {
Method getOffset = Field.class.getMethod("getOffset");
actual = (Integer)getOffset.invoke(field);
} catch (ReflectiveOperationException e) {
System.out.println("Unable to get field offset for " + fieldName + ":" + e); return;
}
if (actual != expected) {
System.out.println(
String.format("GapOrder.%s has offset %d, but expected %d",
fieldName, actual, expected));
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.