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

JDI: an implementation of compareTo() method is not transitive for IntegerValue

XMLWordPrintable

    • tiger
    • generic
    • generic
    • Verified



      Name: dkR10014 Date: 07/30/2002


      ------------------------------------------------------------------------------
      Test : nsk/jdi/IntegerValue/compareTo/compareto001
      Test Base : testbase_nsk
      VM : ServerVM, ClientVM
      Mode : comp, int, mixed
      Platform (s) : solx86, linux, solsparc, win
      OS : 5.8, RH7.2, NT/2000
      JDK : 1.4.0-FCS, 1.4.1-b18
      ------------------------------------------------------------------------------

      The bug is reproduced since Merlin-FCS.
      The test checks whether inherited compareTo(Object o) method of IntegerValue interface
      complies with contract for java.lang.Comparable.compareTo(Object o) method.

      Along with other obligations, an implementation of the method must be transitive
      in compliance of the spec for Comparable.compareTo(Object o) method:
      ...
      The implementor must also ensure that the relation is transitive: (x.compareTo(y)>0 && y.compareTo(z)>0)
      implies x.compareTo(z)>0.
      ...

      Using nsk.jdi.share classes, the debugger connects to the debuggee.
      Then the debugger gets a list of integer fields of debuggee's object of
      compareto001aClassToCheck type. For every field a mirror of IntegerValue type
      is created and the assertions are checked. A various values for comparison
      are got from values of mirrors of debuggee's static fields.

      The test consists of the following files:
              compareto001.java - debugger
              compareto001.javaa.java - debuggee
      and will be available in release r16 of the testbase_nsk.

      Steps to reproduce
      ==================
      1. cd /net/sqesvr.sfbay/export/vsn/GammaBase/Bugs/<BugID>
      2. sh doit.sh $JAVA_HOME

      Test error diagnostics:

      # ERROR: debugger FAILURE > Failed assertion [ if (x.compareTo(y) > 0) and (y.compareTo(z) > 0), then (x.compareTo(z) > 0) ]
      # ERROR: where 'x' is IntegerValue: 2147483647 , 'y' is IntegerValue : 0 , 'z' is IntegerValue : -1
      # ERROR: result of (x.compareTo(y)): 2147483647
      # ERROR: result of (y.compareTo(z)): 1
      # ERROR: result of (x.compareTo(z)): -2147483648
      # ERROR: debugger FAILURE > Failed assertion [ if (x.compareTo(y) > 0) and (y.compareTo(z) > 0), then (x.compareTo(z) > 0) ]
      # ERROR: where 'x' is IntegerValue: 1 , 'y' is IntegerValue : -1 , 'z' is IntegerValue : -2147483648
      # ERROR: result of (x.compareTo(y)): 2
      # ERROR: result of (y.compareTo(z)): 2147483647
      # ERROR: result of (x.compareTo(z)): -2147483647
      # ERROR: debugger FAILURE > Failed assertion [ if (x.compareTo(y) > 0) and (y.compareTo(z) > 0), then (x.compareTo(z) > 0) ]
      # ERROR: where 'x' is IntegerValue: 0 , 'y' is IntegerValue : -1 , 'z' is IntegerValue : -2147483648
      # ERROR: result of (x.compareTo(y)): 1
      # ERROR: result of (y.compareTo(z)): 2147483647
      # ERROR: result of (x.compareTo(z)): -2147483648
      # ERROR: debugger FAILURE > Failed assertion [ if (x.compareTo(y) > 0) and (y.compareTo(z) > 0), then (x.compareTo(z) > 0) ]
      # ERROR: where 'x' is IntegerValue: -1 , 'y' is IntegerValue : -2147483648 , 'z' is IntegerValue : 2147483647
      # ERROR: result of (x.compareTo(y)): 2147483647
      # ERROR: result of (y.compareTo(z)): 1
      # ERROR: result of (x.compareTo(z)): -2147483648
      # ERROR: debugger FAILURE > Failed assertion [ if (x.compareTo(y) > 0) and (y.compareTo(z) > 0), then (x.compareTo(z) > 0) ]
      # ERROR: where 'x' is IntegerValue: -2147483648 , 'y' is IntegerValue : 1 , 'z' is IntegerValue : 0
      # ERROR: result of (x.compareTo(y)): 2147483647
      # ERROR: result of (y.compareTo(z)): 1
      # ERROR: result of (x.compareTo(z)): -2147483648
      exit code = 97

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

            alanb Alan Bateman
            kdossunw Kdos Kdos (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: