Skip to content

Sort declared methods for deterministic CGLIB classes - #37730

Open
algomaster99 wants to merge 2 commits into
spring-projects:mainfrom
algomaster99:cglib-deterministic-method-order
Open

algomaster99 wants to merge 2 commits into
spring-projects:mainfrom
algomaster99:cglib-deterministic-method-order

Conversation

@algomaster99

Copy link
Copy Markdown

The Java 25 documentation of Class.getDeclaredMethods() says this about the order.

The elements in the returned array are not sorted and are not in any particular order.

In practice, the order changes between JVM runs. CGLIB numbers the methods in this order, so the same proxy class gets different bytecode in different runs. This PR sorts the declared methods in ReflectUtils.addAllMethods() by name and descriptor.

I use SBOM.exe, which checks the classes an application loads against an allowlist of their bytecode. In Spring PetClinic, WebConfiguration$$SpringCGLIB$$0 differed between runs. This change helps create a consistent allowlist for Spring-based applications like PetClinic.

🤖 Generated with Claude Code

Signed-off-by: Aman Sharma <mannu.poski10@gmail.com>
Signed-off-by: Aman Sharma <mannu.poski10@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants