4583 } catch (ArithmeticException e) {
4584 throw new java.io.StreamCorruptedException("BigInteger: Out of the supported range");
4585 }
4586 }
4587 }
4588
4589 // Support for resetting final fields while deserializing
4590 private static class UnsafeHolder {
4591 private static final jdk.internal.misc.Unsafe unsafe
4592 = jdk.internal.misc.Unsafe.getUnsafe();
4593 private static final long signumOffset
4594 = unsafe.objectFieldOffset(BigInteger.class, "signum");
4595 private static final long magOffset
4596 = unsafe.objectFieldOffset(BigInteger.class, "mag");
4597
4598 static void putSign(BigInteger bi, int sign) {
4599 unsafe.putInt(bi, signumOffset, sign);
4600 }
4601
4602 static void putMag(BigInteger bi, int[] magnitude) {
4603 unsafe.putObject(bi, magOffset, magnitude);
4604 }
4605 }
4606
4607 /**
4608 * Save the {@code BigInteger} instance to a stream. The magnitude of a
4609 * {@code BigInteger} is serialized as a byte array for historical reasons.
4610 * To maintain compatibility with older implementations, the integers
4611 * -1, -1, -2, and -2 are written as the values of the obsolete fields
4612 * {@code bitCount}, {@code bitLength}, {@code lowestSetBit}, and
4613 * {@code firstNonzeroByteNum}, respectively. These values are compatible
4614 * with older implementations, but will be ignored by current
4615 * implementations.
4616 */
4617 private void writeObject(ObjectOutputStream s) throws IOException {
4618 // set the values of the Serializable fields
4619 ObjectOutputStream.PutField fields = s.putFields();
4620 fields.put("signum", signum);
4621 fields.put("magnitude", magSerializedForm());
4622 // The values written for cached fields are compatible with older
4623 // versions, but are ignored in readObject so don't otherwise matter.
|
4583 } catch (ArithmeticException e) {
4584 throw new java.io.StreamCorruptedException("BigInteger: Out of the supported range");
4585 }
4586 }
4587 }
4588
4589 // Support for resetting final fields while deserializing
4590 private static class UnsafeHolder {
4591 private static final jdk.internal.misc.Unsafe unsafe
4592 = jdk.internal.misc.Unsafe.getUnsafe();
4593 private static final long signumOffset
4594 = unsafe.objectFieldOffset(BigInteger.class, "signum");
4595 private static final long magOffset
4596 = unsafe.objectFieldOffset(BigInteger.class, "mag");
4597
4598 static void putSign(BigInteger bi, int sign) {
4599 unsafe.putInt(bi, signumOffset, sign);
4600 }
4601
4602 static void putMag(BigInteger bi, int[] magnitude) {
4603 unsafe.putReference(bi, magOffset, magnitude);
4604 }
4605 }
4606
4607 /**
4608 * Save the {@code BigInteger} instance to a stream. The magnitude of a
4609 * {@code BigInteger} is serialized as a byte array for historical reasons.
4610 * To maintain compatibility with older implementations, the integers
4611 * -1, -1, -2, and -2 are written as the values of the obsolete fields
4612 * {@code bitCount}, {@code bitLength}, {@code lowestSetBit}, and
4613 * {@code firstNonzeroByteNum}, respectively. These values are compatible
4614 * with older implementations, but will be ignored by current
4615 * implementations.
4616 */
4617 private void writeObject(ObjectOutputStream s) throws IOException {
4618 // set the values of the Serializable fields
4619 ObjectOutputStream.PutField fields = s.putFields();
4620 fields.put("signum", signum);
4621 fields.put("magnitude", magSerializedForm());
4622 // The values written for cached fields are compatible with older
4623 // versions, but are ignored in readObject so don't otherwise matter.
|