jtulach commented on code in PR #9691:
URL: https://github.com/apache/netbeans/pull/9691#discussion_r4261337727


##########
java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/BreakpointOutput.java:
##########
@@ -373,67 +377,99 @@ private String substitute (String printText, 
JPDABreakpointEvent event) {
         }
              
         // 5) resolve all expressions {=expression}
+        printExpressions(event, printText, (msg, action) -> {
+            io.printWithAction(msg, action, false);
+        }, (msg) -> {
+            io.println(msg, null);
+        });
+    }
+
+    /* Processing all expressions. Expressions take form of {=expression}.
+    * Invoked from {@code BreakpointOutputTest}.
+    */
+    final void printExpressions(
+        JPDABreakpointEvent event,
+        String message,
+        BiConsumer<String, Runnable> print,
+        Consumer<String> println
+    ) {
+        String printText = message;
+        Session session = event.getDebugger().getSession();
+        var dumpErrors = new ArrayList<Runnable>();
         for (;;) {
             Matcher m = expressionPattern.matcher (printText);
             if (!m.find ()) {
                 break;
             }
             String expression = m.group (1);
-            String value = "";
             try {
                 JPDADebugger theDebugger;
                 synchronized (lock) {
                     if (debugger == null) {
-                        return value; // The debugger is gone
+                        // The debugger is gone
+                        return;
                     }
                     theDebugger = debugger;
                 }
+
+                String beforeExpression = printText.substring(0, m.start());
+                print.accept(beforeExpression, null);
+
                 CallStackFrame csf = null;
-                if (t != null && !isThreadDeath) {
+                JPDAThread t = event.getThread();
+                if (t != null && !event.isThreadDeath()) {
                     try {
                         CallStackFrame[] topFramePtr = t.getCallStack(0, 1);
                         if (topFramePtr.length > 0) {
                             csf = topFramePtr[0];
                         }
                     } catch (AbsentInformationException aiex) {}
                 }
-                try {
-                value = ((Variable) 
theDebugger.getClass().getMethod("evaluate", String.class, 
CallStackFrame.class).
-                        invoke(theDebugger, expression, csf)).getValue();
-                } catch (InvocationTargetException itex) {
-                    if (itex.getTargetException() instanceof 
InvalidExpressionException) {
-                        throw (InvalidExpressionException) 
itex.getTargetException();
-                    }
-                } catch (Exception ex) {
-                    Exceptions.printStackTrace(ex);
+                Variable refValue = theDebugger.evaluate(expression, csf);

Review Comment:
   - added a test in 87ddf47cb8
   - catching all `Exception` and logging them into debug console



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to