From d14de6679dad588f357ad60a5a89a72bb7fb55a0 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Wed, 18 Mar 2026 16:23:44 +0100 Subject: [PATCH] Breakpoints for lambdas. --- build.xml | 1 + patches/9285.diff | 2110 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 2111 insertions(+) create mode 100644 patches/9285.diff diff --git a/build.xml b/build.xml index e195563..09bff57 100644 --- a/build.xml +++ b/build.xml @@ -74,6 +74,7 @@ patches/updated-show-input-params.diff patches/java-notebooks.diff patches/formatOptions.diff + patches/9285.diff diff --git a/patches/9285.diff b/patches/9285.diff new file mode 100644 index 0000000..020be87 --- /dev/null +++ b/patches/9285.diff @@ -0,0 +1,2110 @@ +diff --git a/java/api.debugger.jpda/src/org/netbeans/api/debugger/jpda/LineBreakpoint.java b/java/api.debugger.jpda/src/org/netbeans/api/debugger/jpda/LineBreakpoint.java +index 78726be196d7..9450baabbfa2 100644 +--- a/java/api.debugger.jpda/src/org/netbeans/api/debugger/jpda/LineBreakpoint.java ++++ b/java/api.debugger.jpda/src/org/netbeans/api/debugger/jpda/LineBreakpoint.java +@@ -24,6 +24,7 @@ + import java.io.IOException; + import java.net.MalformedURLException; + import java.net.URL; ++import java.util.Arrays; + import java.util.Collection; + import java.util.Map; + import java.util.WeakHashMap; +@@ -67,6 +68,8 @@ public class LineBreakpoint extends JPDABreakpoint { + /** Property name constant */ + public static final String PROP_LINE_NUMBER = "lineNumber"; // NOI18N + /** Property name constant */ ++ public static final String PROP_LAMBDA_INDEXES = "lambdaIndexes"; // NOI18N ++ /** Property name constant */ + public static final String PROP_URL = "url"; // NOI18N + /** Property name constant. */ + public static final String PROP_CONDITION = "condition"; // NOI18N +@@ -83,6 +86,9 @@ public class LineBreakpoint extends JPDABreakpoint { + /** Property name constant */ + public static final String PROP_THREAD_FILTERS = "threadFilters"; // NOI18N + ++ /**Lambda index value meaning the debugger should stop at locations outside of any lambda.*/ ++ public static final int LAMBDA_INDEX_STOP_OUTSIDE = -1; ++ + private static final Logger LOG = Logger.getLogger(LineBreakpoint.class.getName()); + + private String url = ""; // NOI18N +@@ -94,6 +100,7 @@ public class LineBreakpoint extends JPDABreakpoint { + private String className = null; + private Map instanceFilters; + private Map threadFilters; ++ private int[] lambdaIndexes = new int[0]; + + + private LineBreakpoint (String url) { +@@ -182,6 +189,28 @@ public void setLineNumber (int ln) { + Integer.valueOf(ln) + ); + } ++ ++ public int[] getLambdaIndexes() { ++ return lambdaIndexes.clone(); ++ } ++ ++ public void setLambdaIndexes(int[] li) { ++ int[] old; ++ ++ li = li.clone(); ++ ++ synchronized (this) { ++ if (li == lambdaIndexes) { ++ return; ++ } ++ old = lambdaIndexes; ++ lambdaIndexes = li; ++ } ++ firePropertyChange (PROP_LAMBDA_INDEXES, ++ old, ++ li ++ ); ++ } + + /** + * Get the instance filter for a specific debugger session. +@@ -423,7 +452,7 @@ public String toString () { + if (fileName == null) { + fileName = url; + } +- return "LineBreakpoint " + fileName + " : " + lineNumber; ++ return "LineBreakpoint " + fileName + " : " + lineNumber + (lambdaIndexes.length > 0 ? " lambda indices: " + Arrays.toString(lambdaIndexes) : ""); + } + + private static class LineBreakpointImpl extends LineBreakpoint +diff --git a/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties b/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties +index fe41db22e26f..f5102fb01e63 100644 +--- a/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties ++++ b/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties +@@ -229,6 +229,11 @@ + ACSD_TF_Line_Breakpoint_Line_Number=Line number + TTT_TF_Line_Breakpoint_Line_Number=Line number to stop at + ++ L_Line_Breakpoint_Lambda_Index=Lambda &Indexes\: ++ ACSD_L_Line_Breakpoint_Lambda_Index=Lambda Indexes ++ ACSD_TF_Line_Breakpoint_Lambda_Index=Lambda Indexes ++ TTT_TF_Line_Breakpoint_Lambda_Index=Comma seperated lambda indexes to stop at\nempty: all locations\n-1: stop outside of lambda\n0-based index: break in that lambda expression ++ + L_Line_Breakpoint_Condition=Co&ndition: + ACSD_L_Line_Breakpoint_Condition=Condition + ACSD_TF_Line_Breakpoint_Condition=Condition +@@ -242,6 +247,7 @@ + MSG_No_Line_Number_Spec=Line number should be specified. + MSG_TooBig_Line_Number_Spec=The line number {0} is too big. Maximum line number is {1}. + MSG_NonPositive_Line_Number_Spec=A positive line number should be specified. ++ MSG_Invalid_Lambda_Index=Lambda index {0} is not a number. + + MSG_Bad_Hit_Count_Filter_Spec=Wrong value of hit count filter: ''{0}''. + MSG_NonPositive_Hit_Count_Filter_Spec=A positive hit count filter should be specified. +@@ -317,3 +323,4 @@ ACSN_LineBreakpoint=Line Breakpoint properties + ACSN_FieldBreakpoint=Field Breakpoint properties + ACSN_ExceptionBreakpoint=Exception Breakpoint properties + TTT_ExceptionClassName=The class name representing the exception. ++ACSN_TF_Line_Breakpoint_Lambda_Index=Lambda index +diff --git a/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/LineBreakpointPanel.form b/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/LineBreakpointPanel.form +index 5ea1b1c1ff72..ff40b6edfef9 100644 +--- a/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/LineBreakpointPanel.form ++++ b/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/LineBreakpointPanel.form +@@ -1,4 +1,4 @@ +- ++ + +