Skip to content

Add --realignLineNumbers option - #184

Merged
kwart merged 16 commits into
intoolswetrust:masterfrom
nbauma109:feature/realign-line-numbers
Nov 22, 2026
Merged

kwart merged 16 commits into
intoolswetrust:masterfrom
nbauma109:feature/realign-line-numbers

Conversation

@nbauma109

Copy link
Copy Markdown
Contributor

Closes #102.

Adds a --realignLineNumbers / -rn option which passes jd-core's realignLineNumbers configuration to the decompiler, so that the statements of the decompiled code land on the same line numbers as in the original source (e.g. to set breakpoints or read stack traces against it). It needs line number debug info in the classes, and can be combined with --displayLineNumbers.

  • DecompilerOptions.isRealignLineNumbers() is a default method returning false, so existing implementers still compile.
  • JavaDecompiler passes the option in the configuration map of jd-core.
  • README and --help describe the option. Note that jd-core orders fields, methods and inner classes by their original line number whether the option is enabled or not.
  • Test: JavaDecompilerTest.realignLineNumbersTest decompiles a sample with builder chains (one call per line, with javadoc) and compares the whole output, with the line numbers displayed, with an expected file.

It was reviewed and built on a fork before: nbauma109#6

🤖 Generated with Claude Code

Nicolas Baumann and others added 16 commits November 21, 2026 07:35
Closes intoolswetrust#102

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…dering

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Compile the sample with --release 17 and showcase member re-ordering with
explicit members (the implicit inner class constructor is not emitted by
javac 17).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…lignLineNumbers

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ked sample

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…t file

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…chain to the test

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ring builder chains

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…lign fixture

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…lign fixture

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kwart

kwart commented Nov 22, 2026

Copy link
Copy Markdown
Member

Thanks a lot for this, @nbauma109! The option works well. I tried it from the CLI and statements land on their original lines, and the default method on DecompilerOptions keeps existing implementers working.

I'm merging it as is. We'll do a few small follow-ups ourselves afterwards.

@kwart
kwart merged commit 7c44b3c into intoolswetrust:master Nov 22, 2026
1 check passed
@nbauma109

Copy link
Copy Markdown
Contributor Author

You're welcome !

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request] Realign line numbers

2 participants