Ok, no problem.

I'll give that a try and, if there are no side effects, I'll assume that
this is the "right" thing to do and provide a patch.

However, somebody such as you with a deeper knowledge of the system
internals may want to take a look anyway to make sure that this is the right
approach. So, I'll flag this in Bugzilla for follow up.


Regards,
Dave



> -----Original Message-----
> From: Keith Visco [mailto:[EMAIL PROTECTED]
> Sent: 5 November 2004 5:16
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-user] [XML] NullPointerException when a
> class overrides parent class
>
>
>
> Hi David,
>
> For now, can you wrap the localElements[i].getValidator() in a null check:
>
> if (localElements[i] != null) {
>
> }
>
> --Keith
>
> David Leangen wrote:
> >
> > Dear List,
> >
> > I am having a problem with a NullPointerException with a very
> specific case.
> >
> > I have two classes that are pure value objects, one overriding
> the other.
> > Generally:
> >
> > public class ParentClass
> > {
> >   public int id;
> >
> >   public void setId(int id)
> >   {
> >     this.id = id;
> >   }
> >
> >   public int getId()
> >   {
> >     return id;
> >   }
> > }
> >
> > and
> >
> > public class ChildClass extends ParentClass
> > {
> >   public void setId(int id)
> >   {
> >     this.id = id;
> >   }
> >
> >   public int getId()
> >   {
> >     return id;
> >   }
> > }
> >
> >
> > The NPE occurs during unmarshalling.
> >
> >
> > Note that if I take out the overriding getters and setters, the
> problem goes
> > away. I can still unmarshall the id value from the parent class
> in the child
> > class. It is only when I override the getters and setters that
> this problem
> > occurs.
> >
> >
> >
> > I traced the problem to this line in XMLClassDescriptorImpl:
> >
> >   Line 891:
> >     FieldValidator fieldValidator = localElements[i].getValidator();
> >
> >
> > Each of the local elements that is overridden becomes null, so calling
> > getValidator throws a NPE.
> >
> >
> >
> > Note that the same NPE happens when I override other values, too.
> >
> >
> > Any ideas about how to work around the problem?
> >
> >
> > Thanks!
> > Dave
> >
> >
> >
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> >         unsubscribe castor-user
> >
>
>
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to