Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > null pointer exceptions

Reply
Thread Tools

null pointer exceptions

 
 
Tennessee James Leeuwenburg
Guest
Posts: n/a
 
      07-18-2003
It seems to be the case that there are some null pointer exceptions which
Java can handle, but Jython can't. Which doesn't make sense to me, as with
Jython, it is Java which is doing the work.

Are there any good guides to this?

I have a class which includes adding an ImageIcon. If the required graphic
resource isn't present, there is a NullPointerException. Java doesn't care
- the straight Java program handles it internally and gets on with life.
But when I include it from Python, it explodes.

It may be because the resource is specified using a relative pathname.
When Jython executes, it may be not using the current directory as its'
base for relative paths, but could be using JYTHON_HOME, which could lead
to this behaviour.

Can anyone tell me what Jython uses for its' relative path base?
Can anyone describe how Jython handles exceptions that is different from
Java?

Thanks,
-Tennessee
 
Reply With Quote
 
 
 
 
Erik Max Francis
Guest
Posts: n/a
 
      07-18-2003
Tennessee James Leeuwenburg wrote:

> I have a class which includes adding an ImageIcon. If the required
> graphic
> resource isn't present, there is a NullPointerException. Java doesn't
> care
> - the straight Java program handles it internally and gets on with
> life.
> But when I include it from Python, it explodes.


A java.lang.NullPointerException is just an exception like anything
else. Can't you just catch it?

max@oxygen:~/tmp% cat NullCaster.java
import java.lang.*;

public class NullCaster
{
public static void main(String[] args)
{
Object nullObject = null;
String nullString = (String) nullObject;
nullString.length();
}
}
max@oxygen:~/tmp% javac NullCaster.java
max@oxygen:~/tmp% jython
Jython 2.1 on java1.4.1 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> import java.lang
>>> import NullCaster
>>> try:

.... NullCaster.main([])
.... except java.lang.NullPointerException, e:
.... print 'oops:', e
....
oops: java.lang.NullPointerException

--
Erik Max Francis && && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ Wretches hang that jurymen may dine.
\__/ Alexander Pope
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pointer to pointer intialize to NULL but still point to NULL Christopher C++ 4 07-09-2011 12:35 AM
Null pointer (NULL array pointer is passed) aneuryzma C++ 3 06-16-2008 05:48 AM
Null pointer exceptions Alan Java 4 12-28-2007 01:55 PM
beginner question about null pointer exceptions aa Java 4 07-24-2006 09:22 AM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57