Skip to content

Inspect all stratas to find a source file#9433

Open
jtulach wants to merge 2 commits into
apache:masterfrom
jtulach:DebugKotlin
Open

Inspect all stratas to find a source file#9433
jtulach wants to merge 2 commits into
apache:masterfrom
jtulach:DebugKotlin

Conversation

@jtulach

@jtulach jtulach commented Jun 8, 2026

Copy link
Copy Markdown
Contributor
  • trying to debug a Kotlin file
  • can specify a method breakpoint
    • the execution stops, but no location in editor is selected
    • clicking on stacktrace element shows the line in a .kt file
  • can step over
    • execution does the step, but no location in editor is selected
    • clicking on stacktrace element shows the line in a .kt file
  • turns out the problem is wrong stratum (from JDK-245)
strata
  • there are too many strata and the default one is Kotlin

  • when the strata is switched to Java the debugger line gets selected in the editor

  • hence this PR tries all available strata to find any line in any existing editor

  • with this the stepping seems to work

  • TBD: placing a breakpoint in the Kotlin source

@jtulach jtulach self-assigned this Jun 8, 2026
@jtulach jtulach added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Kotlin debugger labels Jun 8, 2026
convertSlash (csf.getSourcePath (stratumn)), true
convertSlash (csf.getSourcePath (csf.getDefaultStratum())), true
);
for (var anyStratum : csf.getAvailableStrata()) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fallback is only applied if url is still null after all previous attempts. E.g. this fallback shall not have any impact on cases where the URL was found previously.

In Kotlin sources, it seems to work OKeish - the line is selected according to Java strata (that good). However the debugger strata remains Kotlin. As such the current PC line isn't highlighted, just selected. Not ideal, but I am afraid to switch the strata behind the scene - who knows how that would work in JSPs, etc.?

@jtulach jtulach requested a review from lahodaj June 9, 2026 09:41
private static final Pattern PACKAGE = Pattern.compile("package *([\\p{Alnum}+\\.$]+) *");
private void createNewBreakpoint(String url, int line, final DebuggerManager m) {
try {
var b = LineBreakpoint.create(url, line);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tedious piece of code that every JVM language needs to write to allow LineBreakpoint. I am convinced that LineBreakpoint should be a core debugger feature and should be applicable to any line in any file automatically.

That's why I'd like to introduce LineBreakpoint next to ide/api.debugger/src/org/netbeans/api/debugger/Breakpoint.java and automatically handle placing it everywhere (in .txt files, or .md files, etc.). It would then be up to various debuggers (like JPDA debugger) to pick all such generic LineBreakpoints up and use them.

Of course, that would be for a separate PR and review...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debugger Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Kotlin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant