0

I am trying to run JPF and encountered a following null pointer exception.

java.lang.NullPointerException at gov.nasa.jpf.vm.ThreadInfo$StackTraceElement.createJPFStackTraceElement(ThreadInfo.java:1671)

The code that is corresponds to 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();
    }
}
4

1 回答 1

0

有两种方法

  1. 你的代码应该包含空检查,所以首先它会检查值是否为空,然后决定是否执行代码片段。
  2. 或者你可以使用 try catch 块。
于 2014-11-27T09:42:42.200 回答