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


##########
java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/BreakpointOutput.java:
##########
@@ -397,43 +414,43 @@ private String substitute (String printText, 
JPDABreakpointEvent event) {
                         }
                     } 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);
+                if (refValue instanceof ObjectVariable obj) {
+                    var sessionRef = new WeakReference<>(session);
+                    io.printWithAction("#" + obj.getUniqueID(), () -> {
+                        var s = sessionRef.get();
+                        var ok = s != null && 
BreakpointOutputDetails.showObjectVariable(s, obj);
+                        if (!ok) {
+                            io.println("Cannot display details of " + obj, 
null);
+                        }
+                    }, false);
+                } else {
+                    String textualValue = refValue == null ? "null" : 
refValue.getValue();
+                    io.printWithAction(textualValue, null, false);
                 }
-                //value = theDebugger.evaluate (expression, csf).getValue ();
-                value = backslashEscapePattern.matcher (value).
-                    replaceAll ("\\\\\\\\");
-                value = dollarEscapePattern.matcher (value).
-                    replaceAll ("\\\\\\$");
             } catch (InvalidExpressionException e) {
                 // expression is invalid or cannot be evaluated
-                String msg = e.getCause () != null ? 
-                    e.getCause ().getMessage () : e.getMessage ();
-                JPDADebuggerImpl dbg;
-                synchronized (lock) {
-                    dbg = (JPDADebuggerImpl) debugger;
-                }
-                if (dbg != null) {
-                    dbg.getConsoleIO().println (
-                            "Cannot evaluate expression '" + expression + "' : 
" + msg, 
-                            null
-                        );
-                }
+                String[] msg = new String[] {
+                    e.getCause () != null ? e.getCause ().getMessage () : 
e.getMessage ()
+                };
+                Breakpoint bp = (Breakpoint) event.getSource();
+                io.printWithAction("{=" + expression + "}", () -> {

Review Comment:
   - Resolved in a27977e
   - there is again only pointer to `bp`
   - all errors are printed after the "debug line" is printed



-- 
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