in src/main/java/org/apache/commons/compress/harmony/unpack200/ClassBands.java [682:745]
private void parseCodeBands(final InputStream in) throws Pack200Exception, IOException {
final AttributeLayout layout = attrMap.getAttributeLayout(AttributeLayout.ATTRIBUTE_CODE, AttributeLayout.CONTEXT_METHOD);
final int codeCount = SegmentUtils.countMatches(methodFlags, layout);
final int[] codeHeaders = decodeBandInt("code_headers", in, Codec.BYTE1, codeCount);
final boolean allCodeHasFlags = segment.getSegmentHeader().getOptions().hasAllCodeFlags();
if (!allCodeHasFlags) {
codeHasAttributes = new boolean[codeCount];
}
int codeSpecialHeader = 0;
for (int i = 0; i < codeCount; i++) {
if (codeHeaders[i] == 0) {
codeSpecialHeader++;
if (!allCodeHasFlags) {
codeHasAttributes[i] = true;
}
}
}
final int[] codeMaxStackSpecials = decodeBandInt("code_max_stack", in, Codec.UNSIGNED5, codeSpecialHeader);
final int[] codeMaxNALocalsSpecials = decodeBandInt("code_max_na_locals", in, Codec.UNSIGNED5, codeSpecialHeader);
final int[] codeHandlerCountSpecials = decodeBandInt("code_handler_count", in, Codec.UNSIGNED5, codeSpecialHeader);
codeMaxStack = new int[codeCount];
codeMaxNALocals = new int[codeCount];
codeHandlerCount = new int[codeCount];
int special = 0;
for (int i = 0; i < codeCount; i++) {
final int header = 0xff & codeHeaders[i];
if (header < 0) {
throw new IllegalStateException("Shouldn't get here");
}
if (header == 0) {
codeMaxStack[i] = codeMaxStackSpecials[special];
codeMaxNALocals[i] = codeMaxNALocalsSpecials[special];
codeHandlerCount[i] = codeHandlerCountSpecials[special];
special++;
} else if (header <= 144) {
codeMaxStack[i] = (header - 1) % 12;
codeMaxNALocals[i] = (header - 1) / 12;
codeHandlerCount[i] = 0;
} else if (header <= 208) {
codeMaxStack[i] = (header - 145) % 8;
codeMaxNALocals[i] = (header - 145) / 8;
codeHandlerCount[i] = 1;
} else if (header <= 255) {
codeMaxStack[i] = (header - 209) % 7;
codeMaxNALocals[i] = (header - 209) / 7;
codeHandlerCount[i] = 2;
} else {
throw new IllegalStateException("Shouldn't get here either");
}
}
codeHandlerStartP = decodeBandInt("code_handler_start_P", in, Codec.BCI5, codeHandlerCount);
codeHandlerEndPO = decodeBandInt("code_handler_end_PO", in, Codec.BRANCH5, codeHandlerCount);
codeHandlerCatchPO = decodeBandInt("code_handler_catch_PO", in, Codec.BRANCH5, codeHandlerCount);
codeHandlerClassRCN = decodeBandInt("code_handler_class_RCN", in, Codec.UNSIGNED5, codeHandlerCount);
final int codeFlagsCount = allCodeHasFlags ? codeCount : codeSpecialHeader;
codeAttributes = new List[codeFlagsCount];
Arrays.setAll(codeAttributes, i -> new ArrayList<>());
parseCodeAttrBands(in, codeFlagsCount);
}