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

JCK: incorrect result of equals() and shift operator for Float and Double

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux, windows_98

      Description


      The following test fails on Linux and Windows while executing against HotSpot Server VM in -Xcomp mode.
      ------------ test.java -----------
      import java.math.*;

      public class test {
       public static void main( String[] args ) {
         double dvalue = 0.0d;
         float fvalue = 0.0f;
         Double x1, y1;
         Float x2, y2;
         if (Double.doubleToLongBits(Math.abs(dvalue)) != ((Double.doubleToLongBits(dvalue)<<1)>>>1)) {
          System.out.println( "Conversation error for Double");
         }
         if (Float.floatToIntBits(Math.abs(fvalue)) != ((Float.floatToIntBits(fvalue)<<1)>>>1)) {
          System.out.println( "Conversation error for Float");
         }

         x1 = new Double(Math.abs(dvalue));
         y1 = new Double(dvalue);
         if (!x1.equals(y1)) {
          System.out.println("Equals error for Double");
         }
         x2 = new Float(Math.abs(fvalue));
         y2 = new Float(fvalue);
         if (!x2.equals(y2)) {
          System.out.println("Equals error for Float");
         }
       }
      }

      ----------------------------------

      Below is output from the test execution:
      -----------------------------------------------------
      %java -server -Xcomp test
      Conversation error for Double
      Conversation error for Float
      Equals error for Double
      Equals error for Float
      %java -server test
      %java -client -Xcomp test
      %java -client test
      %
      -----------------------------------------------------

      The JDK version is:
      java version "1.3.1beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1beta-b08)
      Java HotSpot(TM) Server VM (build 1.3.1beta-b08, compiled mode)

      The test passes in -Xmixed and in -Xint modes against JDK 1.3.1 Server VM; as well as the test passes in all execution modes against the Client VM.
      The test passes against JDK 1.3.1-b07 both Client and Server VMs in all execution modes.

      The following JCK1.3 api tests fail due to this bug against JDK1.3.1beta-b08 HS Server VM in -Xcomp mode:
      api/java_lang/Math/index.html#abs
      api/java_lang/StrictMath/index.html#abs

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rasbold Chuck Rasbold
                Reporter:
                irasunw Ira Ira (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: