java.lang.IndexOutOfBoundsException: fromIndex < 0: -2147483648

JDK Bug System | Webbug Group | 6 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    FULL PRODUCT VERSION : java version "1.8.0_101" Java(TM) SE Runtime Environment (build 1.8.0_101-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode) ADDITIONAL OS VERSION INFORMATION : Linux 4.2.0-42-generic #49-Ubuntu SMP Tue Jun 28 21:26:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux A DESCRIPTION OF THE PROBLEM : If a BitSet contains the bit Integer.MAX_VALUE, the stream iterator throws an IndexOutOfBoundsException exception after visiting this bit STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : use a stream iterator on a bitset with bit Integer.MAX_VALUE set and call the stream iterator EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - the iterator should not throw any exception at all ACTUAL - the iterator throws an IndexOutOfBoundsException ERROR MESSAGES/STACK TRACES THAT OCCUR : java.lang.IndexOutOfBoundsException: fromIndex < 0: -2147483648 at java.util.BitSet.nextSetBit(BitSet.java:712) at java.util.BitSet$1BitSetIterator.nextInt(BitSet.java:1232) at java.util.PrimitiveIterator$OfInt.forEachRemaining(PrimitiveIterator.java:115) at java.util.Spliterators$IntIteratorSpliterator.forEachRemaining(Spliterators.java:1908) at java.util.stream.IntPipeline$Head.forEach(IntPipeline.java:557) at me.pg.GeneratedRegressionTest.testBitSet(GeneratedRegressionTest.java:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.util.BitSet; import org.junit.Test; public class BitSetTest { @Test public void testStreamIteratorNext() { BitSet bs = new BitSet(Integer.MAX_VALUE); bs.set(Integer.MAX_VALUE); bs.stream().iterator().next(); } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Test if a given BitSet contains the bit Integer.MAX_VALUE. eg: if (Integer.MAX_VALUE == bs.length()) { bs.clear(Integer.MAX_VALUE); bs.stream().forEach(lambda); lambda.accept(Integer.MAX_VALUE); bs.set(Integer.MAX_VALUE); } else { bs.stream().forEach(lambda); }

    JDK Bug System | 6 months ago | Webbug Group
    java.lang.IndexOutOfBoundsException: fromIndex < 0: -2147483648

    Root Cause Analysis

    1. java.lang.IndexOutOfBoundsException

      fromIndex < 0: -2147483648

      at java.util.BitSet.nextSetBit()
    2. Java RT
      IntPipeline$Head.forEach
      1. java.util.BitSet.nextSetBit(BitSet.java:712)
      2. java.util.BitSet$1BitSetIterator.nextInt(BitSet.java:1232)
      3. java.util.PrimitiveIterator$OfInt.forEachRemaining(PrimitiveIterator.java:115)
      4. java.util.Spliterators$IntIteratorSpliterator.forEachRemaining(Spliterators.java:1908)
      5. java.util.stream.IntPipeline$Head.forEach(IntPipeline.java:557)
      5 frames
    3. me.pg
      GeneratedRegressionTest.testBitSet
      1. me.pg.GeneratedRegressionTest.testBitSet(GeneratedRegressionTest.java:45)
      1 frame
    4. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:498)
      4 frames
    5. JUnit
      ParentRunner.run
      1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      5. org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      6. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      7. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      8. org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      9. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      10. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      11. org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      12. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      13. org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      13 frames
    6. JUnit4 Runner
      JUnit4TestReference.run
      1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      1 frame
    7. JUnit3 Runner
      RemoteTestRunner.main
      1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
      3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
      4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
      5 frames