Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/util/Base64/TestBase64.java
38812 views
1
/*
2
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/**
25
* @test 4235519 8004212 8005394 8007298 8006295 8006315 8006530 8007379 8008925
26
* 8014217 8025003 8026330 8028397 8165243
27
* @summary tests java.util.Base64
28
* @key randomness
29
* @library /lib/testlibrary
30
* @build jdk.testlibrary.*
31
* @run main TestBase64
32
*/
33
34
import java.io.ByteArrayInputStream;
35
import java.io.ByteArrayOutputStream;
36
import java.io.InputStream;
37
import java.io.IOException;
38
import java.io.OutputStream;
39
import java.nio.ByteBuffer;
40
import java.util.Arrays;
41
import java.util.ArrayList;
42
import java.util.Base64;
43
import java.util.List;
44
import java.util.Random;
45
46
import jdk.testlibrary.RandomFactory;
47
48
public class TestBase64 {
49
50
private static final Random rnd = RandomFactory.getRandom();
51
52
public static void main(String args[]) throws Throwable {
53
int numRuns = 10;
54
int numBytes = 200;
55
if (args.length > 1) {
56
numRuns = Integer.parseInt(args[0]);
57
numBytes = Integer.parseInt(args[1]);
58
}
59
60
test(Base64.getEncoder(), Base64.getDecoder(), numRuns, numBytes);
61
test(Base64.getUrlEncoder(), Base64.getUrlDecoder(), numRuns, numBytes);
62
test(Base64.getMimeEncoder(), Base64.getMimeDecoder(), numRuns, numBytes);
63
64
byte[] nl_1 = new byte[] {'\n'};
65
byte[] nl_2 = new byte[] {'\n', '\r'};
66
byte[] nl_3 = new byte[] {'\n', '\r', '\n'};
67
for (int i = 0; i < 10; i++) {
68
int len = rnd.nextInt(200) + 4;
69
test(Base64.getMimeEncoder(len, nl_1),
70
Base64.getMimeDecoder(),
71
numRuns, numBytes);
72
test(Base64.getMimeEncoder(len, nl_2),
73
Base64.getMimeDecoder(),
74
numRuns, numBytes);
75
test(Base64.getMimeEncoder(len, nl_3),
76
Base64.getMimeDecoder(),
77
numRuns, numBytes);
78
}
79
80
testNull(Base64.getEncoder());
81
testNull(Base64.getUrlEncoder());
82
testNull(Base64.getMimeEncoder());
83
testNull(Base64.getMimeEncoder(10, new byte[]{'\n'}));
84
testNull(Base64.getDecoder());
85
testNull(Base64.getUrlDecoder());
86
testNull(Base64.getMimeDecoder());
87
checkNull(() -> Base64.getMimeEncoder(10, null));
88
89
testIOE(Base64.getEncoder());
90
testIOE(Base64.getUrlEncoder());
91
testIOE(Base64.getMimeEncoder());
92
testIOE(Base64.getMimeEncoder(10, new byte[]{'\n'}));
93
94
byte[] src = new byte[1024];
95
rnd.nextBytes(src);
96
final byte[] decoded = Base64.getEncoder().encode(src);
97
testIOE(Base64.getDecoder(), decoded);
98
testIOE(Base64.getMimeDecoder(), decoded);
99
testIOE(Base64.getUrlDecoder(), Base64.getUrlEncoder().encode(src));
100
101
// illegal line separator
102
checkIAE(() -> Base64.getMimeEncoder(10, new byte[]{'\r', 'N'}));
103
104
// malformed padding/ending
105
testMalformedPadding();
106
107
// illegal base64 character
108
decoded[2] = (byte)0xe0;
109
checkIAE(() -> Base64.getDecoder().decode(decoded));
110
checkIAE(() -> Base64.getDecoder().decode(decoded, new byte[1024]));
111
checkIAE(() -> Base64.getDecoder().decode(ByteBuffer.wrap(decoded)));
112
113
// test single-non-base64 character for mime decoding
114
testSingleNonBase64MimeDec();
115
116
// test decoding of unpadded data
117
testDecodeUnpadded();
118
119
// test mime decoding with ignored character after padding
120
testDecodeIgnoredAfterPadding();
121
122
// given invalid args, encoder should not produce output
123
testEncoderKeepsSilence(Base64.getEncoder());
124
testEncoderKeepsSilence(Base64.getUrlEncoder());
125
testEncoderKeepsSilence(Base64.getMimeEncoder());
126
127
// given invalid args, decoder should not consume input
128
testDecoderKeepsAbstinence(Base64.getDecoder());
129
testDecoderKeepsAbstinence(Base64.getUrlDecoder());
130
testDecoderKeepsAbstinence(Base64.getMimeDecoder());
131
}
132
133
private static sun.misc.BASE64Encoder sunmisc = new sun.misc.BASE64Encoder();
134
135
private static void test(Base64.Encoder enc, Base64.Decoder dec,
136
int numRuns, int numBytes) throws Throwable {
137
Random rnd = new java.util.Random();
138
139
enc.encode(new byte[0]);
140
dec.decode(new byte[0]);
141
142
for (boolean withoutPadding : new boolean[] { false, true}) {
143
if (withoutPadding) {
144
enc = enc.withoutPadding();
145
}
146
for (int i=0; i<numRuns; i++) {
147
for (int j=1; j<numBytes; j++) {
148
byte[] orig = new byte[j];
149
rnd.nextBytes(orig);
150
151
// --------testing encode/decode(byte[])--------
152
byte[] encoded = enc.encode(orig);
153
byte[] decoded = dec.decode(encoded);
154
155
checkEqual(orig, decoded,
156
"Base64 array encoding/decoding failed!");
157
if (withoutPadding) {
158
if (encoded[encoded.length - 1] == '=')
159
throw new RuntimeException(
160
"Base64 enc.encode().withoutPadding() has padding!");
161
}
162
// compare to sun.misc.BASE64Encoder
163
164
byte[] encoded2 = sunmisc.encode(orig).getBytes("ASCII");
165
if (!withoutPadding) { // don't test for withoutPadding()
166
checkEqual(normalize(encoded), normalize(encoded2),
167
"Base64 enc.encode() does not match sun.misc.base64!");
168
}
169
// remove padding '=' to test non-padding decoding case
170
if (encoded[encoded.length -2] == '=')
171
encoded2 = Arrays.copyOf(encoded, encoded.length -2);
172
else if (encoded[encoded.length -1] == '=')
173
encoded2 = Arrays.copyOf(encoded, encoded.length -1);
174
else
175
encoded2 = null;
176
177
// --------testing encodetoString(byte[])/decode(String)--------
178
String str = enc.encodeToString(orig);
179
if (!Arrays.equals(str.getBytes("ASCII"), encoded)) {
180
throw new RuntimeException(
181
"Base64 encodingToString() failed!");
182
}
183
byte[] buf = dec.decode(new String(encoded, "ASCII"));
184
checkEqual(buf, orig, "Base64 decoding(String) failed!");
185
186
if (encoded2 != null) {
187
buf = dec.decode(new String(encoded2, "ASCII"));
188
checkEqual(buf, orig, "Base64 decoding(String) failed!");
189
}
190
191
//-------- testing encode/decode(Buffer)--------
192
testEncode(enc, ByteBuffer.wrap(orig), encoded);
193
ByteBuffer bin = ByteBuffer.allocateDirect(orig.length);
194
bin.put(orig).flip();
195
testEncode(enc, bin, encoded);
196
197
testDecode(dec, ByteBuffer.wrap(encoded), orig);
198
bin = ByteBuffer.allocateDirect(encoded.length);
199
bin.put(encoded).flip();
200
testDecode(dec, bin, orig);
201
202
if (encoded2 != null)
203
testDecode(dec, ByteBuffer.wrap(encoded2), orig);
204
205
// --------testing decode.wrap(input stream)--------
206
// 1) random buf length
207
ByteArrayInputStream bais = new ByteArrayInputStream(encoded);
208
InputStream is = dec.wrap(bais);
209
buf = new byte[orig.length + 10];
210
int len = orig.length;
211
int off = 0;
212
while (true) {
213
int n = rnd.nextInt(len);
214
if (n == 0)
215
n = 1;
216
n = is.read(buf, off, n);
217
if (n == -1) {
218
checkEqual(off, orig.length,
219
"Base64 stream decoding failed");
220
break;
221
}
222
off += n;
223
len -= n;
224
if (len == 0)
225
break;
226
}
227
buf = Arrays.copyOf(buf, off);
228
checkEqual(buf, orig, "Base64 stream decoding failed!");
229
230
// 2) read one byte each
231
bais.reset();
232
is = dec.wrap(bais);
233
buf = new byte[orig.length + 10];
234
off = 0;
235
int b;
236
while ((b = is.read()) != -1) {
237
buf[off++] = (byte)b;
238
}
239
buf = Arrays.copyOf(buf, off);
240
checkEqual(buf, orig, "Base64 stream decoding failed!");
241
242
// --------testing encode.wrap(output stream)--------
243
ByteArrayOutputStream baos = new ByteArrayOutputStream((orig.length + 2) / 3 * 4 + 10);
244
OutputStream os = enc.wrap(baos);
245
off = 0;
246
len = orig.length;
247
for (int k = 0; k < 5; k++) {
248
if (len == 0)
249
break;
250
int n = rnd.nextInt(len);
251
if (n == 0)
252
n = 1;
253
os.write(orig, off, n);
254
off += n;
255
len -= n;
256
}
257
if (len != 0)
258
os.write(orig, off, len);
259
os.close();
260
buf = baos.toByteArray();
261
checkEqual(buf, encoded, "Base64 stream encoding failed!");
262
263
// 2) write one byte each
264
baos.reset();
265
os = enc.wrap(baos);
266
off = 0;
267
while (off < orig.length) {
268
os.write(orig[off++]);
269
}
270
os.close();
271
buf = baos.toByteArray();
272
checkEqual(buf, encoded, "Base64 stream encoding failed!");
273
274
// --------testing encode(in, out); -> bigger buf--------
275
buf = new byte[encoded.length + rnd.nextInt(100)];
276
int ret = enc.encode(orig, buf);
277
checkEqual(ret, encoded.length,
278
"Base64 enc.encode(src, null) returns wrong size!");
279
buf = Arrays.copyOf(buf, ret);
280
checkEqual(buf, encoded,
281
"Base64 enc.encode(src, dst) failed!");
282
283
// --------testing decode(in, out); -> bigger buf--------
284
buf = new byte[orig.length + rnd.nextInt(100)];
285
ret = dec.decode(encoded, buf);
286
checkEqual(ret, orig.length,
287
"Base64 enc.encode(src, null) returns wrong size!");
288
buf = Arrays.copyOf(buf, ret);
289
checkEqual(buf, orig,
290
"Base64 dec.decode(src, dst) failed!");
291
292
}
293
}
294
}
295
}
296
297
private static final byte[] ba_null = null;
298
private static final String str_null = null;
299
private static final ByteBuffer bb_null = null;
300
301
private static void testNull(Base64.Encoder enc) {
302
checkNull(() -> enc.encode(ba_null));
303
checkNull(() -> enc.encodeToString(ba_null));
304
checkNull(() -> enc.encode(ba_null, new byte[10]));
305
checkNull(() -> enc.encode(new byte[10], ba_null));
306
checkNull(() -> enc.encode(bb_null));
307
checkNull(() -> enc.wrap((OutputStream)null));
308
}
309
310
private static void testNull(Base64.Decoder dec) {
311
checkNull(() -> dec.decode(ba_null));
312
checkNull(() -> dec.decode(str_null));
313
checkNull(() -> dec.decode(ba_null, new byte[10]));
314
checkNull(() -> dec.decode(new byte[10], ba_null));
315
checkNull(() -> dec.decode(bb_null));
316
checkNull(() -> dec.wrap((InputStream)null));
317
}
318
319
@FunctionalInterface
320
private static interface Testable {
321
public void test() throws Throwable;
322
}
323
324
private static void testIOE(Base64.Encoder enc) throws Throwable {
325
ByteArrayOutputStream baos = new ByteArrayOutputStream(8192);
326
OutputStream os = enc.wrap(baos);
327
os.write(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9});
328
os.close();
329
checkIOE(() -> os.write(10));
330
checkIOE(() -> os.write(new byte[] {10}));
331
checkIOE(() -> os.write(new byte[] {10}, 1, 4));
332
}
333
334
private static void testIOE(Base64.Decoder dec, byte[] decoded) throws Throwable {
335
ByteArrayInputStream bais = new ByteArrayInputStream(decoded);
336
InputStream is = dec.wrap(bais);
337
is.read(new byte[10]);
338
is.close();
339
checkIOE(() -> is.read());
340
checkIOE(() -> is.read(new byte[] {10}));
341
checkIOE(() -> is.read(new byte[] {10}, 1, 4));
342
checkIOE(() -> is.available());
343
checkIOE(() -> is.skip(20));
344
}
345
346
private static final void checkNull(Runnable r) {
347
try {
348
r.run();
349
throw new RuntimeException("NPE is not thrown as expected");
350
} catch (NullPointerException npe) {}
351
}
352
353
private static final void checkIOE(Testable t) throws Throwable {
354
try {
355
t.test();
356
throw new RuntimeException("IOE is not thrown as expected");
357
} catch (IOException ioe) {}
358
}
359
360
private static final void checkIAE(Runnable r) throws Throwable {
361
try {
362
r.run();
363
throw new RuntimeException("IAE is not thrown as expected");
364
} catch (IllegalArgumentException iae) {}
365
}
366
367
private static void testDecodeIgnoredAfterPadding() throws Throwable {
368
for (byte nonBase64 : new byte[] {'#', '(', '!', '\\', '-', '_', '\n', '\r'}) {
369
byte[][] src = new byte[][] {
370
"A".getBytes("ascii"),
371
"AB".getBytes("ascii"),
372
"ABC".getBytes("ascii"),
373
"ABCD".getBytes("ascii"),
374
"ABCDE".getBytes("ascii")
375
};
376
Base64.Encoder encM = Base64.getMimeEncoder();
377
Base64.Decoder decM = Base64.getMimeDecoder();
378
Base64.Encoder enc = Base64.getEncoder();
379
Base64.Decoder dec = Base64.getDecoder();
380
for (int i = 0; i < src.length; i++) {
381
// decode(byte[])
382
byte[] encoded = encM.encode(src[i]);
383
encoded = Arrays.copyOf(encoded, encoded.length + 1);
384
encoded[encoded.length - 1] = nonBase64;
385
checkEqual(decM.decode(encoded), src[i], "Non-base64 char is not ignored");
386
byte[] decoded = new byte[src[i].length];
387
decM.decode(encoded, decoded);
388
checkEqual(decoded, src[i], "Non-base64 char is not ignored");
389
390
try {
391
dec.decode(encoded);
392
throw new RuntimeException("No IAE for non-base64 char");
393
} catch (IllegalArgumentException iae) {}
394
}
395
}
396
}
397
398
private static void testMalformedPadding() throws Throwable {
399
Object[] data = new Object[] {
400
"$=#", "", 0, // illegal ending unit
401
"A", "", 0, // dangling single byte
402
"A=", "", 0,
403
"A==", "", 0,
404
"QUJDA", "ABC", 4,
405
"QUJDA=", "ABC", 4,
406
"QUJDA==", "ABC", 4,
407
408
"=", "", 0, // unnecessary padding
409
"QUJD=", "ABC", 4, //"ABC".encode() -> "QUJD"
410
411
"AA=", "", 0, // incomplete padding
412
"QQ=", "", 0,
413
"QQ=N", "", 0, // incorrect padding
414
"QQ=?", "", 0,
415
"QUJDQQ=", "ABC", 4,
416
"QUJDQQ=N", "ABC", 4,
417
"QUJDQQ=?", "ABC", 4,
418
};
419
420
Base64.Decoder[] decs = new Base64.Decoder[] {
421
Base64.getDecoder(),
422
Base64.getUrlDecoder(),
423
Base64.getMimeDecoder()
424
};
425
426
for (Base64.Decoder dec : decs) {
427
for (int i = 0; i < data.length; i += 3) {
428
final String srcStr = (String)data[i];
429
final byte[] srcBytes = srcStr.getBytes("ASCII");
430
final ByteBuffer srcBB = ByteBuffer.wrap(srcBytes);
431
byte[] expected = ((String)data[i + 1]).getBytes("ASCII");
432
int pos = (Integer)data[i + 2];
433
434
// decode(byte[])
435
checkIAE(() -> dec.decode(srcBytes));
436
437
// decode(String)
438
checkIAE(() -> dec.decode(srcStr));
439
440
// decode(ByteBuffer)
441
checkIAE(() -> dec.decode(srcBB));
442
443
// wrap stream
444
checkIOE(new Testable() {
445
public void test() throws IOException {
446
try (InputStream is = dec.wrap(new ByteArrayInputStream(srcBytes))) {
447
while (is.read() != -1);
448
}
449
}});
450
}
451
}
452
}
453
454
private static void testDecodeUnpadded() throws Throwable {
455
byte[] srcA = new byte[] { 'Q', 'Q' };
456
byte[] srcAA = new byte[] { 'Q', 'Q', 'E'};
457
Base64.Decoder dec = Base64.getDecoder();
458
byte[] ret = dec.decode(srcA);
459
if (ret[0] != 'A')
460
throw new RuntimeException("Decoding unpadding input A failed");
461
ret = dec.decode(srcAA);
462
if (ret[0] != 'A' && ret[1] != 'A')
463
throw new RuntimeException("Decoding unpadding input AA failed");
464
ret = new byte[10];
465
if (dec.wrap(new ByteArrayInputStream(srcA)).read(ret) != 1 &&
466
ret[0] != 'A')
467
throw new RuntimeException("Decoding unpadding input A from stream failed");
468
if (dec.wrap(new ByteArrayInputStream(srcA)).read(ret) != 2 &&
469
ret[0] != 'A' && ret[1] != 'A')
470
throw new RuntimeException("Decoding unpadding input AA from stream failed");
471
}
472
473
// single-non-base64-char should be ignored for mime decoding, but
474
// iae for basic decoding
475
private static void testSingleNonBase64MimeDec() throws Throwable {
476
for (String nonBase64 : new String[] {"#", "(", "!", "\\", "-", "_"}) {
477
if (Base64.getMimeDecoder().decode(nonBase64).length != 0) {
478
throw new RuntimeException("non-base64 char is not ignored");
479
}
480
try {
481
Base64.getDecoder().decode(nonBase64);
482
throw new RuntimeException("No IAE for single non-base64 char");
483
} catch (IllegalArgumentException iae) {}
484
}
485
}
486
487
private static final void testEncode(Base64.Encoder enc, ByteBuffer bin, byte[] expected)
488
throws Throwable {
489
490
ByteBuffer bout = enc.encode(bin);
491
byte[] buf = new byte[bout.remaining()];
492
bout.get(buf);
493
if (bin.hasRemaining()) {
494
throw new RuntimeException(
495
"Base64 enc.encode(ByteBuffer) failed!");
496
}
497
checkEqual(buf, expected, "Base64 enc.encode(bf, bf) failed!");
498
}
499
500
private static final void testDecode(Base64.Decoder dec, ByteBuffer bin, byte[] expected)
501
throws Throwable {
502
503
ByteBuffer bout = dec.decode(bin);
504
byte[] buf = new byte[bout.remaining()];
505
bout.get(buf);
506
checkEqual(buf, expected, "Base64 dec.decode(bf) failed!");
507
}
508
509
private static final void checkEqual(int v1, int v2, String msg)
510
throws Throwable {
511
if (v1 != v2) {
512
System.out.printf(" v1=%d%n", v1);
513
System.out.printf(" v2=%d%n", v2);
514
throw new RuntimeException(msg);
515
}
516
}
517
518
private static final void checkEqual(byte[] r1, byte[] r2, String msg)
519
throws Throwable {
520
if (!Arrays.equals(r1, r2)) {
521
System.out.printf(" r1[%d]=[%s]%n", r1.length, new String(r1));
522
System.out.printf(" r2[%d]=[%s]%n", r2.length, new String(r2));
523
throw new RuntimeException(msg);
524
}
525
}
526
527
// remove line feeds,
528
private static final byte[] normalize(byte[] src) {
529
int n = 0;
530
boolean hasUrl = false;
531
for (int i = 0; i < src.length; i++) {
532
if (src[i] == '\r' || src[i] == '\n')
533
n++;
534
if (src[i] == '-' || src[i] == '_')
535
hasUrl = true;
536
}
537
if (n == 0 && hasUrl == false)
538
return src;
539
byte[] ret = new byte[src.length - n];
540
int j = 0;
541
for (int i = 0; i < src.length; i++) {
542
if (src[i] == '-')
543
ret[j++] = '+';
544
else if (src[i] == '_')
545
ret[j++] = '/';
546
else if (src[i] != '\r' && src[i] != '\n')
547
ret[j++] = src[i];
548
}
549
return ret;
550
}
551
552
private static void testEncoderKeepsSilence(Base64.Encoder enc)
553
throws Throwable {
554
List<Integer> vals = Arrays.asList(Integer.MIN_VALUE,
555
Integer.MIN_VALUE + 1, -1111, -2, -1, 0, 1, 2, 3, 1111,
556
Integer.MAX_VALUE - 1, Integer.MAX_VALUE,
557
rnd.nextInt(), rnd.nextInt(), rnd.nextInt(),
558
rnd.nextInt());
559
byte[] buf = new byte[] {1, 0, 91};
560
for (int off : vals) {
561
for (int len : vals) {
562
if (off >= 0 && len >= 0 && off <= buf.length - len) {
563
// valid args, skip them
564
continue;
565
}
566
// invalid args, test them
567
System.out.println("testing off=" + off + ", len=" + len);
568
569
ByteArrayOutputStream baos = new ByteArrayOutputStream(100);
570
try (OutputStream os = enc.wrap(baos)) {
571
os.write(buf, off, len);
572
throw new RuntimeException("Expected IOOBEx was not thrown");
573
} catch (IndexOutOfBoundsException expected) {
574
}
575
if (baos.size() > 0)
576
throw new RuntimeException("No output was expected, but got "
577
+ baos.size() + " bytes");
578
}
579
}
580
}
581
582
private static void testDecoderKeepsAbstinence(Base64.Decoder dec)
583
throws Throwable {
584
List<Integer> vals = Arrays.asList(Integer.MIN_VALUE,
585
Integer.MIN_VALUE + 1, -1111, -2, -1, 0, 1, 2, 3, 1111,
586
Integer.MAX_VALUE - 1, Integer.MAX_VALUE,
587
rnd.nextInt(), rnd.nextInt(), rnd.nextInt(),
588
rnd.nextInt());
589
byte[] buf = new byte[3];
590
for (int off : vals) {
591
for (int len : vals) {
592
if (off >= 0 && len >= 0 && off <= buf.length - len) {
593
// valid args, skip them
594
continue;
595
}
596
// invalid args, test them
597
System.out.println("testing off=" + off + ", len=" + len);
598
599
String input = "AAAAAAAAAAAAAAAAAAAAAA";
600
ByteArrayInputStream bais =
601
new ByteArrayInputStream(input.getBytes("Latin1"));
602
try (InputStream is = dec.wrap(bais)) {
603
is.read(buf, off, len);
604
throw new RuntimeException("Expected IOOBEx was not thrown");
605
} catch (IndexOutOfBoundsException expected) {
606
}
607
if (bais.available() != input.length())
608
throw new RuntimeException("No input should be consumed, "
609
+ "but consumed " + (input.length() - bais.available())
610
+ " bytes");
611
}
612
}
613
}
614
}
615
616