think about NullPointerException as a dereferencing exception.  you get
one of these /only/ when you try to actually /use/ a reference that is
null but cannot be.  this, in general, means that the vm or native code of 
some kind is being asked to /do/ something with a null reference.

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/NullPointerException.html 

it's important to understand the comment at the bottom of this javadoc,
where it says:

"Applications should throw instances of this class to indicate other 
illegal uses of the null object"

the key word here is "uses".  it is not illegal to /use/ the null object 
as a parameter to a method.  therefore, passing null in itself should 
never result in a NullPointerException.  it's only when the null object is 
/used/ (dereferenced in some way) that the NPE should be thrown.

On Fri, 7 Jan 2005, Jonathan Locke wrote:

> 
> we should not be throwing NullPointerExceptions.  the right JDK exception
> for this would be IllegalArgumentException.  only the VM should throw
> NullPointerExceptions.
> 
> On Fri, 7 Jan 2005, Juergen Donnerstag wrote:
> 
> > This is the original code, which did work: class PropertyModel
> > 
> > public PropertyModel(final IModel model, final String expression,
> > boolean applyFormatting)
> > {
> >         super(null);
> > 
> >         if (model == null)
> >         {
> >             throw new NullPointerException("Parameter 'model' must not be 
> > null");
> >         }
> >         
> >         this.model = model;
> >         this.expression = expression;
> >         this.applyFormatting = applyFormatting;
> > }
> > 
> > and this is the new one
> > 
> >     public PropertyModel(final IModel model, final String expression)
> >     {
> >         super(null);
> > 
> >         checkModelNotNull(model);
> >         
> >         this.model = model;
> >         this.expression = expression;
> > 
> >         ApplicationSettings settings =
> > RequestCycle.get().getApplication().getSettings();
> >         this.applyFormatting = 
> > settings.isPropertyModelDefaultApplyFormatting();
> >     }
> > 
> > 
> > NPE is thrown because RequestCycle.get() returns null. The
> > RequestCycle has not yet been initialized. Though it may be a problem
> > of our unit tests only, I'd still suggest to fix it.
> > 
> > Juergen
> > 
> > 
> > On Fri, 7 Jan 2005 20:24:01 +0100, Juergen Donnerstag
> > <[EMAIL PROTECTED]> wrote:
> > > Hi,
> > > 
> > > after modifying the MarkupParser javadoc (and committing it), run
> > > maven jar on wicket core and I was surprised that it failed. I thought
> > > I made the mistake while changeing the javadoc, but after debugging
> > > the problem I not sure. The problem is that RequesrCycle.get() returns
> > > null and throws a NPE in cases where it didn't happen before. Any idea
> > > what about cause?
> > > 
> > > Juergen
> > >
> > 
> > 
> > -------------------------------------------------------
> > The SF.Net email is sponsored by: Beat the post-holiday blues
> > Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
> > It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
> > _______________________________________________
> > Wicket-develop mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/wicket-develop
> > 
> 
> 
> 
> -------------------------------------------------------
> The SF.Net email is sponsored by: Beat the post-holiday blues
> Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
> It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
> _______________________________________________
> Wicket-develop mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-develop
> 



-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to