Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-1047

[classlib][math]exception compatibility: new BigInteger(Integer.MAX_VALUE, (Random)null)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • Patch Available

    Description

      Different exception behaviour when create a huge BigInteger.

      Actually it's impossible to create BigInteger with numBits=Integer.MAX_VALUE, but RI throws an Exception while Harmony throws an Error.

      Test --------------------------------------------------------------

      mport java.math.BigInteger;
      import java.util.Random;

      public class bug9282 {
      public static void main(String args[] )

      { new BigInteger(Integer.MAX_VALUE, (Random)null); }


      }

      Output -------------------------------------------------------

      RI
      java.lang.NegativeArraySizeException: Negative size-268435455
      at java.math.BigInteger.randomBits(BigInteger.java:471)
      at java.math.BigInteger.<init>(BigInteger.java:464)
      at bug9282.main(bug9282.java:6)

      Harmony
      java.lang.OutOfMemoryError
      <no stack trace available>

      Attachments

        1. HARMONY-1047.patch
          0.6 kB
          Nellya Udovichenko
        2. HARMONY-1047-test.patch
          0.8 kB
          Nellya Udovichenko

        Issue Links

          Activity

            People

              tellison Tim Ellison
              dkishenko Denis Kishenko
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: