Skip to content

Make getMethodHandlesImplLookup Handle Exceptions#3481

Open
alonalbert wants to merge 1 commit intoJetBrains:masterfrom
alonalbert:IDEA-388179
Open

Make getMethodHandlesImplLookup Handle Exceptions#3481
alonalbert wants to merge 1 commit intoJetBrains:masterfrom
alonalbert:IDEA-388179

Conversation

@alonalbert
Copy link
Copy Markdown
Contributor

@alonalbert alonalbert commented Apr 9, 2026

On Android API < 26,:

debugProcess.findClass(evaluationContext, "java.lang.invoke.MethodHandles\$Lookup", null)

Will throw and this will make Evaluate Expression fail.

https://youtrack.jetbrains.com/issue/IDEA-388179/Evaluate-Expression-Throws-on-Android-API-25


Note

Low Risk
Change is localized to debugger evaluation utility code and only adds exception handling/fallback behavior; low risk aside from potentially masking unexpected class-loading errors.

Overview
Prevents Evaluate Expression failures on older Android runtimes by making getMethodHandlesImplLookup tolerate findClass throwing (e.g., API < 26) and return null instead.

Callers already treat a null lookup as a helper-invocation failure, so evaluation now cleanly falls back instead of crashing when MethodHandles$Lookup is unavailable.

Reviewed by Cursor Bugbot for commit 1c2b159. Bugbot is set up for automated code reviews on this repo. Configure here.

On Android API < 26,:
```
debugProcess.findClass(evaluationContext, "java.lang.invoke.MethodHandles\$Lookup", null)
```

Will throw and this will make Evaluate Expression fail.
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1c2b159. Configure here.

val theClass = runCatching {
// On Android API < 26, this will throw
evaluationContext.debugProcess.findClass(evaluationContext, "java.lang.invoke.MethodHandles\$Lookup", null)
}.getOrNull() ?: return null
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

runCatching silently swallows cancellation exceptions

Medium Severity

Using runCatching here catches all Throwable instances, including ProcessCanceledException and CancellationException, which are used by the IntelliJ Platform for task cancellation. Swallowing these causes the method to return null instead of propagating the cancellation signal, potentially leaving the IDE in an unresponsive or inconsistent state when the user cancels an evaluation. A try/catch that rethrows cancellation exceptions would be appropriate here.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1c2b159. Configure here.

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.

3 participants