Пример #1
0
  public void exceptionEvent(ExceptionEvent event) {
    ObjectReference or = event.exception();
    ReferenceType rt = or.referenceType();
    String exceptionName = rt.name();
    // Field messageField = Throwable.class.getField("detailMessage");
    Field messageField = rt.fieldByName("detailMessage");
    //    System.out.println("field " + messageField);
    Value messageValue = or.getValue(messageField);
    //    System.out.println("mess val " + messageValue);

    // "java.lang.ArrayIndexOutOfBoundsException"
    int last = exceptionName.lastIndexOf('.');
    String message = exceptionName.substring(last + 1);
    if (messageValue != null) {
      String messageStr = messageValue.toString();
      if (messageStr.startsWith("\"")) {
        messageStr = messageStr.substring(1, messageStr.length() - 1);
      }
      message += ": " + messageStr;
    }
    //    System.out.println("mess type " + messageValue.type());
    // StringReference messageReference = (StringReference) messageValue.type();

    // First just report the exception and its placement
    reportException(message, or, event.thread());
    // Then try to pretty it up with a better message
    handleCommonErrors(exceptionName, message, listener);

    if (editor != null) {
      editor.deactivateRun();
    }
  }
Пример #2
0
 /** ******** test assist ********* */
 Method getMethod(String className, String methodName) {
   List refs = vm().classesByName(className);
   if (refs.size() != 1) {
     failure("Test failure: " + refs.size() + " ReferenceTypes named: " + className);
     return null;
   }
   ReferenceType refType = (ReferenceType) refs.get(0);
   List meths = refType.methodsByName(methodName);
   if (meths.size() != 1) {
     failure("Test failure: " + meths.size() + " methods named: " + methodName);
     return null;
   }
   return (Method) meths.get(0);
 }