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

JCK: invalid optimizations for java.math.BigInteger

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.3.1
    • hotspot
    • x86
    • generic, linux



      Name: asR10013 Date: 12/08/2000


          
          The sample code below demonstrates incorrect behavior of method
      gcd(BigInteger val) of class java.math.BigInteger. Test calls
      method 'gcd' with the same argument 1000 times and compares result
      values. With jdk1.3.1-b11 in server mode test reports error.

          The problem is reproducible on all Windows platforms and Linux
      using jdk1.3.1-b11 Server VM mixed and comp mode.
          Due to this bug the following JCK tests fail:
      * api/java_math/BigInteger/index.html#Mod
      * api/java_math/BigInteger/index.html#Conversion

      ---------------------------- test.java -------------------------------
      import java.math.*;

      class test {
          public static void main(String arg[]) throws Exception {
      BigInteger b1, b2,r1,r2;
              b1 = new BigInteger("4857495251917700622069626544940165507318326107275029065226427887152179157410695867164352990853049392980154677179467464264959253875868402179145614765183223333035386422570961312212953787209106291162977315812124382187050108863279392948329049229871503257426368974815540020070314");
      b2 = new BigInteger("5450575449322039263801346436025993354938363692088057065418233409385759157289004729237749485081611715227593918052535576013896876840868593858330523542978142413861130900706469825552782891077926246912078331448994490070819294276235531852154491590621549857809398780956711158457374059323767369195846464308646071676931621333069587931538095038317716541447904777");
      r1 = b2.gcd(b1);
      for (int i=0; i<1000; i++) {
      r2 = r1;
                  r1 = b2.gcd(b1);
      if (!r1.equals(r2)) {
      System.out.println("TEST FAILED! Iteration: "+i);
      }
              }
          }
      }
      ---------------------------- output ----------------------------------
      $ java -server -version
      java version "1.3.1beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1beta-b11)
      Java HotSpot(TM) Server VM (build 1.3.1beta-b11, mixed mode)
      $ java -server -Xfuture test
      TEST FAILED! Iteration: 105
      $ java -server -Xcomp -Xfuture test
      TEST FAILED! Iteration: 36
      ======================================================================

      ======================================================================

            sdeversunw Steve Dever (Inactive)
            alssunw Als Als (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: