Skip to content

fix: honor source encodings when resolving breakpoints - #647

Merged
Changyong Gong (chagong) merged 2 commits into
mainfrom
chagong-refactored-guide
Oct 29, 2026
Merged

Changyong Gong (chagong) merged 2 commits into
mainfrom
chagong-refactored-guide

Conversation

@chagong

@chagong Changyong Gong (chagong) commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes microsoft/vscode-java-debug#1726.

The file-backed source lookup decoded Java sources with the language-server JVM's default charset before parsing them. UTF-16 bytes consequently produced an unusable AST and no breakpoint class name, leaving line breakpoints unverified.

  • Use Eclipse IFile.readString() for workspace resources, honoring file/project encodings and stripping Unicode BOMs.
  • Recognize UTF-16 LE/BE and UTF-8 BOMs for external sources with the already bundled Commons IO reader. Preserve the JVM-default fallback for external files without a BOM, and log source-read failures.
  • Add 14 headless Eclipse/JDT regression cases exercising getBreakpointLocations() from actual encoded files through AST parsing to the resolved class name and line. Cover workspace and external BOMs, BOM-less resource encodings, UTF-8, and ISO-8859-1 with a non-ASCII package identifier.
  • Enable same-module Tycho plugin tests. Include the optional m2e/Buildship runtime dependencies needed to start JDT LS, and keep the compiler compatible with the Eclipse 4.38 JDT model (the moving snapshot otherwise selects an incompatible compiler and fails external AST binding with NoSuchMethodError).

README.md has no net changes relative to the PR base. The documentation-only follow-up 46db436a48270e53eb169f868d19ffdef2ed6d0b removes the original README additions without changing the runtime fix or regression coverage. There is no suitable existing contributor guide, so contributor-facing build/test evidence and implementation rationale remain in this PR description rather than a new repository document.

Verification

Performed for the unchanged runtime fix in this cloud worktree on Linux with Temurin JDK 27 (Java 21 plugin target):

  • Original reader reproduced null/incorrect breakpoint class names for UTF-16 and configured single-byte workspace sources.
  • ./mvnw -B -ntp clean verify — passed: 55 existing core tests and all 14 new headless plugin cases.
  • ./mvnw -B -ntp checkstyle:check — passed.
  • ./mvnw -B -ntp -pl com.microsoft.java.debug.plugin,com.microsoft.java.debug.target checkstyle:check -Dcheckstyle.includeTestSourceDirectory=true — passed, including the new tests.

Initial implementation CI completed successfully for commit 5a6483183afaff90e2711b1df3fef29e6f4f2f0a on Linux, Windows, and macOS with JDK 21. Every platform ran all 14 plugin regression cases with no failures or skips, and passed Checkstyle. The existing core suite ran 55 cases per platform (one existing Windows-only skip; no failures). The CLA check also passed. Copilot review was requested after CI passed and reported no open issues on that implementation commit.

Current-head CI also completed successfully for the README-only follow-up 46db436a48270e53eb169f868d19ffdef2ed6d0b: clean verify and Checkstyle passed on Linux, Windows, and macOS with JDK 21, and the CLA check passed. The follow-up was verified with zero net README diff against the PR base and no changes to the runtime, tests, or harness. No redundant local build was run for that documentation-only change.

These are real JVM/JDT integration tests, not just byte-decoder checks. No VS Code UI/debuggee end-to-end reproduction was performed; the claim verified here is correct source decoding and breakpoint class-name/location resolution.

Use Eclipse resource decoding for workspace files and BOM-aware decoding for external sources. Exercise breakpoint class-name resolution with UTF-16, UTF-8, and configured resource charsets in headless JDT tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the encoding-aware source decoding changes.

No open issues 🎉

What changed in this PR

Fixes encoding-related breakpoint resolution failures by decoding file-backed Java sources correctly before JDT parses them.

Changes:

  • Honor workspace file/project encodings and recognize UTF-8 and UTF-16 BOMs in external sources, preserving the JVM-default fallback.
  • Add 14 headless Eclipse/JDT regression cases covering encoding-aware breakpoint class-name and line resolution.
  • Enable plugin integration tests, align the compiler with the Eclipse target, and document encoding behavior and build requirements.
File Description
README.md Documents source encodings and build/test requirements.
com.microsoft.java.debug.target/​com.microsoft.java.debug.tp.target Makes the Eclipse target’s JDT compiler available.
com.microsoft.java.debug.plugin/​src/​test/​java/​com/​microsoft/​java/​debug/​plugin/​internal/​JdtSourceLookUpProviderTest.java Adds 14 encoding-focused breakpoint regression cases.
com.microsoft.java.debug.plugin/​src/​main/​java/​com/​microsoft/​java/​debug/​plugin/​internal/​JdtSourceLookUpProvider.java Uses encoding-aware source readers and logs read failures.
com.microsoft.java.debug.plugin/​pom.xml Configures plugin tests, runtime dependencies, and a compatible compiler range.

Review effort: Balanced

Restore README.md to the PR base without changing the source-encoding fix or regression tests. Keep contributor-facing verification and implementation rationale in the PR description because there is no suitable existing contributor guide.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@wenytang-ms wenyt (wenytang-ms) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@chagong
Changyong Gong (chagong) merged commit a658059 into main Oct 29, 2026
4 checks passed
@chagong
Changyong Gong (chagong) deleted the chagong-refactored-guide branch October 29, 2026 03:00
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.

Line breakpoints never verify in UTF-16 encoded source files

3 participants