From 1c2b1596e4171febbd682313c0683e5a0db1242c Mon Sep 17 00:00:00 2001 From: Alon Albert Date: Thu, 9 Apr 2026 09:25:03 -0700 Subject: [PATCH] Make getMethodHandlesImplLookup Handle Exceptions On Android API < 26,: ``` debugProcess.findClass(evaluationContext, "java.lang.invoke.MethodHandles\$Lookup", null) ``` Will throw and this will make Evaluate Expression fail. --- .../intellij/debugger/engine/MethodInvokeUtils.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/MethodInvokeUtils.kt b/java/debugger/impl/src/com/intellij/debugger/engine/MethodInvokeUtils.kt index f737d2024832f..458db40d546b1 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/MethodInvokeUtils.kt +++ b/java/debugger/impl/src/com/intellij/debugger/engine/MethodInvokeUtils.kt @@ -76,12 +76,12 @@ object MethodInvokeUtils { } fun getMethodHandlesImplLookup(evaluationContext: EvaluationContextImpl): ObjectReference? { - val theClass = evaluationContext.debugProcess.findClass(evaluationContext, - "java.lang.invoke.MethodHandles\$Lookup", - null) - val theField = DebuggerUtils.findField(theClass, - "IMPL_LOOKUP") - return theClass?.getValue(theField) as? ObjectReference + val theClass = runCatching { + // On Android API < 26, this will throw + evaluationContext.debugProcess.findClass(evaluationContext, "java.lang.invoke.MethodHandles\$Lookup", null) + }.getOrNull() ?: return null + val theField = DebuggerUtils.findField(theClass, "IMPL_LOOKUP") + return theClass.getValue(theField) as? ObjectReference } }