On Feb 25, 2014, at 9:36 PM, Brian Burkhalter <brian.burkhal...@oracle.com> wrote:
> > On Feb 25, 2014, at 4:26 AM, Paul Sandoz wrote: > >> Might as well just remove the @Deprecated stuff. I think it is fine under >> the circumstances to have offsets and getter methods that return the correct >> values. > > I have posted a new webrev taking this approach: > > http://cr.openjdk.java.net/~bpb/8035279/webrev.01/ > > A review would be appreciated. > It might be worth refining the comments, replacing: 145 // These "redundant fields" are initialized with recognizable nonsense 146 // values, and cached the first time they are needed (or never, if they 147 // aren't needed). with: // The following fields are stable variables. A stable variable's value changes // at most once from the default zero value to a non-zero stable value. // A stable value is calculated lazily on demand. // /** * One plus the bitCount of this BigInteger. This is a stable variable. ... /** * One plus the bitLength of this BigInteger. This is a stable variable. ... /** * Two plus the lowest set bit of this BigInteger. This is a stable variable. Also, is @serial is relevant any more? Plus to be pedantic for firstNonzeroIntNumPlusTwo with zero magnitudes: /** * Two plus the index of the lowest-order int in the magnitude of this * BigInteger that contains a nonzero int. This is a stable variable. * The least significant int has int-number 0, the next int in order of * increasing significance has int-number 1, and so forth. * * <p>Note: never used for a BigInteger with a magnitude of zero. * @see #firstNonzeroIntNum() /** * Returns the index of the int that contains the first nonzero int in the * little-endian binary representation of the magnitude (int 0 is the * least significant). If the magnitude is zero, return value is undefined. * * <p>Note: never used for a BigInteger with a magnitude of zero. * @see #getInt. */ private int firstNonzeroIntNum() { int fn = firstNonzeroIntNumPlusTwo - 2; if (fn == -3) { // firstNonzeroIntNum not initialized yet // Search for the first nonzero int int i; int mlen = mag.length; for (i = mlen - 1; i >= 0 && mag[i] == 0; i--) ; fn = mlen - i - 1; firstNonzeroIntNumPlusTwo = fn + 2; // offset by two to initialize } return fn; } An unnecessary assignment is removed from the above method. -- We can revisit and clean things up if/when the JMM is updated. Paul.