Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6371401

java.math.BigInteger.shift(Integer.MIN_VALUE) throws StackOverflowError

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 7
    • 5.0, 6
    • core-libs
    • b77
    • x86
    • linux

    Description

      FULL PRODUCT VERSION :
      java version "1.5.0_05"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      2.6.11-6mdk #1 Tue Mar 22 16:04:32 CET 2005 i686 Intel(R) Pentium(R) 4 CPU 2.26GHz unknown GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      If you shift a BigInteger by Integer.MIN_VALUE, it throws StackOverflowError (probably because Integer.MIN_VALUE == -Integer.MIN_VALUE

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      BigInteger.ONE.shiftRight(Intger.MIN_VALUE)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      BigInteger.ZERO
      ACTUAL -
      an Error: StackOverflowError

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.math.BigInteger;
      public class BugShift{
          public static void main(String[] args){
              System.out.println(BigInteger.ONE.shiftRight(Integer.MIN_VALUE));
          }
      }
      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              darcy Joe Darcy
              rmandalasunw Ranjith Mandala (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: