Skip to content

fix: handle NoSuchMethodError for isMainMethodCandidate() on older JD…#622

Merged
wenytang-ms merged 3 commits intomainfrom
fix/handle-nosuchmethoderror-isMainMethodCandidate
Mar 31, 2026
Merged

fix: handle NoSuchMethodError for isMainMethodCandidate() on older JD…#622
wenytang-ms merged 3 commits intomainfrom
fix/handle-nosuchmethoderror-isMainMethodCandidate

Conversation

@wenytang-ms
Copy link
Copy Markdown
Contributor

…T Core

Catch NoSuchMethodError when calling SourceMethod.isMainMethodCandidate() in ResolveMainClassHandler and ResolveMainMethodHandler. This method was added in JDT Core 3.36 and is unavailable on older versions, causing the debugger to fail entirely when resolving main classes.

Fixes microsoft/vscode-java-debug#1598

…T Core

Catch NoSuchMethodError when calling SourceMethod.isMainMethodCandidate()
in ResolveMainClassHandler and ResolveMainMethodHandler. This method was
added in JDT Core 3.36 and is unavailable on older versions, causing
the debugger to fail entirely when resolving main classes.

Fixes microsoft/vscode-java-debug#1598

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves backward compatibility with older Eclipse JDT Core versions by preventing debugger failures when SourceMethod.isMainMethodCandidate() is unavailable (added in JDT Core 3.36), allowing main-class/main-method resolution to continue via fallback logic.

Changes:

  • Wrap calls to SourceMethod.isMainMethodCandidate() in try/catch (NoSuchMethodError) in main-method resolution.
  • Add a fallback path in main-class resolution to use IMethod.isMainMethod() when isMainMethodCandidate() is missing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
com.microsoft.java.debug.plugin/.../ResolveMainMethodHandler.java Prevents crashes during per-type method scanning by catching NoSuchMethodError around isMainMethodCandidate().
com.microsoft.java.debug.plugin/.../ResolveMainClassHandler.java Prevents crashes during search-based main-method detection by catching NoSuchMethodError and falling back to isMainMethod().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wenytang-ms wenytang-ms reopened this Mar 31, 2026
@wenytang-ms wenytang-ms merged commit a4c27fb into main Mar 31, 2026
8 checks passed
@wenytang-ms wenytang-ms deleted the fix/handle-nosuchmethoderror-isMainMethodCandidate branch March 31, 2026 06:04
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.

Java Fails to Run in Version >56.2

3 participants