Skip to content

Add ASM metadata reader fallback and slim ClassFile method metadata - #36978

Closed
LordKay-sudo wants to merge 1 commit into
spring-projects:7.0.xfrom
LordKay-sudo:gh-36737-asm-metadata-reader-fallback
Closed

LordKay-sudo wants to merge 1 commit into
spring-projects:7.0.xfrom
LordKay-sudo:gh-36737-asm-metadata-reader-fallback

Conversation

@LordKay-sudo

Copy link
Copy Markdown

Summary

Addresses bclozel's issue 2 and the ASM workaround discussed in gh-36737:

  • Adds -Dspring.classformat.metadatareader.asm=true to select the ASM-based SimpleMetadataReaderFactory on Java 24+ (official alternative to shadowing MetadataReaderFactoryDelegate)
  • Reduces retained memory per method in ClassFileMethodMetadata by storing int access flags and JVM descriptor strings instead of AccessFlags / MethodTypeDesc objects

Context

Several reporters (@bherczyk, @lbenedetto, @pkernevez) resolved OOM by switching back to ASM metadata reading. This provides a supported configuration flag for that workaround while ClassFile memory use is further optimized.

Test plan

  • ./gradlew :spring-core:test --tests "org.springframework.core.type.classreading.*"
  • ./gradlew :spring-core:test --tests "org.springframework.core.type.classreading.MetadataReaderFactoryDelegateTests"

Related to gh-36737

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 29, 2026
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Aug 5, 2026
@bclozel bclozel self-assigned this Sep 3, 2026
@bclozel
bclozel changed the base branch from main to 7.0.x September 3, 2026 16:22
Allow -Dspring.classformat.metadatareader.asm=true to use the ASM-based
SimpleMetadataReaderFactory on Java 24+ as a workaround for high memory
use of ClassFileAnnotationMetadata (spring-projectsgh-36737).

Reduce retained memory per method by storing ASM-style int access flags
and descriptor strings instead of ClassFile API type objects.

Related to spring-projectsgh-36737

Signed-off-by: LordKay-sudo <lkandiro@gmail.com>
@bclozel
bclozel force-pushed the gh-36737-asm-metadata-reader-fallback branch from ab155c0 to eac91d2 Compare September 3, 2026 16:34
@bclozel

bclozel commented Sep 3, 2026

Copy link
Copy Markdown
Member

Thanks for the proposal, but I don't think we can accept this: this introduces a dependency on ASM in the ClassFile implementation. The entire goal here is to not rely on ASM for class metadata introspection.

@bclozel bclozel closed this Sep 3, 2026
@bclozel bclozel added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 3, 2026
@LordKay-sudo
LordKay-sudo deleted the gh-36737-asm-metadata-reader-fallback branch September 3, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants