Name: rmT116609 Date: 05/01/2003
A DESCRIPTION OF THE REQUEST :
Add the ability to mark objects where the value ofString.valueOf() would included in any stack trace. In my example below I used "trace". Variables that aren't declared at the point of the stack trace would just be ingored.
JUSTIFICATION :
It would make debugging much easier and make it much easier to write programs that are easy to debug.
EXPECTED VERSUS ACTUAL BEHAVIOR :
java.lang.NullPointerException:
at Test.main(Test.java:7) index=0, sum=3, obj=null
java.lang.NullPointerException:
at Test.main(Engine.java:124)
Or doesn't compile if the "trace" keyword is included.
---------- BEGIN SOURCE ----------
public class Test {
Object obj;
public void main(String[] args) trace obj {
trace int sum = 0;
for(trace int index = 0; index < args.length; index++) {
sum += Integer.parseInt(args[index]);
sum += obj.hashCode();//Will cause NullPointerException
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Catch Throwable and re-throw it with more info. The method would also have to be declared to throw Throwable.
(Review ID: 182848)
======================================================================