Exemplo n.º 1
0
  static void failEventForInstrumentation(EventBinding<?> b, String eventName, Throwable t) {
    assert !b.isLanguageBinding();
    InstrumentationInstrumenter instrumentationInstrumenter =
        (InstrumentationInstrumenter) b.getInstrumenter();
    Class<?> instrumentationClass = instrumentationInstrumenter.getInstrumentationClass();

    String message =
        String.format(
            "Event %s failed for instrumentation class %s and listener/factory %s.", //
            eventName, instrumentationClass.getName(), b.getElement());

    Exception exception = new Exception(message, t);
    PrintStream stream = new PrintStream(instrumentationInstrumenter.getEnv().err());
    exception.printStackTrace(stream);
  }
Exemplo n.º 2
0
 ProbeNode.EventChainNode createEventChainCallback(EventBinding<?> binding) {
   ProbeNode.EventChainNode next;
   Object element = binding.getElement();
   if (element instanceof EventListener) {
     next = new EventFilterChainNode(binding, (EventListener) element);
   } else {
     assert element instanceof EventNodeFactory;
     EventNode eventNode = createEventNode(binding, element);
     if (eventNode == null) {
       // error occured creating the event node
       return null;
     }
     next = new EventProviderChainNode(binding, eventNode);
   }
   return next;
 }
Exemplo n.º 3
0
 final void onReturnExceptional(EventContext context, VirtualFrame frame, Throwable exception) {
   try {
     innerOnReturnExceptional(context, frame, exception);
   } catch (Throwable t) {
     if (!seenException) {
       CompilerDirectives.transferToInterpreterAndInvalidate();
       seenException = true;
     }
     if (binding.isLanguageBinding()) {
       exception.addSuppressed(t);
     } else {
       CompilerDirectives.transferToInterpreter();
       failEventForInstrumentation(binding, "onReturnExceptional", t);
     }
   }
   if (next != null) {
     next.onReturnExceptional(context, frame, exception);
   }
 }
Exemplo n.º 4
0
 final void onDispose(EventContext context, VirtualFrame frame) {
   try {
     innerOnDispose(context, frame);
   } catch (Throwable t) {
     if (!seenException) {
       CompilerDirectives.transferToInterpreterAndInvalidate();
       seenException = true;
     }
     if (binding.isLanguageBinding()) {
       throw t;
     } else {
       CompilerDirectives.transferToInterpreter();
       failEventForInstrumentation(binding, "onEnter", t);
     }
   }
   if (next != null) {
     next.onDispose(context, frame);
   }
 }
Exemplo n.º 5
0
 private EventNode createEventNode(EventBinding<?> binding, Object element) {
   EventNode eventNode;
   try {
     eventNode = ((EventNodeFactory) element).create(context);
     if (eventNode.getParent() != null) {
       throw new IllegalStateException(
           String.format("Returned EventNode %s was already adopted by another AST.", eventNode));
     }
   } catch (Throwable t) {
     if (binding.isLanguageBinding()) {
       /* Language bindings can just throw exceptions directly into the AST. */
       throw t;
     } else {
       /* Where as instrumentations are not allowed to do that. */
       failEventForInstrumentation(binding, "ProbeNodeFactory.create", t);
       return null;
     }
   }
   return eventNode;
 }