Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enhancement of Null Pointer Exception

 
Richard Miranda
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7466
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic