Details
-
Enhancement
-
Resolution: Fixed
-
P4
-
6u14
-
b06
-
generic
-
generic
-
Not verified
Description
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.
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.
Attachments
Issue Links
- relates to
-
JDK-7082971 More performance tuning of BigDecimal and other java.math classes
- Closed
-
JDK-6622432 RFE: Performance improvements to java.math.BigDecimal
- Resolved