in src/com/amazon/ion/impl/IonBinary.java [1166:1213]
public long readIntAsLong(int len) throws IOException {
long retvalue = 0;
boolean is_negative = false;
int b;
if (len > 0) {
// read the first byte
if ((b = read()) < 0) throwUnexpectedEOFException();
retvalue = (b & 0x7F);
is_negative = ((b & 0x80) != 0);
switch (len - 1) { // we read 1 already
case 8: // even after reading the 1st byte we may have 8 remaining
// bytes of value when the value is Long.MIN_VALUE since it
// has all 8 bytes for data and the ninth for the sign bit
// all by itself (which we read above)
if ((b = read()) < 0) throwUnexpectedEOFException();
retvalue = (retvalue << 8) | b;
case 7:
if ((b = read()) < 0) throwUnexpectedEOFException();
retvalue = (retvalue << 8) | b;
case 6:
if ((b = read()) < 0) throwUnexpectedEOFException();
retvalue = (retvalue << 8) | b;
case 5:
if ((b = read()) < 0) throwUnexpectedEOFException();
retvalue = (retvalue << 8) | b;
case 4:
if ((b = read()) < 0) throwUnexpectedEOFException();
retvalue = (retvalue << 8) | b;
case 3:
if ((b = read()) < 0) throwUnexpectedEOFException();
retvalue = (retvalue << 8) | b;
case 2:
if ((b = read()) < 0) throwUnexpectedEOFException();
retvalue = (retvalue << 8) | b;
case 1:
if ((b = read()) < 0) throwUnexpectedEOFException();
retvalue = (retvalue << 8) | b;
default:
}
if (is_negative) {
// this is correct even when retvalue == Long.MIN_VALUE
retvalue = -retvalue;
}
}
return retvalue;
}