Harmony
  1. Harmony
  2. HARMONY-1047

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None
    • Patch Info:
      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>

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

        Issue Links

          Activity

          Hide
          Tim Ellison added a comment -

          Verified by Nellya.

          Show
          Tim Ellison added a comment - Verified by Nellya.
          Hide
          Nellya Udovichenko added a comment -

          Verified. All works. Thank you!

          Show
          Nellya Udovichenko added a comment - Verified. All works. Thank you!
          Hide
          Tim Ellison added a comment -

          Thanks Nellya.

          Patch applied to MATH module at repo revision r495643.

          Please verify that is was applied correctly.

          Show
          Tim Ellison added a comment - Thanks Nellya. Patch applied to MATH module at repo revision r495643. Please verify that is was applied correctly.
          Hide
          Nellya Udovichenko added a comment -

          Please, try my patch.

          Show
          Nellya Udovichenko added a comment - Please, try my patch.
          Hide
          Tim Ellison added a comment -

          Nellya, Harmony should throw the same exception in this case.

          Show
          Tim Ellison added a comment - Nellya, Harmony should throw the same exception in this case.
          Hide
          Nellya Udovichenko added a comment -

          I verified this test on the latest Harmony version and got the following results:

          the same one on RI:
          Exception in thread "main" java.lang.NegativeArraySizeException
          at java.math.BigInteger.randomBits(BigInteger.java:471)
          at java.math.BigInteger.<init>(BigInteger.java:464)
          at BigIntegerTest.main(BigIntegerTest.java:6)

          but another one on Harmony:
          Exception in thread "main" java.lang.NullPointerException
          at java.math.BigInteger.<init>(BigInteger.java:98)
          at BigIntegerTest.main(BigIntegerTest.java:6)

          So I think this bug can be closed as 'Won't Fix'.

          Show
          Nellya Udovichenko added a comment - I verified this test on the latest Harmony version and got the following results: the same one on RI: Exception in thread "main" java.lang.NegativeArraySizeException at java.math.BigInteger.randomBits(BigInteger.java:471) at java.math.BigInteger.<init>(BigInteger.java:464) at BigIntegerTest.main(BigIntegerTest.java:6) but another one on Harmony: Exception in thread "main" java.lang.NullPointerException at java.math.BigInteger.<init>(BigInteger.java:98) at BigIntegerTest.main(BigIntegerTest.java:6) So I think this bug can be closed as 'Won't Fix'.
          Hide
          Denis Kishenko added a comment -

          test comment

          Show
          Denis Kishenko added a comment - test comment

            People

            • Assignee:
              Tim Ellison
              Reporter:
              Denis Kishenko
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development