Hi Geeks

Right now I ecounter another problem with XDoclet as we use it.
It does not generate the CMP classes correctly.

Note: the version we are using right now is not an offical version
but one between 1.1.2 and the current CVS Head which makes
it very difficult to use because there is not update to date DOCU
(@#$!).

I tried to use the CVS Head but it seems you have to use Ant
1.5 (alpha) which was not working for me.

Andy

> In looking at a CMP cache bug report, it is another instance of an
> xdoclet generated key screwing up the hashCode implementation.
> Here is the generated key:
>
> /*
>  * Generated file - Do not edit!
>  */
> package com.lombardrisk.scratch;
>
> import java.lang.*;
> import java.util.Collection;
> import java.util.Iterator;
> import javax.ejb.CreateException;
> import javax.ejb.EntityBean;
> import com.lombardrisk.common.ServiceLocations;
> import org.apache.log4j.Category;
>
> /**
>  * Primary key for ScratchEntity.
>  * @ejb-pk
>
>  * @xdoclet-generated at 02-May-02 14:41:41
>  */
> public class ScratchEntityKey
>    extends java.lang.Object
>    implements java.io.Serializable
> {
>    static final long serialVersionUID = 3511574961442126022L;
>    transient private int _hashCode = Integer.MIN_VALUE;
>    transient private String value = null;
>
>    public long id;
>
>    public ScratchEntityKey()
>    {
>    }
>
>    public ScratchEntityKey( long id )
>    {
>       this.id = id;
>    }
>
>    public long getId()
>    {
>       return id;
>    }
>
>    public void setId(long id)
>    {
>       this.id = id;
>    }
>
>    public int hashCode()
>    {
>       if( _hashCode == Integer.MIN_VALUE )
>       {
>          _hashCode += (int)this.id;
>       }
>
>       return _hashCode;
>    }
>
>    public boolean equals(Object obj)
>    {
>       if( !(obj instanceof com.lombardrisk.scratch.ScratchEntityKey) )
>          return false;
>
>       com.lombardrisk.scratch.ScratchEntityKey pk =
> (com.lombardrisk.scratch.Scr
> atchEntityKey)obj;
>       boolean eq = true;
>
>       if( obj == null )
>       {
>          eq = false;
>       }
>       else
>       {
>          eq = eq && this.id == pk.id;
>       }
>
>       return eq;
>    }
>
>    public String toString()
>    {
>       if( value == null )
>       {
>          value = "[.";
>          value += this.id+".";
>          value += "]";
>       }
>
>       return value;
>    }
> }
>
> The problem is the construct used to initialize and cache the hashCode
> value.
> Here is a trival program that demonstrates the problem:
>
> import java.rmi.MarshalledObject;
> import com.lombardrisk.scratch.ScratchEntityKey;
>
> public class TstKey
> {
>    public static void main(String[] args) throws Exception
>    {
>       ScratchEntityKey pk1 = new ScratchEntityKey(1);
>       System.out.println("Integer.MIN_VALUE="+Integer.MIN_VALUE);
>       System.out.println("pk1.hashCode="+pk1.hashCode());
>       MarshalledObject mo = new MarshalledObject(pk1);
>       ScratchEntityKey pk2 = (ScratchEntityKey) mo.get();
>       System.out.println("pk2.hashCode="+pk2.hashCode());
>    }
> }
>
> Which when runs, shows that the unserialized object pk2
> has a hashCode of 0:
>
> Integer.MIN_VALUE=-2147483648
> pk1.hashCode=-2147483647
> pk2.hashCode=0
>
> So the unserialized pk1 value has a hashCode of 0 != -2147483647.
> Its Serializable 101 stuff that default serialization does not
> execute the default constructor and member intializations
> during deserialization. Is xdoclet still generating this invalid
> construct?
>
> xxxxxxxxxxxxxxxxxxxxxxxx
> Scott Stark
> Chief Technology Officer
> JBoss Group, LLC
> xxxxxxxxxxxxxxxxxxxxxxxx
>
>
> _______________________________________________________________
>
> Have big pipes? SourceForge.net is looking for download mirrors. We supply
> the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
> _______________________________________________
> Jboss-development mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-development
>
>



_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to