Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6838776

Defer initialization of static fields in java.math.BigInteger

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 6u14
    • core-libs
    • b06
    • generic
    • generic
    • Not verified

      The fix for 6622432: RFE: Performance improvements to java.math.BigDecimal in 6u14 adds two new static fields that are only needed for deserialization. Better to initialize them lazily when needed.

          private static final sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe();
          private static final long signumOffset;
          private static final long magOffset;
          static {
              try {
                  signumOffset = unsafe.objectFieldOffset
                      (BigInteger.class.getDeclaredField("signum"));
                  magOffset = unsafe.objectFieldOffset
                      (BigInteger.class.getDeclaredField("mag"));
              } catch (Exception ex) {
                  throw new Error(ex);
              }
          }


      zeros is another static field used by the toString() method and it can also be lazily initialized.

            darcy Joe Darcy
            mchung Mandy Chung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: