This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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).]
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 ...