2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 * This package is based on the work done by Keiron Liddle, Aftex Software
21 * <keiron@aftexsw.com> to whom the Ant project is very grateful for his
24 package org.apache.tools.bzip2;
26 import java.io.IOException;
27 import java.io.InputStream;
30 * An input stream that decompresses from the BZip2 format (without the file
31 * header chars) to be read as any other stream.
33 * <p>The decompression requires large amounts of memory. Thus you
34 * should call the {@link #close() close()} method as soon as
35 * possible, to force <tt>CBZip2InputStream</tt> to release the
36 * allocated memory. See {@link CBZip2OutputStream
37 * CBZip2OutputStream} for information about memory usage.</p>
39 * <p><tt>CBZip2InputStream</tt> reads bytes from the compressed
40 * source stream via the single byte {@link java.io.InputStream#read()
41 * read()} method exclusively. Thus you should consider to use a
42 * buffered source stream.</p>
44 * <p>Instances of this class are not threadsafe.</p>
46 public class CBZip2InputStream extends InputStream implements BZip2Constants {
49 * Index of the last char in the block, so the block size == last + 1.
54 * Index in zptr[] of original string after sorting.
59 * always: in the range 0 .. 9.
60 * The current block size is 100000 * this number.
62 private int blockSize100k;
64 private boolean blockRandomised;
68 private final CRC crc = new CRC();
72 private InputStream in;
73 private final boolean decompressConcatenated;
75 private int currentChar = -1;
77 private static final int EOF = 0;
78 private static final int START_BLOCK_STATE = 1;
79 private static final int RAND_PART_A_STATE = 2;
80 private static final int RAND_PART_B_STATE = 3;
81 private static final int RAND_PART_C_STATE = 4;
82 private static final int NO_RAND_PART_A_STATE = 5;
83 private static final int NO_RAND_PART_B_STATE = 6;
84 private static final int NO_RAND_PART_C_STATE = 7;
86 private int currentState = START_BLOCK_STATE;
88 private int storedBlockCRC, storedCombinedCRC;
89 private int computedBlockCRC, computedCombinedCRC;
91 // Variables used by setup* methods exclusively
95 private int su_chPrev;
98 private int su_rNToGo;
104 * All memory intensive stuff.
105 * This field is initialized by initBlock().
107 private CBZip2InputStream.Data data;
110 * Constructs a new CBZip2InputStream which decompresses bytes read from
111 * the specified stream. This doesn't suppprt decompressing
112 * concatenated .bz2 files.
114 * <p>Although BZip2 headers are marked with the magic
115 * <tt>"Bz"</tt> this constructor expects the next byte in the
116 * stream to be the first one after the magic. Thus callers have
117 * to skip the first two bytes. Otherwise this constructor will
118 * throw an exception. </p>
121 * @throws IOException
122 * if the stream content is malformed or an I/O error occurs.
123 * @throws NullPointerException
124 * if <tt>in == null</tt>
126 public CBZip2InputStream(final InputStream in) throws IOException {
131 * Constructs a new CBZip2InputStream which decompresses bytes
132 * read from the specified stream.
134 * <p>Although BZip2 headers are marked with the magic
135 * <tt>"Bz"</tt> this constructor expects the next byte in the
136 * stream to be the first one after the magic. Thus callers have
137 * to skip the first two bytes. Otherwise this constructor will
138 * throw an exception. </p>
140 * @param in the InputStream from which this object should be created
141 * @param decompressConcatenated
142 * if true, decompress until the end of the input;
143 * if false, stop after the first .bz2 stream and
144 * leave the input position to point to the next
145 * byte after the .bz2 stream
147 * @throws IOException
148 * if the stream content is malformed or an I/O error occurs.
149 * @throws NullPointerException
150 * if <tt>in == null</tt>
152 public CBZip2InputStream(final InputStream in,
153 final boolean decompressConcatenated)
158 this.decompressConcatenated = decompressConcatenated;
167 public int read() throws IOException {
169 throw new IOException("stream closed");
176 * @see java.io.InputStream#read(byte[], int, int)
179 public int read(final byte[] dest, final int offs, final int len)
182 throw new IndexOutOfBoundsException("offs(" + offs + ") < 0.");
185 throw new IndexOutOfBoundsException("len(" + len + ") < 0.");
187 if (offs + len > dest.length) {
188 throw new IndexOutOfBoundsException("offs(" + offs + ") + len("
189 + len + ") > dest.length("
190 + dest.length + ").");
192 if (this.in == null) {
193 throw new IOException("stream closed");
196 final int hi = offs + len;
198 for (int b; (destOffs < hi) && ((b = read0()) >= 0);) {
199 dest[destOffs++] = (byte) b;
202 return (destOffs == offs) ? -1 : (destOffs - offs);
205 private void makeMaps() {
206 final boolean[] inUse = this.data.inUse;
207 final byte[] seqToUnseq = this.data.seqToUnseq;
209 int nInUseShadow = 0;
211 for (int i = 0; i < 256; i++) {
213 seqToUnseq[nInUseShadow++] = (byte) i;
217 this.nInUse = nInUseShadow;
220 private int read0() throws IOException {
221 final int retChar = this.currentChar;
223 switch (this.currentState) {
227 case START_BLOCK_STATE:
228 throw new IllegalStateException();
230 case RAND_PART_A_STATE:
231 throw new IllegalStateException();
233 case RAND_PART_B_STATE:
237 case RAND_PART_C_STATE:
241 case NO_RAND_PART_A_STATE:
242 throw new IllegalStateException();
244 case NO_RAND_PART_B_STATE:
248 case NO_RAND_PART_C_STATE:
253 throw new IllegalStateException();
259 private boolean init(boolean isFirstStream) throws IOException {
261 throw new IOException("No InputStream");
265 if (in.available() == 0) {
266 throw new IOException("Empty InputStream");
274 if (magic0 != 'B' || magic1 != 'Z') {
275 throw new IOException("Garbage after a valid BZip2 stream");
281 throw new IOException(isFirstStream
282 ? "Stream is not in the BZip2 format"
283 : "Garbage after a valid BZip2 stream");
286 int blockSize = read();
287 if ((blockSize < '1') || (blockSize > '9')) {
288 throw new IOException("Stream is not BZip2 formatted: illegal "
289 + "blocksize " + (char) blockSize);
292 this.blockSize100k = blockSize - '0';
295 this.computedCombinedCRC = 0;
300 private void initBlock() throws IOException {
309 // Get the block magic bytes.
310 magic0 = bsGetUByte();
311 magic1 = bsGetUByte();
312 magic2 = bsGetUByte();
313 magic3 = bsGetUByte();
314 magic4 = bsGetUByte();
315 magic5 = bsGetUByte();
317 // If isn't end of stream magic, break out of the loop.
318 if (magic0 != 0x17 || magic1 != 0x72 || magic2 != 0x45 || magic3 != 0x38
319 || magic4 != 0x50 || magic5 != 0x90) {
323 // End of stream was reached. Check the combined CRC and
324 // advance to the next .bz2 stream if decoding concatenated
331 if (magic0 != 0x31 || // '1'
332 magic1 != 0x41 || // ')'
333 magic2 != 0x59 || // 'Y'
334 magic3 != 0x26 || // '&'
335 magic4 != 0x53 || // 'S'
336 magic5 != 0x59 // 'Y'
338 this.currentState = EOF;
339 throw new IOException("bad block header");
341 this.storedBlockCRC = bsGetInt();
342 this.blockRandomised = bsR(1) == 1;
345 * Allocate data here instead in constructor, so we do not allocate it if
346 * the input file is empty.
348 if (this.data == null) {
349 this.data = new Data(this.blockSize100k);
353 getAndMoveToFrontDecode();
355 this.crc.initialiseCRC();
356 this.currentState = START_BLOCK_STATE;
359 private void endBlock() throws IOException {
360 this.computedBlockCRC = this.crc.getFinalCRC();
362 // A bad CRC is considered a fatal error.
363 if (this.storedBlockCRC != this.computedBlockCRC) {
364 // make next blocks readable without error
365 // (repair feature, not yet documented, not tested)
366 this.computedCombinedCRC
367 = (this.storedCombinedCRC << 1)
368 | (this.storedCombinedCRC >>> 31);
369 this.computedCombinedCRC ^= this.storedBlockCRC;
374 this.computedCombinedCRC
375 = (this.computedCombinedCRC << 1)
376 | (this.computedCombinedCRC >>> 31);
377 this.computedCombinedCRC ^= this.computedBlockCRC;
380 private boolean complete() throws IOException {
381 this.storedCombinedCRC = bsGetInt();
382 this.currentState = EOF;
385 if (this.storedCombinedCRC != this.computedCombinedCRC) {
389 // Look for the next .bz2 stream if decompressing
390 // concatenated files.
391 return !decompressConcatenated || !init(false);
395 public void close() throws IOException {
396 InputStream inShadow = this.in;
397 if (inShadow != null) {
399 if (inShadow != System.in) {
409 private int bsR(final int n) throws IOException {
410 int bsLiveShadow = this.bsLive;
411 int bsBuffShadow = this.bsBuff;
413 if (bsLiveShadow < n) {
414 final InputStream inShadow = this.in;
416 int thech = read();//inShadow.read();
419 throw new IOException("unexpected end of stream");
422 bsBuffShadow = (bsBuffShadow << 8) | thech;
424 } while (bsLiveShadow < n);
426 this.bsBuff = bsBuffShadow;
429 this.bsLive = bsLiveShadow - n;
430 return (bsBuffShadow >> (bsLiveShadow - n)) & ((1 << n) - 1);
433 private boolean bsGetBit() throws IOException {
434 int bsLiveShadow = this.bsLive;
435 int bsBuffShadow = this.bsBuff;
437 if (bsLiveShadow < 1) {
441 throw new IOException("unexpected end of stream");
444 bsBuffShadow = (bsBuffShadow << 8) | thech;
446 this.bsBuff = bsBuffShadow;
449 this.bsLive = bsLiveShadow - 1;
450 return ((bsBuffShadow >> (bsLiveShadow - 1)) & 1) != 0;
453 private char bsGetUByte() throws IOException {
454 return (char) bsR(8);
457 private int bsGetInt() throws IOException {
458 return (((((bsR(8) << 8) | bsR(8)) << 8) | bsR(8)) << 8) | bsR(8);
462 * Called by createHuffmanDecodingTables() exclusively.
471 private static void hbCreateDecodeTables(final int[] limit,
477 final int alphaSize) {
478 for (int i = minLen, pp = 0; i <= maxLen; i++) {
479 for (int j = 0; j < alphaSize; j++) {
480 if (length[j] == i) {
486 for (int i = MAX_CODE_LEN; --i > 0;) {
491 for (int i = 0; i < alphaSize; i++) {
492 base[length[i] + 1]++;
495 for (int i = 1, b = base[0]; i < MAX_CODE_LEN; i++) {
500 for (int i = minLen, vec = 0, b = base[i]; i <= maxLen; i++) {
501 final int nb = base[i + 1];
508 for (int i = minLen + 1; i <= maxLen; i++) {
509 base[i] = ((limit[i - 1] + 1) << 1) - base[i];
513 private void recvDecodingTables() throws IOException {
514 final Data dataShadow = this.data;
515 final boolean[] inUse = dataShadow.inUse;
516 final byte[] pos = dataShadow.recvDecodingTables_pos;
517 final byte[] selector = dataShadow.selector;
518 final byte[] selectorMtf = dataShadow.selectorMtf;
522 /* Receive the mapping table */
523 for (int i = 0; i < 16; i++) {
529 for (int i = 256; --i >= 0;) {
533 for (int i = 0; i < 16; i++) {
534 if ((inUse16 & (1 << i)) != 0) {
535 final int i16 = i << 4;
536 for (int j = 0; j < 16; j++) {
538 inUse[i16 + j] = true;
545 final int alphaSize = this.nInUse + 2;
547 /* Now the selectors */
548 final int nGroups = bsR(3);
549 final int nSelectors = bsR(15);
551 for (int i = 0; i < nSelectors; i++) {
556 selectorMtf[i] = (byte) j;
559 /* Undo the MTF values for the selectors. */
560 for (int v = nGroups; --v >= 0;) {
564 for (int i = 0; i < nSelectors; i++) {
565 int v = selectorMtf[i] & 0xff;
566 final byte tmp = pos[v];
568 // nearly all times v is zero, 4 in most other cases
576 final char[][] len = dataShadow.temp_charArray2d;
578 /* Now the coding tables */
579 for (int t = 0; t < nGroups; t++) {
581 final char[] len_t = len[t];
582 for (int i = 0; i < alphaSize; i++) {
584 curr += bsGetBit() ? -1 : 1;
586 len_t[i] = (char) curr;
590 // finally create the Huffman tables
591 createHuffmanDecodingTables(alphaSize, nGroups);
595 * Called by recvDecodingTables() exclusively.
599 private void createHuffmanDecodingTables(final int alphaSize,
601 final Data dataShadow = this.data;
602 final char[][] len = dataShadow.temp_charArray2d;
603 final int[] minLens = dataShadow.minLens;
604 final int[][] limit = dataShadow.limit;
605 final int[][] base = dataShadow.base;
606 final int[][] perm = dataShadow.perm;
608 for (int t = 0; t < nGroups; t++) {
611 final char[] len_t = len[t];
612 for (int i = alphaSize; --i >= 0;) {
613 final char lent = len_t[i];
621 hbCreateDecodeTables(limit[t], base[t], perm[t], len[t], minLen,
627 private void getAndMoveToFrontDecode() throws IOException {
628 this.origPtr = bsR(24);
629 recvDecodingTables();
631 final InputStream inShadow = this.in;
632 final Data dataShadow = this.data;
633 final byte[] ll8 = dataShadow.ll8;
634 final int[] unzftab = dataShadow.unzftab;
635 final byte[] selector = dataShadow.selector;
636 final byte[] seqToUnseq = dataShadow.seqToUnseq;
637 final char[] yy = dataShadow.getAndMoveToFrontDecode_yy;
638 final int[] minLens = dataShadow.minLens;
639 final int[][] limit = dataShadow.limit;
640 final int[][] base = dataShadow.base;
641 final int[][] perm = dataShadow.perm;
642 final int limitLast = this.blockSize100k * 100000;
645 Setting up the unzftab entries here is not strictly
646 necessary, but it does save having to do it later
647 in a separate pass, and so saves a block's worth of
650 for (int i = 256; --i >= 0;) {
656 int groupPos = G_SIZE - 1;
657 final int eob = this.nInUse + 1;
658 int nextSym = getAndMoveToFrontDecode0(0);
659 int bsBuffShadow = this.bsBuff;
660 int bsLiveShadow = this.bsLive;
662 int zt = selector[groupNo] & 0xff;
663 int[] base_zt = base[zt];
664 int[] limit_zt = limit[zt];
665 int[] perm_zt = perm[zt];
666 int minLens_zt = minLens[zt];
668 while (nextSym != eob) {
669 if ((nextSym == RUNA) || (nextSym == RUNB)) {
672 for (int n = 1; true; n <<= 1) {
673 if (nextSym == RUNA) {
675 } else if (nextSym == RUNB) {
682 groupPos = G_SIZE - 1;
683 zt = selector[++groupNo] & 0xff;
685 limit_zt = limit[zt];
687 minLens_zt = minLens[zt];
695 // int zvec = bsR(zn);
696 while (bsLiveShadow < zn) {
697 final int thech = read();//inShadow.read();
699 throw new IOException("unexpected end of stream");
701 bsBuffShadow = (bsBuffShadow << 8) | thech;
705 int zvec = (bsBuffShadow >> (bsLiveShadow - zn)) & ((1 << zn) - 1);
708 while (zvec > limit_zt[zn]) {
710 while (bsLiveShadow < 1) {
711 final int thech = read();//inShadow.read();
713 throw new IOException("unexpected end of stream");
714 bsBuffShadow = (bsBuffShadow << 8) | thech;
719 zvec = (zvec << 1) | ((bsBuffShadow >> bsLiveShadow) & 1);
721 nextSym = perm_zt[zvec - base_zt[zn]];
724 final byte ch = seqToUnseq[yy[0]];
725 unzftab[ch & 0xff] += s + 1;
728 ll8[++lastShadow] = ch;
731 if (lastShadow >= limitLast) {
732 throw new IOException("block overrun");
735 if (++lastShadow >= limitLast) {
736 throw new IOException("block overrun");
739 final char tmp = yy[nextSym - 1];
740 unzftab[seqToUnseq[tmp] & 0xff]++;
741 ll8[lastShadow] = seqToUnseq[tmp];
744 This loop is hammered during decompression,
745 hence avoid native method call overhead of
746 System.arraycopy for very small ranges to copy.
749 for (int j = nextSym - 1; j > 0;) {
753 System.arraycopy(yy, 0, yy, 1, nextSym - 1);
759 groupPos = G_SIZE - 1;
760 zt = selector[++groupNo] & 0xff;
762 limit_zt = limit[zt];
764 minLens_zt = minLens[zt];
772 // int zvec = bsR(zn);
773 while (bsLiveShadow < zn) {
774 final int thech = read();//inShadow.read();
776 throw new IOException("unexpected end of stream");
777 bsBuffShadow = (bsBuffShadow << 8) | thech;
781 int zvec = (bsBuffShadow >> (bsLiveShadow - zn)) & ((1 << zn) - 1);
784 while (zvec > limit_zt[zn]) {
786 while (bsLiveShadow < 1) {
787 final int thech = read();//inShadow.read();
789 throw new IOException("unexpected end of stream");
790 bsBuffShadow = (bsBuffShadow << 8) | thech;
795 zvec = (zvec << 1) | ((bsBuffShadow >> bsLiveShadow) & 1);
797 nextSym = perm_zt[zvec - base_zt[zn]];
801 this.last = lastShadow;
802 this.bsLive = bsLiveShadow;
803 this.bsBuff = bsBuffShadow;
806 private int getAndMoveToFrontDecode0(final int groupNo) throws IOException {
807 final InputStream inShadow = this.in;
808 final Data dataShadow = this.data;
809 final int zt = dataShadow.selector[groupNo] & 0xff;
810 final int[] limit_zt = dataShadow.limit[zt];
811 int zn = dataShadow.minLens[zt];
813 int bsLiveShadow = this.bsLive;
814 int bsBuffShadow = this.bsBuff;
816 while (zvec > limit_zt[zn]) {
818 while (bsLiveShadow < 1) {
819 final int thech = read();//inShadow.read();
822 throw new IOException("unexpected end of stream");
824 bsBuffShadow = (bsBuffShadow << 8) | thech;
829 zvec = (zvec << 1) | ((bsBuffShadow >> bsLiveShadow) & 1);
832 this.bsLive = bsLiveShadow;
833 this.bsBuff = bsBuffShadow;
835 return dataShadow.perm[zt][zvec - dataShadow.base[zt][zn]];
838 private void setupBlock() throws IOException {
839 if (this.data == null) {
843 final int[] cftab = this.data.cftab;
844 final int[] tt = this.data.initTT(this.last + 1);
845 final byte[] ll8 = this.data.ll8;
847 System.arraycopy(this.data.unzftab, 0, cftab, 1, 256);
849 for (int i = 1, c = cftab[0]; i <= 256; i++) {
854 for (int i = 0, lastShadow = this.last; i <= lastShadow; i++) {
855 tt[cftab[ll8[i] & 0xff]++] = i;
858 if ((this.origPtr < 0) || (this.origPtr >= tt.length)) {
859 throw new IOException("stream corrupted");
862 this.su_tPos = tt[this.origPtr];
865 this.su_ch2 = 256; /* not a char and not EOF */
867 if (this.blockRandomised) {
876 private void setupRandPartA() throws IOException {
877 if (this.su_i2 <= this.last) {
878 this.su_chPrev = this.su_ch2;
879 int su_ch2Shadow = this.data.ll8[this.su_tPos] & 0xff;
880 this.su_tPos = this.data.tt[this.su_tPos];
881 if (this.su_rNToGo == 0) {
882 this.su_rNToGo = BZip2Constants.rNums[this.su_rTPos] - 1;
883 if (++this.su_rTPos == 512) {
889 this.su_ch2 = su_ch2Shadow ^= (this.su_rNToGo == 1) ? 1 : 0;
891 this.currentChar = su_ch2Shadow;
892 this.currentState = RAND_PART_B_STATE;
893 this.crc.updateCRC(su_ch2Shadow);
901 private void setupNoRandPartA() throws IOException {
902 if (this.su_i2 <= this.last) {
903 this.su_chPrev = this.su_ch2;
904 int su_ch2Shadow = this.data.ll8[this.su_tPos] & 0xff;
905 this.su_ch2 = su_ch2Shadow;
906 this.su_tPos = this.data.tt[this.su_tPos];
908 this.currentChar = su_ch2Shadow;
909 this.currentState = NO_RAND_PART_B_STATE;
910 this.crc.updateCRC(su_ch2Shadow);
912 this.currentState = NO_RAND_PART_A_STATE;
919 private void setupRandPartB() throws IOException {
920 if (this.su_ch2 != this.su_chPrev) {
921 this.currentState = RAND_PART_A_STATE;
924 } else if (++this.su_count >= 4) {
925 this.su_z = (char) (this.data.ll8[this.su_tPos] & 0xff);
926 this.su_tPos = this.data.tt[this.su_tPos];
927 if (this.su_rNToGo == 0) {
928 this.su_rNToGo = BZip2Constants.rNums[this.su_rTPos] - 1;
929 if (++this.su_rTPos == 512) {
936 this.currentState = RAND_PART_C_STATE;
937 if (this.su_rNToGo == 1) {
942 this.currentState = RAND_PART_A_STATE;
947 private void setupRandPartC() throws IOException {
948 if (this.su_j2 < this.su_z) {
949 this.currentChar = this.su_ch2;
950 this.crc.updateCRC(this.su_ch2);
953 this.currentState = RAND_PART_A_STATE;
960 private void setupNoRandPartB() throws IOException {
961 if (this.su_ch2 != this.su_chPrev) {
964 } else if (++this.su_count >= 4) {
965 this.su_z = (char) (this.data.ll8[this.su_tPos] & 0xff);
966 this.su_tPos = this.data.tt[this.su_tPos];
974 private void setupNoRandPartC() throws IOException {
975 if (this.su_j2 < this.su_z) {
976 int su_ch2Shadow = this.su_ch2;
977 this.currentChar = su_ch2Shadow;
978 this.crc.updateCRC(su_ch2Shadow);
980 this.currentState = NO_RAND_PART_C_STATE;
988 private static final class Data extends Object {
990 // (with blockSize 900k)
991 final boolean[] inUse = new boolean[256]; // 256 byte
993 final byte[] seqToUnseq = new byte[256]; // 256 byte
994 final byte[] selector = new byte[MAX_SELECTORS]; // 18002 byte
995 final byte[] selectorMtf = new byte[MAX_SELECTORS]; // 18002 byte
998 * Freq table collected to save a pass over the data during
1001 final int[] unzftab = new int[256]; // 1024 byte
1003 final int[][] limit = new int[N_GROUPS][MAX_ALPHA_SIZE]; // 6192 byte
1004 final int[][] base = new int[N_GROUPS][MAX_ALPHA_SIZE]; // 6192 byte
1005 final int[][] perm = new int[N_GROUPS][MAX_ALPHA_SIZE]; // 6192 byte
1006 final int[] minLens = new int[N_GROUPS]; // 24 byte
1008 final int[] cftab = new int[257]; // 1028 byte
1009 final char[] getAndMoveToFrontDecode_yy = new char[256]; // 512 byte
1010 final char[][] temp_charArray2d = new char[N_GROUPS][MAX_ALPHA_SIZE]; // 3096 byte
1011 final byte[] recvDecodingTables_pos = new byte[N_GROUPS]; // 6 byte
1015 int[] tt; // 3600000 byte
1016 byte[] ll8; // 900000 byte
1021 Data(int blockSize100k) {
1024 this.ll8 = new byte[blockSize100k * BZip2Constants.baseBlockSize];
1028 * Initializes the {@link #tt} array.
1030 * This method is called when the required length of the array
1031 * is known. I don't initialize it at construction time to
1032 * avoid unnecessary memory allocation when compressing small
1037 final int[] initTT(int length) {
1038 int[] ttShadow = this.tt;
1040 // tt.length should always be >= length, but theoretically
1041 // it can happen, if the compressor mixed small and large
1042 // blocks. Normally only the last block will be smaller
1044 if ((ttShadow == null) || (ttShadow.length < length)) {
1045 this.tt = ttShadow = new int[length];
1053 @SuppressWarnings("unused")
1054 private static void reportCRCError() throws IOException {
1055 // The clean way would be to throw an exception.
1056 //throw new IOException("crc error");
1058 // Just print a message, like the previous versions of this class did
1059 System.err.println("BZip2 CRC error");