> Tim and others:
>
> What is the overall implication of the following?
>
> Atom cloneAtom() {
> try {
> return (Atom)super.clone();
> } catch (Exception cnse) {
> return null;
> }
> }
>
If any exception is thrown during the super.clone operation then control
will pass to your exception handler.
Clone operations generally are simple. The exception that comes to mind
for me is OutOfMemoryException.
As implemented, all details about the exception will be lost.
Since you are returning null, there is a good chance that the code which
called this will fail at some point later with a NullPointerException.
Many people believe that it is best not to have such broad, all inclusive
exception handlers. They argue that it is better form to explicitly list
out the exceptions that one is expecting to catch.
For this reason, I strongly suspect this code would raise a warning if it
was run through a Java source code verifier ... like PMD or checkstyle.
Broader errors (like OutOfMemoryException) should be allowed to propogate
to a higher level where they can be handled more gracefully .OR. one
should do one's best to handle/remedy the exception, log the exception and
throw it again.
At a minimum, I suggest that the exception be logged so that you can find
out if any exceptions are being triggered in this context.
> That is, IF this error is caught, what happens to the model?
Since I haven't looked at the code in a while I am not sure.
My guess is that the Atom[] gets a null pointer put in it. Later users of
the Atom[] probably are not expecting this condition (unless some type of
DeleteAtom operation was implemented). Therefore, subsequent uses are not
testing for the possibility of having a null. This leads to a
NullPointerException.
Answering a different aspect of the question ... if/when some Exception is
thrown during the super.clone() operation the virtual machine will keep
running just fine. One need not worry about any memory being lost/leaked
or anything like that.
Hope this helps.
Miguel
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers