Apache Commons logo Commons Compress

CPD Results

The following document contains the results of PMD's CPD 6.55.0.

Duplications

File Line
org/apache/commons/compress/harmony/pack200/MetadataBandGroup.java 90
org/apache/commons/compress/harmony/pack200/MetadataBandGroup.java 169
pair_N.add(nameRU.size());
        nameRU.forEach(name -> name_RU.add(cpBands.getCPUtf8(name)));

        final Iterator<Object> valuesIterator = values.iterator();
        for (final String tag : tags) {
            T.add(tag);
            switch (tag) {
            case "B":
            case "C":
            case "I":
            case "S":
            case "Z": {
                caseI_KI.add(cpBands.getConstant(valuesIterator.next()));
                break;
            }
            case "D": {
                caseD_KD.add(cpBands.getConstant(valuesIterator.next()));
                break;
            }
            case "F": {
                caseF_KF.add(cpBands.getConstant(valuesIterator.next()));
                break;
            }
            case "J": {
                caseJ_KJ.add(cpBands.getConstant(valuesIterator.next()));
                break;
            }
            case "c": {
                casec_RS.add(cpBands.getCPSignature(nextString(valuesIterator)));
                break;
            }
            case "e": {
                caseet_RS.add(cpBands.getCPSignature(nextString(valuesIterator)));
                caseec_RU.add(cpBands.getCPUtf8(nextString(valuesIterator)));
                break;
            }
            case "s": {
                cases_RU.add(cpBands.getCPUtf8(nextString(valuesIterator)));
                break;
            }
            }
            // do nothing here for [ or @ (handled below)
        }
        for (final Integer element : caseArrayN) {
            final int arraySize = element.intValue();
            casearray_N.add(arraySize);
            numBackwardsCalls += arraySize;
        }
        nestTypeRS.forEach(element -> nesttype_RS.add(cpBands.getCPSignature(element)));
File Line
org/apache/commons/compress/harmony/unpack200/bytecode/LocalVariableTableAttribute.java 71
org/apache/commons/compress/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java 71
nestedEntries.add(descriptors[i]);
        }
        return nestedEntries.toArray(ClassFileEntry.NONE);
    }

    @Override
    protected int[] getStartPCs() {
        return startPcs;
    }

    /*
     * (non-Javadoc)
     *
     * @see org.apache.commons.compress.harmony.unpack200.bytecode.BCIRenumberedAttribute#renumber(java.util.List)
     */
    @Override
    public void renumber(final List<Integer> byteCodeOffsets) throws Pack200Exception {
        // Remember the unrenumbered startPcs, since that's used later
        // to calculate end position.
        final int[] unrenumberedStartPcs = Arrays.copyOf(startPcs, startPcs.length);

        // Next renumber startPcs in place
        super.renumber(byteCodeOffsets);

        // lengths are BRANCH5 encoded, not BCI-encoded.
        // In other words:
        // startPc is BCI5 startPc
        // endPc is byteCodeOffset[(index of startPc in byteCodeOffset) +
        // (encoded length)]
        // real length = endPc - startPc
        // special case if endPc is beyond end of bytecode array

        final int maxSize = codeLength;

        // Iterate through the lengths and update each in turn.
        // This is done in place in the lengths array.
        for (int index = 0; index < lengths.length; index++) {
            final int startPc = startPcs[index];
            int revisedLength = -1;
            final int encodedLength = lengths[index];

            // First get the index of the startPc in the byteCodeOffsets
            final int indexOfStartPC = unrenumberedStartPcs[index];
            // Given the index of the startPc, we can now add
            // the encodedLength to it to get the stop index.
            final int stopIndex = indexOfStartPC + encodedLength;
            if (stopIndex < 0) {
                throw new Pack200Exception("Error renumbering bytecode indexes");
            }
            // Length can either be an index into the byte code offsets, or one
            // beyond the
            // end of the byte code offsets. Need to determine which this is.
            if (stopIndex == byteCodeOffsets.size()) {
                // Pointing to one past the end of the byte code array
                revisedLength = maxSize - startPc;
            } else {
                // We're indexed into the byte code array
                final int stopValue = byteCodeOffsets.get(stopIndex).intValue();
                revisedLength = stopValue - startPc;
            }
            lengths[index] = revisedLength;
        }
    }

    @Override
    protected void resolve(final ClassConstantPool pool) {
        super.resolve(pool);
        nameIndexes = new int[localVariableTableLength];