From 83e29382b380aed27fe532e1c61679f464aca458 Mon Sep 17 00:00:00 2001 From: cookie-meringue Date: Tue, 19 May 2026 05:46:44 +0900 Subject: [PATCH] Optimize ClassNameReader.getClassName via direct ASM API getClassName now calls ClassReader.getClassName() directly instead of routing through the visitor-based getClassInfo. Previously, it allocated a List and a ClassVisitor and decoded super_class and every interface name only to discard all but the first element. The method is on the hot path of every CGLIB proxy class definition, so this change significantly lowers its per-call processing cost. Closes gh-36814 Signed-off-by: cookie-meringue --- .../java/org/springframework/cglib/core/ClassNameReader.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-core/src/main/java/org/springframework/cglib/core/ClassNameReader.java b/spring-core/src/main/java/org/springframework/cglib/core/ClassNameReader.java index 4371fcdc3a4b..0e5034c1a3d7 100644 --- a/spring-core/src/main/java/org/springframework/cglib/core/ClassNameReader.java +++ b/spring-core/src/main/java/org/springframework/cglib/core/ClassNameReader.java @@ -34,9 +34,11 @@ private ClassNameReader() { private static class EarlyExitException extends RuntimeException { } + // SPRING PATCH BEGIN public static String getClassName(ClassReader r) { - return getClassInfo(r)[0]; + return r.getClassName().replace('/', '.'); } + // SPRING PATCH END public static String[] getClassInfo(ClassReader r) { final List array = new ArrayList<>();