Make getMethodHandlesImplLookup Handle Exceptions#3481
Make getMethodHandlesImplLookup Handle Exceptions#3481alonalbert wants to merge 1 commit intoJetBrains:masterfrom
Conversation
On Android API < 26,: ``` debugProcess.findClass(evaluationContext, "java.lang.invoke.MethodHandles\$Lookup", null) ``` Will throw and this will make Evaluate Expression fail.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit 1c2b159. Configure here.


On Android API < 26,:
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
getMethodHandlesImplLookuptoleratefindClassthrowing (e.g., API < 26) and returnnullinstead.Callers already treat a
nulllookup as a helper-invocation failure, so evaluation now cleanly falls back instead of crashing whenMethodHandles$Lookupis unavailable.Reviewed by Cursor Bugbot for commit 1c2b159. Bugbot is set up for automated code reviews on this repo. Configure here.