Title: Line breakpoints never verify in UTF-16 encoded source files · Issue #1726 · microsoft/vscode-java-debug · GitHub
Open Graph Title: Line breakpoints never verify in UTF-16 encoded source files · Issue #1726 · microsoft/vscode-java-debug
X Title: Line breakpoints never verify in UTF-16 encoded source files · Issue #1726 · microsoft/vscode-java-debug
Description: Line breakpoints in Java source files encoded as UTF-16 LE with BOM stay unverified forever, even after the class is loaded and the line contains code. The same files debug fine in Eclipse. Our sources are UTF-16 because the ERP developm...
Open Graph Description: Line breakpoints in Java source files encoded as UTF-16 LE with BOM stay unverified forever, even after the class is loaded and the line contains code. The same files debug fine in Eclipse. Our sou...
X Description: Line breakpoints in Java source files encoded as UTF-16 LE with BOM stay unverified forever, even after the class is loaded and the line contains code. The same files debug fine in Eclipse. Our sou...
Opengraph URL: https://github.com/microsoft/vscode-java-debug/issues/1726
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Line breakpoints never verify in UTF-16 encoded source files","articleBody":"Line breakpoints in Java source files encoded as **UTF-16 LE with BOM** stay unverified forever, even after the class is loaded and the line contains code. The same files debug fine in Eclipse. Our sources are UTF-16 because the ERP development environment we work with generates them that way, so we cannot switch to UTF-8.\n\n##### Environment\n- Operating System: Windows Server 2022\n- JDK version: JRE 25 embedded in the Java extension (language server); debuggee runs on JDK 11\n- Visual Studio Code version: 1.144.0\n- Java extension version: 1.58.0\n- Java Debugger extension version: 0.60.2026102705 (pre-release, bundles com.microsoft.java.debug.plugin 0.53.2)\n\n##### Steps To Reproduce\n1. Create `demo/A.java` as UTF-16 LE with BOM, for example in PowerShell:\n ```powershell\n New-Item -ItemType Directory -Force demo | Out-Null\n [IO.File]::WriteAllText(\"$PWD\\demo\\A.java\", \"package demo;`r`n`r`npublic class A {`r`n public static void main(String[] a) {`r`n int x = 1;`r`n System.out.println(x);`r`n }`r`n}`r`n\", [Text.UnicodeEncoding]::new($false, $true))\n ```\n Content of the file:\n ```java\n package demo;\n\n public class A {\n public static void main(String[] a) {\n int x = 1;\n System.out.println(x);\n }\n }\n ```\n2. Open the folder in VS Code and set a line breakpoint on `int x = 1;`\n3. Debug `demo.A`\n\n##### Current Result\nThe breakpoint stays grey (\"unverified\") and the program runs through without stopping. We see this for every line breakpoint in every UTF-16 file of our real project.\n\n##### Expected Result\nThe breakpoint is verified and execution stops, as it does for UTF-8 files.\n\n##### Additional Informations\nI think the cause is in microsoft/java-debug, `JdtSourceLookUpProvider.readFile`: it reads the file with `new InputStreamReader(new FileInputStream(filePath))`, i.e. with the JVM default charset (UTF-8). For a UTF-16 file the `ASTParser` then finds no package and no type, so no class name is resolved and the breakpoint can never be bound. Calling `readFile` from the shipped plugin jar (0.53.2) on the file above and parsing the result the same way gives no package and no type; with the BOM-aware version below it gives `package demo`, type `A`.\n\nWorkaround I tried: `-Dfile.encoding=UTF-16` in `java.jdt.ls.vmargs` fixes the parsing, but then the language server does not start (`ExceptionInInitializerError` in `org.eclipse.core.net`, caused by `NullPointerException: key can't be null` while loading a native library).\n\nA small change that honours the BOM fixed it for me (tested locally by rebuilding the plugin jar: breakpoints in UTF-16 files verify and stop, UTF-8 files with and without BOM behave as before):\n\n```java\nprivate static String readFile(String filePath) {\n try {\n byte[] bytes = Files.readAllBytes(Paths.get(filePath));\n if (bytes.length >= 3 && (bytes[0] & 0xFF) == 0xEF && (bytes[1] & 0xFF) == 0xBB && (bytes[2] & 0xFF) == 0xBF) {\n return new String(bytes, 3, bytes.length - 3, StandardCharsets.UTF_8);\n }\n if (bytes.length >= 2 && (bytes[0] & 0xFF) == 0xFF && (bytes[1] & 0xFF) == 0xFE) {\n return new String(bytes, 2, bytes.length - 2, StandardCharsets.UTF_16LE);\n }\n if (bytes.length >= 2 && (bytes[0] & 0xFF) == 0xFE && (bytes[1] & 0xFF) == 0xFF) {\n return new String(bytes, 2, bytes.length - 2, StandardCharsets.UTF_16BE);\n }\n return new String(bytes, Charset.defaultCharset());\n } catch (IOException e) {\n return \"\";\n }\n}\n```\n\nUsing the resource charset (`IFile.getCharset()`) where the file belongs to a workspace project might be even better. I'm happy to open a PR in microsoft/java-debug if that helps.\n","author":{"url":"https://github.com/barbarabrugger","@type":"Person","name":"barbarabrugger"},"datePublished":"2026-10-28T21:58:21Z","url":"https://github.com/microsoft/vscode-java-debug/issues/1726"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6e85727a-41d3-19c2-fc20-a3c8e49dbdb5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 884E:23D581:EE349:147ABB:6AF7CF09 |
| html-safe-nonce | 5d97ecb1da25e9e3165af1baaa3ba8c1302ea34c0477447d3705fff0ae62a0fa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4ODRFOjIzRDU4MTpFRTM0OToxNDdBQkI6NkFGN0NGMDkiLCJ2aXNpdG9yX2lkIjoiNTkzNDk1MzUwMzA4MjI4ODczIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 228f7e1bfa3dc8c1b92b968e750de059748e82a88c09399726dfdcd426eb88bc |
| hovercard-subject-tag | issue:6088244032 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/vscode-java-debug/1726/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8128166d5a3d1b944a95941be816743c28430e32d428965724f17428fabae56d/microsoft/vscode-java-debug/issues/1726 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8128166d5a3d1b944a95941be816743c28430e32d428965724f17428fabae56d/microsoft/vscode-java-debug/issues/1726 |
| og:image:alt | Line breakpoints in Java source files encoded as UTF-16 LE with BOM stay unverified forever, even after the class is loaded and the line contains code. The same files debug fine in Eclipse. Our sou... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | barbarabrugger |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0538a59d4a0acd1aee7d41f7f56bd94b5294b4b7cb8ac3a11a32ac8bb4562076 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/vscode-java-debug git https://github.com/microsoft/vscode-java-debug.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 102584737 |
| octolytics-dimension-repository_nwo | microsoft/vscode-java-debug |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 102584737 |
| octolytics-dimension-repository_network_root_nwo | microsoft/vscode-java-debug |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8a34a01748011ac03e602fdd18a9597dd6341074 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width