本文整理汇总了Java中gov.nasa.jpf.JPF.getLastError方法的典型用法代码示例。如果您正苦于以下问题:Java JPF.getLastError方法的具体用法?Java JPF.getLastError怎么用?Java JPF.getLastError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gov.nasa.jpf.JPF
的用法示例。
在下文中一共展示了JPF.getLastError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unhandledException
import gov.nasa.jpf.JPF; //导入方法依赖的package包/类
/**
* NOTE: this uses the exception class name because it might be an
* exception type that is only known to JPF (i.e. not in the native classpath)
*
* @param xClassName name of the exception base type that is expected
* @param details detail message of the expected exception
* @param args JPF arguments
*/
protected JPF unhandledException (StackTraceElement testMethod, String xClassName, String details, String... args) {
JPF jpf = null;
report(args);
try {
jpf = createAndRunJPF(testMethod, args);
} catch (Throwable t) {
t.printStackTrace();
fail("JPF internal exception executing: ", args, t.toString());
return jpf;
}
Error error = jpf.getLastError();
if (error != null){
Property errorProperty = error.getProperty();
if (errorProperty instanceof NoUncaughtExceptionsProperty){
ExceptionInfo xi = ((NoUncaughtExceptionsProperty)errorProperty).getUncaughtExceptionInfo();
String xn = xi.getExceptionClassname();
if (!xn.equals(xClassName)) {
fail("JPF caught wrong exception: " + xn + ", expected: " + xClassName);
}
if (details != null) {
String gotDetails = xi.getDetails();
if (gotDetails == null) {
fail("JPF caught the right exception but no details, expected: " + details);
} else {
if (!gotDetails.endsWith(details)) {
fail("JPF caught the right exception but the details were wrong: " + gotDetails + ", expected: " + details);
}
}
}
} else { // error not a NoUncaughtExceptionsProperty
fail("JPF failed to catch exception executing: ", args, ("expected " + xClassName));
}
} else { // no error
fail("JPF failed to catch exception executing: ", args, ("expected " + xClassName));
}
return jpf;
}