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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Enhancement of Null Pointer Exception" Watch "Enhancement of Null Pointer Exception" New topic
Author

Enhancement of Null Pointer Exception

Richard Miranda
Greenhorn

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 http://developer.java.sun.com/developer/bugParade/bugs/4438973.html
If you agree with my point please "vote" for this bug, on the given URL.
thanks,
Richard.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4419
    
    5

Richard,
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.
Junilu

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


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

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 frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enhancement of Null Pointer Exception
 
Similar Threads
main has to be in a public class?
roll doesn't work properly
Instance initializers in anonymous class
Resolving most specific method
Exception and Instance Initializer