java - How to bypass null pointer exception?#JPF -
i trying run jpf , encountered following null pointer exception.
java.lang.nullpointerexception @ gov.nasa.jpf.vm.threadinfo$stacktraceelement.createjpfstacktraceelement(threadinfo.java:1671)
the code corresponds is:
int createjpfstacktraceelement() { if (ignore) { return mjienv.null; } else { heap heap = vm.getheap(); classinfo ci = classloaderinfo.getsystemresolvedclassinfo("java.lang.stacktraceelement"); elementinfo ei = heap.newobject(ci, threadinfo.this); ei.setreferencefield("clsname", heap.newstring(clsname, threadinfo.this).getobjectref()); ei.setreferencefield("mthname", heap.newstring(mthname, threadinfo.this).getobjectref()); ei.setreferencefield("filename", heap.newstring(filename, threadinfo.this).getobjectref()); //line 1671 ei.setintfield("line", line); return ei.getobjectref(); } }
there 2 ways
- your code should contain null check, first of check if value null or not decided whether code snippet should execute or not.
- or can use try catch block.
Comments
Post a Comment