From bb3017a7b8264f6883acc6279b2ceaab4fd9860e Mon Sep 17 00:00:00 2001 From: wenyutang-ms Date: Mon, 30 Mar 2026 17:08:38 +0800 Subject: [PATCH] Use JDTUtils.toUri() for decompiled class file URIs Replace manual jdt:// URI construction in getFileURI(IClassFile) with JDTUtils.toUri(classFile) to align with eclipse.jdt.ls PR #3666. This ensures the debugger generates the same URI format as the language server, fixing the issue where classes with source code are opened twice (once as .java, once as .class) during debugging. Fixes microsoft/java-debug#623 Related: eclipse-jdtls/eclipse.jdt.ls#3729 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../debug/plugin/internal/JdtSourceLookUpProvider.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/JdtSourceLookUpProvider.java b/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/JdtSourceLookUpProvider.java index 5652b922..2c39425e 100644 --- a/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/JdtSourceLookUpProvider.java +++ b/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/JdtSourceLookUpProvider.java @@ -466,15 +466,7 @@ private String getContents(IClassFile cf) { } private static String getFileURI(IClassFile classFile) { - String packageName = classFile.getParent().getElementName(); - String jarName = classFile.getParent().getParent().getElementName(); - try { - return new URI(JDT_SCHEME, "contents", PATH_SEPARATOR + jarName + PATH_SEPARATOR + packageName - + PATH_SEPARATOR + classFile.getElementName(), classFile.getHandleIdentifier(), null) - .toASCIIString(); - } catch (URISyntaxException e) { - return null; - } + return JDTUtils.toUri(classFile); } private static String getFileURI(IResource resource) {