Base64 — 138 lineLength = lineLength >> 2 << 2;
I know the code was shuffled up but i find the following clearer in terms of bit manipulation: // Round down to nearest mulitple of 4 lineLength &= ~0b11 TestBase64 — Is there a test passing in a negative value for len? Thanks, Paul. > On Jan 26, 2018, at 3:32 PM, Xueming Shen <xueming.s...@oracle.com> wrote: > > Hi, > > Please help review the change for JDK-8176379 > > issue: https://bugs.openjdk.java.net/browse/JDK-8176379 > webrev: http://cr.openjdk.java.net/~sherman/8176379/webrev > > It appears the spec is somewhat misleading and/or incorrect in this corner > case. And the implementation of the mime type encoder OutputStream does > not expect a "length==0" mime encoder. The difference behavior of the > non-stream-type encoder and stream-type encoder comes from > > in non-stream-type case, we always have a " > 0" guard as > > if (linemax > 0 && slen > linemax / 4 * 3) > slen = linemax / 4 * 3 > > but in stream-type we don't. > > private void checkNewline() throws IOException { > if (linepos == linemax) { > out.write(newline); > linepos = 0; > } > } > > The proposed change here is to clarify the spec and the implementation > to use a non-mime type encoder (no line separator) when the rounded down > mime line length is smaller than 4. > > We probably need a CSR for this spec clarification, if the proposed change is > approved. > > Thanks, > Sherman