# HG changeset patch # User Artem Tikhomirov # Date 1374526026 -7200 # Node ID f568330dd9c0b916b28a8cafaa41d960d49d4c9b # Parent 4f93bbc73b64b0a3a752dc60a302f62835060908 Compile with Java5, ensure generics are fine for other compilers, too diff -r 4f93bbc73b64 -r f568330dd9c0 src/org/tmatesoft/hg/internal/ArrayHelper.java --- a/src/org/tmatesoft/hg/internal/ArrayHelper.java Sun Jul 21 17:48:05 2013 +0200 +++ b/src/org/tmatesoft/hg/internal/ArrayHelper.java Mon Jul 22 22:47:06 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 TMate Software Ltd + * Copyright (c) 2011-2013 TMate Software Ltd * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -89,7 +89,9 @@ */ public int binarySearchSorted(T value) { if (sorted != null) { - return Arrays.binarySearch(sorted, 0, data.length, value); + int x = Arrays.binarySearch(sorted, value); + // fulfill the Arrays#binarySearch contract in case sorted array is greater than data + return x >= data.length ? -(data.length - 1) : x; } return binarySearchWithReverse(0, data.length, value); } diff -r 4f93bbc73b64 -r f568330dd9c0 src/org/tmatesoft/hg/internal/EncodingHelper.java --- a/src/org/tmatesoft/hg/internal/EncodingHelper.java Sun Jul 21 17:48:05 2013 +0200 +++ b/src/org/tmatesoft/hg/internal/EncodingHelper.java Mon Jul 22 22:47:06 2013 +0200 @@ -180,7 +180,11 @@ return utfDecoder.decode(ByteBuffer.wrap(data, start, length)).toString(); } catch (CharacterCodingException ex) { // TODO post-1.2 respect ui.fallbackencoding actual setting - return new String(data, start, length, Charset.forName("ISO-8859-1")); + try { + return new String(data, start, length, "ISO-8859-1"); // XXX java5 + } catch (UnsupportedEncodingException e) { + throw new HgInvalidStateException(ex.getMessage()); + } } } diff -r 4f93bbc73b64 -r f568330dd9c0 src/org/tmatesoft/hg/internal/diff/DiffRangeMap.java --- a/src/org/tmatesoft/hg/internal/diff/DiffRangeMap.java Sun Jul 21 17:48:05 2013 +0200 +++ b/src/org/tmatesoft/hg/internal/diff/DiffRangeMap.java Mon Jul 22 22:47:06 2013 +0200 @@ -19,6 +19,7 @@ import java.util.ArrayList; import org.tmatesoft.hg.internal.DiffHelper; +import org.tmatesoft.hg.internal.DiffHelper.MatchInspector; import org.tmatesoft.hg.internal.IntSliceSeq; import org.tmatesoft.hg.internal.IntTuple; import org.tmatesoft.hg.internal.DiffHelper.ChunkSequence; @@ -44,8 +45,11 @@ * dh.findMatchingBlocks(p1ToBase); // compiles ok! * */ + @SuppressWarnings("unchecked") public DiffRangeMap fill(DiffHelper dh) { - dh.findMatchingBlocks(this); + @SuppressWarnings("rawtypes") + final MatchInspector i = (MatchInspector) this; + dh.findMatchingBlocks(i); return this; }