[jdom-interest] Document getRootElement() problem

Jason Hunter jhunter at acm.org
Wed Jun 14 12:45:37 PDT 2000


> In Document.java I noticed the following:

Since b4 I've fixed the comments to match behavior.  

> Personally, my preference is, from most preferred to least preferred:
> 
> 1. Prevent creation of Document objects with null root elements.

That was our basic plan too.  You must pass in an Element to the
Document constructor, so only if someone explicitly passes null might
you have a problem.  We could do a null check in the constructor, but
since we have the no-arg constructor for special clients to use, we
can't be 100% sure it'll never be null.  Hmm...  In Element we just
don't worry about the no-arg constructor and trust that subclasses do
the right thing (and allow NPEs if they don't).  We could do that here,
checking for null at construction and not at getRootElement() time.  I'm
OK with that.  Opinions?

-jh-



More information about the jdom-interest mailing list