Juergen Hoeller opened SPR-14505 and commented
As noted in #19073, the JVM's Class.getDeclaredMethods() may return the methods in any order... not just dependent on the bytecode but even dependent on the particular JVM run, which means it might differ on re-execution of the very same classes on the very same JVM.
As a consequence, we should consider some deterministic order that we can enforce within the framework, e.g. sorting the @Bean methods within each configuration class before registering bean definitions for them.
However, we have two modes of registration: ASM-based, automatically applied for bean definitions registered with class name (and therefore also for classpath scanning); and reflection-based, automatically applied for bean definitions registered with a pre-resolved Class. ASM-based parsing follows source-code declaration order, while reflection-based parsing follows the Class.getDeclaredMethods() order of the particular JVM. While the latter would benefit from a custom deterministic order that we're enforcing, that'd be a step backwards for our ASM mode since source-code declaration order is arguably ideal there.
Affects: 4.3.1
Issue Links:
Juergen Hoeller opened SPR-14505 and commented
As noted in #19073, the JVM's
Class.getDeclaredMethods()may return the methods in any order... not just dependent on the bytecode but even dependent on the particular JVM run, which means it might differ on re-execution of the very same classes on the very same JVM.As a consequence, we should consider some deterministic order that we can enforce within the framework, e.g. sorting the
@Beanmethods within each configuration class before registering bean definitions for them.However, we have two modes of registration: ASM-based, automatically applied for bean definitions registered with class name (and therefore also for classpath scanning); and reflection-based, automatically applied for bean definitions registered with a pre-resolved
Class. ASM-based parsing follows source-code declaration order, while reflection-based parsing follows theClass.getDeclaredMethods()order of the particular JVM. While the latter would benefit from a custom deterministic order that we're enforcing, that'd be a step backwards for our ASM mode since source-code declaration order is arguably ideal there.Affects: 4.3.1
Issue Links:
@Beanmethods@Profiledeclarations on overloaded@Beanmethods@Beanmethods within@Configurationclasses@Orderon nested configuration classes