diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TBitSet.java b/classlib/src/main/java/org/teavm/classlib/java/util/TBitSet.java index 41202ae44..03076c117 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TBitSet.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TBitSet.java @@ -169,6 +169,9 @@ public class TBitSet extends TObject implements TCloneable, TSerializable { if (fromIndex > toIndex) { throw new TIndexOutOfBoundsException(); } + if (fromIndex == toIndex) { + return; + } int fromDataIndex = fromIndex / 32; int toDataIndex = toIndex / 32; if (toIndex > length) { @@ -224,6 +227,9 @@ public class TBitSet extends TObject implements TCloneable, TSerializable { return; } toIndex = TMath.min(length, toIndex); + if (fromIndex == toIndex) { + return; + } int fromDataIndex = fromIndex / 32; int toDataIndex = toIndex / 32; if (fromDataIndex == toDataIndex) { diff --git a/tests/src/test/java/org/teavm/classlib/java/util/BitSetTest.java b/tests/src/test/java/org/teavm/classlib/java/util/BitSetTest.java index a2067a29a..87c94ff78 100644 --- a/tests/src/test/java/org/teavm/classlib/java/util/BitSetTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/util/BitSetTest.java @@ -878,6 +878,9 @@ public class BitSetTest { bs.set(2, 2); assertFalse("Bit got set incorrectly ", bs.get(2)); + + bs = new BitSet(); + bs.set(0, 0); } @Test