From 4a895835693fd21c126f5ee52795c446c42a5524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=AD=E5=A5=87?= Date: Thu, 5 Feb 2026 16:28:38 +0800 Subject: [PATCH 1/2] pref: add try-catch #236 --- .../spring/patch/RequestParamPatcher.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/debug-tools-hotswap/debug-tools-hotswap-plugin/debug-tools-hotswap-spring-plugin/src/main/java/io/github/future0923/debug/tools/hotswap/core/plugin/spring/patch/RequestParamPatcher.java b/debug-tools-hotswap/debug-tools-hotswap-plugin/debug-tools-hotswap-spring-plugin/src/main/java/io/github/future0923/debug/tools/hotswap/core/plugin/spring/patch/RequestParamPatcher.java index 2ae90105..b3dce33a 100644 --- a/debug-tools-hotswap/debug-tools-hotswap-plugin/debug-tools-hotswap-spring-plugin/src/main/java/io/github/future0923/debug/tools/hotswap/core/plugin/spring/patch/RequestParamPatcher.java +++ b/debug-tools-hotswap/debug-tools-hotswap-plugin/debug-tools-hotswap-spring-plugin/src/main/java/io/github/future0923/debug/tools/hotswap/core/plugin/spring/patch/RequestParamPatcher.java @@ -40,14 +40,17 @@ public static void patchAbstractNamedValueMethodArgumentResolver(CtClass ctClass @OnClassLoadEvent(classNameRegexp = "org.springframework.core.LocalVariableTableParameterNameDiscoverer") public static void patchLocalVariableTableParameterNameDiscoverer(CtClass ctClass, ClassPool classPool) throws CannotCompileException, NotFoundException { - CtMethod getParameterNames = ctClass.getDeclaredMethod("doGetParameterNames", new CtClass[]{classPool.get("java.lang.reflect.Executable")}); - getParameterNames.setBody("{" + - " Class declaringClass = $1.getDeclaringClass();" + - " java.util.Map map = this.inspectClass(declaringClass);" + - " if (map != NO_DEBUG_INFO_MAP) {" + - " return (String[])map.get($1);" + - " }" + - " return null;" + - "}"); + try { + CtMethod getParameterNames = ctClass.getDeclaredMethod("doGetParameterNames", new CtClass[]{classPool.get("java.lang.reflect.Executable")}); + getParameterNames.setBody("{" + + " Class declaringClass = $1.getDeclaringClass();" + + " java.util.Map map = this.inspectClass(declaringClass);" + + " if (map != NO_DEBUG_INFO_MAP) {" + + " return (String[])map.get($1);" + + " }" + + " return null;" + + "}"); + } catch (Exception e) { + } } } From c4a09a932e61eeb03020f03072f6dc2f68bd3776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=AD=E5=A5=87?= Date: Mon, 9 Feb 2026 21:08:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?pref:=20add=20=E9=80=82=E9=85=8D5.1.8?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=9A=84spring-core=20#236?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spring/patch/RequestParamPatcher.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/debug-tools-hotswap/debug-tools-hotswap-plugin/debug-tools-hotswap-spring-plugin/src/main/java/io/github/future0923/debug/tools/hotswap/core/plugin/spring/patch/RequestParamPatcher.java b/debug-tools-hotswap/debug-tools-hotswap-plugin/debug-tools-hotswap-spring-plugin/src/main/java/io/github/future0923/debug/tools/hotswap/core/plugin/spring/patch/RequestParamPatcher.java index b3dce33a..4ef7a0f5 100644 --- a/debug-tools-hotswap/debug-tools-hotswap-plugin/debug-tools-hotswap-spring-plugin/src/main/java/io/github/future0923/debug/tools/hotswap/core/plugin/spring/patch/RequestParamPatcher.java +++ b/debug-tools-hotswap/debug-tools-hotswap-plugin/debug-tools-hotswap-spring-plugin/src/main/java/io/github/future0923/debug/tools/hotswap/core/plugin/spring/patch/RequestParamPatcher.java @@ -16,6 +16,7 @@ */ package io.github.future0923.debug.tools.hotswap.core.plugin.spring.patch; +import io.github.future0923.debug.tools.base.logging.Logger; import io.github.future0923.debug.tools.hotswap.core.annotation.OnClassLoadEvent; import javassist.CannotCompileException; import javassist.ClassPool; @@ -30,6 +31,8 @@ */ public class RequestParamPatcher { + private static final Logger logger = Logger.getLogger(RequestParamPatcher.class); + @OnClassLoadEvent(classNameRegexp = "org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver") public static void patchAbstractNamedValueMethodArgumentResolver(CtClass ctClass, ClassPool classPool) throws CannotCompileException, NotFoundException { CtMethod getNamedValueInfo = ctClass.getDeclaredMethod("getNamedValueInfo", new CtClass[]{classPool.get("org.springframework.core.MethodParameter")}); @@ -41,6 +44,7 @@ public static void patchAbstractNamedValueMethodArgumentResolver(CtClass ctClass @OnClassLoadEvent(classNameRegexp = "org.springframework.core.LocalVariableTableParameterNameDiscoverer") public static void patchLocalVariableTableParameterNameDiscoverer(CtClass ctClass, ClassPool classPool) throws CannotCompileException, NotFoundException { try { + // 5.3.23+ CtMethod getParameterNames = ctClass.getDeclaredMethod("doGetParameterNames", new CtClass[]{classPool.get("java.lang.reflect.Executable")}); getParameterNames.setBody("{" + " Class declaringClass = $1.getDeclaringClass();" + @@ -51,6 +55,19 @@ public static void patchLocalVariableTableParameterNameDiscoverer(CtClass ctClas " return null;" + "}"); } catch (Exception e) { + // 5.1.8 + CtMethod getParameterNames = ctClass.getDeclaredMethod("getParameterNames", new CtClass[]{classPool.get("java.lang.reflect.Constructor")}); + getParameterNames.setBody("{" + + " Class declaringClass = $1.getDeclaringClass();" + + " java.util.Map map = this.inspectClass(declaringClass);" + + " if (map != NO_DEBUG_INFO_MAP) {" + + " return (String[])map.get($1);" + + " }" + + " return null;" + + "}"); } + + logger.info("patch springframework LocalVariableTableParameterNameDiscoverer success"); + } }