test_class.declarator: BIG = 2048L * 1024L * 1024L
test_class.modifier: private static final
test_class.original_string: private static final long BIG = 2048L * 1024L * 1024L;
test_class.type: long
test_class.var_name: BIG
test_class.declarator: DEFLATE_PARAMS = JreDeflateParameters.of(6, 0, true)
test_class.modifier: private static final
test_class.original_string: private static final JreDeflateParameters DEFLATE_PARAMS = JreDeflateParameters.of(6, 0, true);
test_class.type: JreDeflateParameters
test_class.var_name: DEFLATE_PARAMS
test_class.declarator: OLD_DELTA_FRIENDLY_UNCOMPRESS_RANGE1 =
        new TypedRange<Void>(BIG, 17L, null)
test_class.modifier: private static final
test_class.original_string: private static final TypedRange<Void> OLD_DELTA_FRIENDLY_UNCOMPRESS_RANGE1 =
        new TypedRange<Void>(BIG, 17L, null);
test_class.type: TypedRange<Void>
test_class.var_name: OLD_DELTA_FRIENDLY_UNCOMPRESS_RANGE1
test_class.declarator: OLD_DELTA_FRIENDLY_UNCOMPRESS_RANGE2 =
        new TypedRange<Void>(BIG + 25L, 19L, null)
test_class.modifier: private static final
test_class.original_string: private static final TypedRange<Void> OLD_DELTA_FRIENDLY_UNCOMPRESS_RANGE2 =
        new TypedRange<Void>(BIG + 25L, 19L, null);
test_class.type: TypedRange<Void>
test_class.var_name: OLD_DELTA_FRIENDLY_UNCOMPRESS_RANGE2
test_class.declarator: OLD_DELTA_FRIENDLY_UNCOMPRESS_PLAN =
        Collections.unmodifiableList(
            Arrays.asList(
                OLD_DELTA_FRIENDLY_UNCOMPRESS_RANGE1, OLD_DELTA_FRIENDLY_UNCOMPRESS_RANGE2))
test_class.modifier: private static final
test_class.original_string: private static final List<TypedRange<Void>> OLD_DELTA_FRIENDLY_UNCOMPRESS_PLAN =
        Collections.unmodifiableList(
            Arrays.asList(
                OLD_DELTA_FRIENDLY_UNCOMPRESS_RANGE1, OLD_DELTA_FRIENDLY_UNCOMPRESS_RANGE2));
test_class.type: List<TypedRange<Void>>
test_class.var_name: OLD_DELTA_FRIENDLY_UNCOMPRESS_PLAN
test_class.declarator: NEW_DELTA_FRIENDLY_RECOMPRESS_RANGE1 =
        new TypedRange<JreDeflateParameters>(BIG, BIG, DEFLATE_PARAMS)
test_class.modifier: private static final
test_class.original_string: private static final TypedRange<JreDeflateParameters> NEW_DELTA_FRIENDLY_RECOMPRESS_RANGE1 =
        new TypedRange<JreDeflateParameters>(BIG, BIG, DEFLATE_PARAMS);
test_class.type: TypedRange<JreDeflateParameters>
test_class.var_name: NEW_DELTA_FRIENDLY_RECOMPRESS_RANGE1
test_class.declarator: NEW_DELTA_FRIENDLY_RECOMPRESS_RANGE2 =
        new TypedRange<JreDeflateParameters>(BIG * 2, BIG, DEFLATE_PARAMS)
test_class.modifier: private static final
test_class.original_string: private static final TypedRange<JreDeflateParameters> NEW_DELTA_FRIENDLY_RECOMPRESS_RANGE2 =
        new TypedRange<JreDeflateParameters>(BIG * 2, BIG, DEFLATE_PARAMS);
test_class.type: TypedRange<JreDeflateParameters>
test_class.var_name: NEW_DELTA_FRIENDLY_RECOMPRESS_RANGE2
test_class.declarator: NEW_DELTA_FRIENDLY_RECOMPRESS_PLAN =
        Collections.unmodifiableList(
            Arrays.asList(
                NEW_DELTA_FRIENDLY_RECOMPRESS_RANGE1, NEW_DELTA_FRIENDLY_RECOMPRESS_RANGE2))
test_class.modifier: private static final
test_class.original_string: private static final List<TypedRange<JreDeflateParameters>> NEW_DELTA_FRIENDLY_RECOMPRESS_PLAN =
        Collections.unmodifiableList(
            Arrays.asList(
                NEW_DELTA_FRIENDLY_RECOMPRESS_RANGE1, NEW_DELTA_FRIENDLY_RECOMPRESS_RANGE2));
test_class.type: List<TypedRange<JreDeflateParameters>>
test_class.var_name: NEW_DELTA_FRIENDLY_RECOMPRESS_PLAN
test_class.declarator: DELTA_FRIENDLY_OLD_FILE_SIZE = BIG - 75L
test_class.modifier: private static final
test_class.original_string: private static final long DELTA_FRIENDLY_OLD_FILE_SIZE = BIG - 75L;
test_class.type: long
test_class.var_name: DELTA_FRIENDLY_OLD_FILE_SIZE
test_class.declarator: DELTA_FRIENDLY_NEW_FILE_SIZE = BIG + 75L
test_class.modifier: private static final
test_class.original_string: private static final long DELTA_FRIENDLY_NEW_FILE_SIZE = BIG + 75L;
test_class.type: long
test_class.var_name: DELTA_FRIENDLY_NEW_FILE_SIZE
test_class.declarator: DELTA_FRIENDLY_OLD_FILE_WORK_RANGE =
        new TypedRange<Void>(0, DELTA_FRIENDLY_OLD_FILE_SIZE, null)
test_class.modifier: private static final
test_class.original_string: private static final TypedRange<Void> DELTA_FRIENDLY_OLD_FILE_WORK_RANGE =
        new TypedRange<Void>(0, DELTA_FRIENDLY_OLD_FILE_SIZE, null);
test_class.type: TypedRange<Void>
test_class.var_name: DELTA_FRIENDLY_OLD_FILE_WORK_RANGE
test_class.declarator: DELTA_FRIENDLY_NEW_FILE_WORK_RANGE =
        new TypedRange<Void>(0, DELTA_FRIENDLY_NEW_FILE_SIZE, null)
test_class.modifier: private static final
test_class.original_string: private static final TypedRange<Void> DELTA_FRIENDLY_NEW_FILE_WORK_RANGE =
        new TypedRange<Void>(0, DELTA_FRIENDLY_NEW_FILE_SIZE, null);
test_class.type: TypedRange<Void>
test_class.var_name: DELTA_FRIENDLY_NEW_FILE_WORK_RANGE
test_class.declarator: DELTA_CONTENT = "all your delta are belong to us"
test_class.modifier: private static final
test_class.original_string: private static final String DELTA_CONTENT = "all your delta are belong to us";
test_class.type: String
test_class.var_name: DELTA_CONTENT
test_class.declarator: DELTA_DESCRIPTOR =
        new DeltaDescriptor(
            PatchConstants.DeltaFormat.BSDIFF,
            DELTA_FRIENDLY_OLD_FILE_WORK_RANGE,
            DELTA_FRIENDLY_NEW_FILE_WORK_RANGE,
            DELTA_CONTENT.length())
test_class.modifier: private static final
test_class.original_string: private static final DeltaDescriptor DELTA_DESCRIPTOR =
        new DeltaDescriptor(
            PatchConstants.DeltaFormat.BSDIFF,
            DELTA_FRIENDLY_OLD_FILE_WORK_RANGE,
            DELTA_FRIENDLY_NEW_FILE_WORK_RANGE,
            DELTA_CONTENT.length());
test_class.type: DeltaDescriptor
test_class.var_name: DELTA_DESCRIPTOR
test_class.declarator: DELTA_DESCRIPTORS =
        Collections.singletonList(DELTA_DESCRIPTOR)
test_class.modifier: private static final
test_class.original_string: private static final List<DeltaDescriptor> DELTA_DESCRIPTORS =
        Collections.singletonList(DELTA_DESCRIPTOR);
test_class.type: List<DeltaDescriptor>
test_class.var_name: DELTA_DESCRIPTORS
test_class.declarator: corruption = null
test_class.modifier: private
test_class.original_string: private Corruption corruption = null;
test_class.type: Corruption
test_class.var_name: corruption
test_class.file: feya/libraries/archive_diff/diff.applier/src/test/java/com/google/archivepatcher/applier/PatchReaderTest.java
test_class.identifier: PatchReaderTest
test_case.body: @Test(expected = PatchFormatException.class)
    public void testReadPatchApplyPlan_CorruptIdentifier() throws IOException {
      corruption.corruptIdentifier = true;
      new PatchReader().readPatchApplyPlan(new ByteArrayInputStream(writeTestPatch()));
    }
test_case.class_method_signature: PatchReaderTest.testReadPatchApplyPlan_CorruptIdentifier()
test_case.full_signature: @Test(expected = PatchFormatException.class) public void testReadPatchApplyPlan_CorruptIdentifier()
test_case.identifier: testReadPatchApplyPlan_CorruptIdentifier
test_case.invocations: readPatchApplyPlan writeTestPatch
test_case.modifiers: @Test(expected = PatchFormatException.class) public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testReadPatchApplyPlan_CorruptIdentifier()
focal_class.file: feya/libraries/archive_diff/diff.applier/src/main/java/com/google/archivepatcher/applier/PatchReader.java
focal_class.identifier: PatchReader
focal_class.class_method_signature: PatchReader.readPatchApplyPlan(InputStream in)
focal_class.full_signature: public PatchApplyPlan readPatchApplyPlan(InputStream in)
focal_class.identifier: readPatchApplyPlan
focal_class.modifiers: public
focal_class.parameters: (InputStream in)
focal_class.return: PatchApplyPlan
focal_class.signature: PatchApplyPlan readPatchApplyPlan(InputStream in)
focal_class.class_method_signature: PatchReader.checkNonNegative(long value, String description)
focal_class.full_signature: private static final long checkNonNegative(long value, String description)
focal_class.identifier: checkNonNegative
focal_class.modifiers: private static final
focal_class.parameters: (long value, String description)
focal_class.return: long
focal_class.signature: long checkNonNegative(long value, String description)
focal_class.class_method_signature: PatchReader.checkRange(long value, long min, long max, String description)
focal_class.full_signature: private static final long checkRange(long value, long min, long max, String description)
focal_class.identifier: checkRange
focal_class.modifiers: private static final
focal_class.parameters: (long value, long min, long max, String description)
focal_class.return: long
focal_class.signature: long checkRange(long value, long min, long max, String description)
focal_method.body: public PatchApplyPlan readPatchApplyPlan(InputStream in) throws IOException {
      // Use DataOutputStream for ease of writing. This is deliberately left open, as closing it would
      // close the output stream that was passed in and that is not part of the method's documented
      // behavior.
      @SuppressWarnings("resource")
      DataInputStream dataIn = new DataInputStream(in);
  
      // Read header and flags.
      byte[] expectedIdentifier = PatchConstants.IDENTIFIER.getBytes("US-ASCII");
      byte[] actualIdentifier = new byte[expectedIdentifier.length];
      dataIn.readFully(actualIdentifier);
      if (!Arrays.equals(expectedIdentifier, actualIdentifier)) {
        throw new PatchFormatException("Bad identifier");
      }
      dataIn.skip(4); // Flags (ignored in v1)
      long deltaFriendlyOldFileSize = checkNonNegative(
          dataIn.readLong(), "delta-friendly old file size");
  
      // Read old file uncompression instructions.
      int numOldFileUncompressionInstructions = (int) checkNonNegative(
          dataIn.readInt(), "old file uncompression instruction count");
      List<TypedRange<Void>> oldFileUncompressionPlan =
          new ArrayList<TypedRange<Void>>(numOldFileUncompressionInstructions);
      long lastReadOffset = -1;
      for (int x = 0; x < numOldFileUncompressionInstructions; x++) {
        long offset = checkNonNegative(dataIn.readLong(), "old file uncompression range offset");
        long length = checkNonNegative(dataIn.readLong(), "old file uncompression range length");
        if (offset < lastReadOffset) {
          throw new PatchFormatException("old file uncompression ranges out of order or overlapping");
        }
        TypedRange<Void> range = new TypedRange<Void>(offset, length, null);
        oldFileUncompressionPlan.add(range);
        lastReadOffset = offset + length; // To check that the next range starts after the current one
      }
  
      // Read new file recompression instructions
      int numDeltaFriendlyNewFileRecompressionInstructions = dataIn.readInt();
      checkNonNegative(
          numDeltaFriendlyNewFileRecompressionInstructions,
          "delta-friendly new file recompression instruction count");
      List<TypedRange<JreDeflateParameters>> deltaFriendlyNewFileRecompressionPlan =
          new ArrayList<TypedRange<JreDeflateParameters>>(
              numDeltaFriendlyNewFileRecompressionInstructions);
      lastReadOffset = -1;
      for (int x = 0; x < numDeltaFriendlyNewFileRecompressionInstructions; x++) {
        long offset = checkNonNegative(
            dataIn.readLong(), "delta-friendly new file recompression range offset");
        long length = checkNonNegative(
            dataIn.readLong(), "delta-friendly new file recompression range length");
        if (offset < lastReadOffset) {
          throw new PatchFormatException(
              "delta-friendly new file recompression ranges out of order or overlapping");
        }
        lastReadOffset = offset + length; // To check that the next range starts after the current one
  
        // Read the JreDeflateParameters
        // Note that v1 only supports the default deflate compatibility window.
        checkRange(
            dataIn.readByte(),
            PatchConstants.CompatibilityWindowId.DEFAULT_DEFLATE.patchValue,
            PatchConstants.CompatibilityWindowId.DEFAULT_DEFLATE.patchValue,
            "compatibility window id");
        int level = (int) checkRange(dataIn.readUnsignedByte(), 1, 9, "recompression level");
        int strategy = (int) checkRange(dataIn.readUnsignedByte(), 0, 2, "recompression strategy");
        int nowrapInt = (int) checkRange(dataIn.readUnsignedByte(), 0, 1, "recompression nowrap");
        TypedRange<JreDeflateParameters> range =
            new TypedRange<JreDeflateParameters>(
                offset,
                length,
                JreDeflateParameters.of(level, strategy, nowrapInt == 0 ? false : true));
        deltaFriendlyNewFileRecompressionPlan.add(range);
      }
  
      // Read the delta metadata, but stop before the first byte of the actual delta.
      // V1 has exactly one delta and it must be bsdiff.
      int numDeltaRecords = (int) checkRange(dataIn.readInt(), 1, 1, "num delta records");
  
      List<DeltaDescriptor> deltaDescriptors = new ArrayList<DeltaDescriptor>(numDeltaRecords);
      for (int x = 0; x < numDeltaRecords; x++) {
        byte deltaFormatByte = (byte)
        checkRange(
            dataIn.readByte(),
            PatchConstants.DeltaFormat.BSDIFF.patchValue,
            PatchConstants.DeltaFormat.BSDIFF.patchValue,
            "delta format");
        long deltaFriendlyOldFileWorkRangeOffset = checkNonNegative(
            dataIn.readLong(), "delta-friendly old file work range offset");
        long deltaFriendlyOldFileWorkRangeLength = checkNonNegative(
            dataIn.readLong(), "delta-friendly old file work range length");
        long deltaFriendlyNewFileWorkRangeOffset = checkNonNegative(
            dataIn.readLong(), "delta-friendly new file work range offset");
        long deltaFriendlyNewFileWorkRangeLength = checkNonNegative(
            dataIn.readLong(), "delta-friendly new file work range length");
        long deltaLength = checkNonNegative(dataIn.readLong(), "delta length");
        DeltaDescriptor descriptor =
            new DeltaDescriptor(
                PatchConstants.DeltaFormat.fromPatchValue(deltaFormatByte),
                new TypedRange<Void>(
                    deltaFriendlyOldFileWorkRangeOffset, deltaFriendlyOldFileWorkRangeLength, null),
                new TypedRange<Void>(
                    deltaFriendlyNewFileWorkRangeOffset, deltaFriendlyNewFileWorkRangeLength, null),
                deltaLength);
        deltaDescriptors.add(descriptor);
      }
  
      return new PatchApplyPlan(
          Collections.unmodifiableList(oldFileUncompressionPlan),
          deltaFriendlyOldFileSize,
          Collections.unmodifiableList(deltaFriendlyNewFileRecompressionPlan),
          Collections.unmodifiableList(deltaDescriptors));
    }
focal_method.class_method_signature: PatchReader.readPatchApplyPlan(InputStream in)
focal_method.full_signature: public PatchApplyPlan readPatchApplyPlan(InputStream in)
focal_method.identifier: readPatchApplyPlan
focal_method.invocations: getBytes readFully equals skip checkNonNegative readLong checkNonNegative readInt checkNonNegative readLong checkNonNegative readLong add readInt checkNonNegative checkNonNegative readLong checkNonNegative readLong checkRange readByte checkRange readUnsignedByte checkRange readUnsignedByte checkRange readUnsignedByte of add checkRange readInt checkRange readByte checkNonNegative readLong checkNonNegative readLong checkNonNegative readLong checkNonNegative readLong checkNonNegative readLong fromPatchValue add unmodifiableList unmodifiableList unmodifiableList
focal_method.modifiers: public
focal_method.parameters: (InputStream in)
focal_method.return: PatchApplyPlan
focal_method.signature: PatchApplyPlan readPatchApplyPlan(InputStream in)