Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #3878

Re: Avoiding NPEs caused

From "Lew" <lew@THRWHITE.remove-dii-this>
Subject Re: Avoiding NPEs caused
Message-ID <V-ednaFymLYdYAjVnZ2dnUVZ_o-dnZ2d@comcast.com> (permalink)
Newsgroups comp.lang.java.gui
References <13afa58b-569c-4b70-80a5-d5c44182efb7@m73g2000hsh.googlegroups.co
Date 2011-04-27 15:47 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.programmer
Royan wrote:
> There is not much sense in stack trace, it's classic problem, i'm [sic] only
> looking for the best solution. If stack really matters here's slightly

And I was only asking for enough information so that people can try to help you.

"Classic problems" have classic solutions, such as having enough information 
to solve the "classic problem", say by examining the error message for clues. 
  Just for example.

> improved example that you can even run yourself and stack trace:

Now that is an SSCCE, thank you.  "Can even run yourself" is the minimum, not 
some generous bonus.

The whole stack trace is not necessary, nor was it what I asked for:
>> ... (copy and paste) the exception message.

> Exception in thread "main" java.lang.NullPointerException
> 	at test.Model.firePropertyChange(Model.java:20)

Is this line 20?
> propertyChangeSupport.firePropertyChange(propertyName,
> oldValue, newValue);

Which one is null, 'propertyChangeSupport', 'propertyName', 'oldValue' or 
'newValue'?

Have you run this in a debugger?

You will note that you are running an overridden method from the superclass 
constructor, always a no-no.  The constructor for the subclass has not yet 
run, so nothing is initialized.

Do not run overridable methods from a constructor.

-- 
Lew
There are two questions for you in this post.  One indication of whether you 
have answered them is whether you have provided two answers.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | Next | Find similar | Unroll thread


Thread

Re: Avoiding NPEs caused "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000

csiph-web