eppleton commented on code in PR #9691:
URL: https://github.com/apache/netbeans/pull/9691#discussion_r4230468047
##########
java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/BreakpointOutput.java:
##########
@@ -421,10 +404,12 @@ private String substitute (String printText,
JPDABreakpointEvent event) {
dbg = (JPDADebuggerImpl) debugger;
}
if (dbg != null) {
- dbg.getConsoleIO().println (
- "Cannot evaluate expression '" + expression + "' :
" + msg,
- null
- );
+ dbg.getConsoleIO().printlnWithAction(
+ "Cannot evaluate expression '" + expression + "' : " +
msg,
+ () -> {
+ BreakpointsActionsProvider.customize((Breakpoint)
event.getSource());
Review Comment:
This lambda captures the whole `JPDABreakpointEvent` (javap shows
`lambda$substitute$0(JPDABreakpointEvent)`). The event holds the
`JPDADebugger`, the `JPDAThread`, the `Variable` and the original JDI `Event`.
The hyperlink stays in the Debugger Console tab after the session ends, and
`DebuggerOutput` only closes old tabs when the next session starts. Until then,
the finished session is reachable from the output window. `IOManager` keeps
only a `WeakReference` to the debugger, and `CloseSessionsTest` checks that the
debugger is GC'd. Maybe read `Breakpoint b = (Breakpoint) event.getSource();`
before the lambda and capture only `b`?
##########
java/api.debugger.jpda/build.xml:
##########
@@ -24,7 +24,7 @@
<target name="build-init" depends="projectized.build-init">
<mkdir dir="${jpda.classes.dir}"/>
- <copy todir="${jpda.classes.dir}">
+ <copy todir="${jpda.classes.dir}" failonerror="false">
Review Comment:
Is `failonerror="false"` (here and in `debugger.jpda/build.xml`) related to
this PR? These classes are put on `cp.extra`. If the copy fails, the build no
longer stops here but fails later with `package com.sun.jdi does not exist`, or
uses whatever JDI is on the boot classpath. If a particular JDK needs this, a
comment saying which one would help.
##########
java/api.debugger.jpda/src/org/netbeans/api/debugger/jpda/JPDADebugger.java:
##########
@@ -397,10 +397,26 @@ public List<JPDAThread> getAllThreads() {
* @param expression a expression to be evaluated
*
* @return current value of given expression
+ * @throws org.netbeans.api.debugger.jpda.InvalidExpressionException
*/
public abstract Variable evaluate (String expression)
throws InvalidExpressionException;
+ /**
+ * Evaluates given expression in the current context.
+ *
+ * @param expression a expression to be evaluated
+ * @param csf frame to evaluate the expression at
+ *
+ * @return current value of given expression
+ * @throws org.netbeans.api.debugger.jpda.InvalidExpressionException
+ * @since 3.45
+ */
+ public Variable evaluate (String expression, CallStackFrame csf)
Review Comment:
The javadoc says `csf` is the "frame to evaluate the expression at", but the
default implementation ignores it and evaluates in the current context. That's
fine as a compatibility fallback, since `JPDADebuggerImpl` already has the real
implementation. Could the javadoc say so? An `@Override` on
`JPDADebuggerImpl.evaluate(String, CallStackFrame)` would also make the link
explicit.
##########
java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/BreakpointOutput.java:
##########
@@ -397,16 +389,7 @@ 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);
- }
+ value = theDebugger.evaluate(expression, csf).getValue();
//value = theDebugger.evaluate (expression, csf).getValue ();
Review Comment:
Nit: this commented-out line is now the same as the line above it, and the
`java.lang.reflect.InvocationTargetException` and `org.openide.util.Exceptions`
imports are no longer used.
##########
java/api.debugger.jpda/apichanges.xml:
##########
@@ -51,6 +51,20 @@
<!-- ACTUAL CHANGES BEGIN HERE: -->
<changes>
+ <change>
+ <api name="JPDADebuggerAPI"/>
+ <summary>JPDABreakpointEvent, JPDADebugger enhancements</summary>
+ <version major="3" minor="45"/>
+ <date day="16" month="10" year="2026"/>
Review Comment:
Nit: the date is 16 October, a week from now.
--
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