classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why catch (NullPointerException e)?


From: Ian Rogers
Subject: Re: Why catch (NullPointerException e)?
Date: Tue, 26 Sep 2000 14:32:26 +0100

Hi Igor,

>  ---- you wrote:
> > I agree, however, the explicit null check will slow down the execution
> > speed of applets.
> 
> Why? In case of a JIT or compiled Java for applets "if (sm != null)" will be 
> branch predicted and cause no harm at all. Moreover, AFAIK try/catch in 
> general produce more code and even if it is never executed it still can cause 
> more processor cache misses.

Hmm.. there are a lot of assumptions going on here. You are assuming a
JIT, branch prediction and exception models working in certain ways. I
have no problem with this and what you are saying, but it should be born
in mind that these are assumptions. From a JVM performance view the "3)
initialise sm to a default_sm object" scheme seems the best to me (from
my knowledge of the VMs I've worked on), but this is subjective and it
certainly doesn't make it the best choice. If the code were clearer with
the other 2 schemes then that would be an equally compelling reason to
choose them.

Cheers, Ian

------------------------------------------------------
Get the Latest News at the BBC: http://news.bbc.co.uk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]