Hi again,
 
Apologies for posting again - I'm going to post this then shutup until you guys get a change to reply.
 
I'm using castor 0.9.5, with org.exolab.castor.builder.javaclassmapping=type
 
Seems to me that the code generated by SourceGenerator for the equals() method is incorrect for primitive types.  For each primitive field, it generates code like ....
 
           if (this._x != temp._x)
                return false;
            if (this._has_x != temp._has_x)
                return false;
 
I'd suggest that if the fields _has_x are both false, then the value of the _x field is immaterial.  I've had a look at SourceFactor.createEqualsMethod(), where there is comment about handling nulls for non-primitives.  Seems to me that the same is true for the primitive fields through the _has flags.
 
Correct code could possibly be:
 
            if (this._has_x != temp._has_x)
                return false;
           if (this._has_x && this._x != temp._x)
                return false;
This is easy enough to do, provided I can tell the difference between the _has field and real boolean fields.  Looking at JField, seems I can only do this by the name, which seems a bit dodgy.
 
 
BTW: with org.exolab.castor.builder.javaclassmapping=element, I get an equals method that looks like:
 
    public boolean equals(java.lang.Object obj)
    {
        if ( this == obj )
            return true;
       
        if (super.equals(obj)==false)
            return false;
       
        if (obj instanceof Point) {
       
            Point temp = (Point)obj;
            return true;
        }
        return false;
    } //-- boolean equals(java.lang.Object)
 
This seems basically broken too, as there is no reference made to the temp variable!!!!
 
 
Regards and thanks
Dean
 
 
intelli WHERE www.intelliwhere.com

Dr. Dean Chalker 
Senior Architect
[EMAIL PROTECTED]

IntelliWhere Division,  Intergraph Corporation
Australia

Phone: 61-7-3510 8918 
Fax: 61-7-3510 8901 
 
 
 

Reply via email to