Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: X10 2.2
-
Fix Version/s: X10 2.2.2
-
Component/s: XRX Runtime
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
Description
.
=======================================================================
DEFECT ABSTRACT : Class x10.util.Option - equals() and _struct_equals()
AFFECTED TEST CASES :
DRIVER : /X10/drivers/sles11/220/110620
Checked out revision 22251
COMPILE MACHINE DETAILS
LINUX : SUSE Linux Enterprise Server 11 SP1 [V11.SP1] - 2.6.32.12-0.7-ppc64 #1 SMP 2010-05-20 11:14:20 +0200
HOST : swgc155 83528 MB 8 CPU(s) POWER5+ (gs) Model: CHRP IBM,9119-595 [SMP 64BIT ]
========================================================================
PROBLEM DESCRIPTION
------------------------------------------------------------------------
When compare instance of x10.util.Option class with another one with same
values with equals() or _struct_equals() methods - it returns false.
Same if compare with strings equal to its short_ or long_ fields (in the
example with "m" or "-mode")
=======================================================================
SOURCE FILE: t.x10
-----------------------------------------------------------------------
import x10.util.*;
import x10.io.Console;
public class t {
public def run(): Boolean =
public static def main(var args: Array[String](1)): void =
{ new t().run(); }}
=======================================================================
Problem Reproductionand actual output: - run the script below
-----------------------------------------------------------------------
#!/usr/bin/ksh
#
export "LANG=en_US"
export "MP_MSG_API=lapi"
export "JAVA_HOME=/opt/ibm/java-ppc-60"
export "MP_PROCS=4"
#
echo Step 1:X10_COMPLINK
/X10/drivers/sles11/220/110620/bin/x10c++ -VERBOSE_CHECKS=true -STATIC_CHECKS=true -sourcepath /X10/t220/lib -o t t.x10 -x10rt pgas_lapi
echo Return code: $?
echo Step 2:RUN
./t
echo Return code: $?
=======================================================================
ACTUAL OUTPUT:
-----------------------------------------------------------------------
Step 1:X10_COMPLINK
Return code: 0
Step 2:RUN
[1a] :My test M option
[ eq] :false
[ eq] :false :false :false
[ eq] :false :false :false
[seq] :false
[seq] :false :false :false
[seq] :false :false :false
[ eq] :true
[seq] :true
Return code: 0
=======================================================================
ExPECTED OUTPUT:
-----------------------------------------------------------------------
Step 1:X10_COMPLINK
Return code: 0
Step 2:RUN
[1a] :My test M option
[ eq] :true
[ eq] :false :false :true
[ eq] :false :false :true
[seq] :true
[seq] :false :false :true
[seq] :false :false :true
[ eq] :true
[seq] :true
Return code: 0
=======================================================================
Activity
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | X10 2.2.1 [ 17131 ] |
| Fix Version/s | X10 2.2.2 [ 17639 ] | |
| Fix Version/s | X10 2.2.1 [ 17131 ] |
| Assignee | Olivier Tardieu [ tardieu ] | David Grove [ dgrove ] |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] |
| Status | Resolved [ 5 ] | Closed [ 6 ] |
The default equals/== method for a struct will do == on each of its fields. Since the fields are Strings, this doesn't do what one perhaps might expect.
I think the fix is to define a equals (and probably hashcode) method explictly.