aspose file tools
The moose likes Beginning Java and the fly likes Enhancement of Null Pointer Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Enhancement of Null Pointer Exception" Watch "Enhancement of Null Pointer Exception" New topic

Enhancement of Null Pointer Exception

Richard Miranda

Joined: Aug 24, 2000
Posts: 14
Hey Guys,
When a operation is attempted on a variable that is null, the JVM throws a "Null Pointer Exception". The error contains the name of the method which encountered the error. So we have to then find out which variable in this method was null & a operation was attempted on.
It'll be easier for programmers to have the JVM tell them the name of the variable that was null and that caused the error.
I've posted this as a request for 'enhancement' on the Java Bug Parade at
If you agree with my point please "vote" for this bug, on the given URL.
Junilu Lacar

Joined: Feb 26, 2001
Posts: 5880

If I remember what I learned about how compilers work correctly (I've been out of school and in the real world for quite some time now) variable names are merely mnemonics for the programmer: the runtime system really doesn't need them and the names don't make their way into the executable code. Methods are treated different though since there may be a need to bind them dynamically at runtime. When a null pointer exception occurs and the JVM reports only the method name involved, that really is the best it can do.

[This message has been edited by JUNILU LACAR (edited May 09, 2001).]

Junilu - [How to Ask Questions] [How to Answer Questions]
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
The Exception will also contain a stack trace, though, which should tell you exactly which line of code the problem was on. just call e.printStackTrace() to see it all. Are your lines so complex that this doesn't help ? Perhaps this is the time to spread things out a little ...

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
jQuery in Action, 2nd edition
subject: Enhancement of Null Pointer Exception