In order to reduce the surface area of published APIs in the affected
classes, this commit:
- Reverts the changes made to GeneratedClasses in c354b1014d.
- Reverts the changes made to DefaultGenerationContext in a28ec3a0a8.
- Makes the DefaultGenerationContext(DefaultGenerationContext, String)
constructor protected.
- Reworks the internals of TestContextGenerationContext to align with
the above changes.
See gh-30861
Closes gh-30895
Closes gh-30897
Aligned with shortcut handling in AutowiredAnnotationBeanPostProcessor.
Includes minor MethodInvoker optimization for pre-resolved targetClass.
Closes gh-30883
Prior to this commit, test AOT processing failed if a feature name for
generated class names was used for more than one ApplicationContext.
For example, when generating code for org.example.MessageService with a
"Management" feature name, the "BeanDefinitions" class was named as
follows (without a uniquely identifying TestContext###_ feature name
prefix).
org/example/MessageService__ManagementBeanDefinitions.java
When another attempt was made to generate code for the MessageService
using the same "Management" feature name, a FileAlreadyExistsException
was thrown denoting that the class/file name was already in use.
To avoid such naming collisions, this commit introduces a
TestContextGenerationContext which provides a custom implementation of
withName(String) that prepends an existing feature name (if present) to
a new feature name, thereby treating any existing feature name as a
prefix to a new, nested feature name.
Consequently, code generation for the above example now results in
unique class/file names like the following (which retain the uniquely
identifying TestContext###_ prefixes).
org/example/MessageService__TestContext002_ManagementBeanDefinitions.java
org/example/MessageService__TestContext003_ManagementBeanDefinitions.java
Closes gh-30861
This commit introduces a `failOnError` flag in TestContextAotGenerator.
When set to `true`, any error encountered during AOT processing will
result in an exception that fails the overall process. When set to
`false` (the default), the previous behavior remains unchanged: a DEBUG
or WARN message will be logged, and processing will continue.
This feature is currently only used for internal testing.
See gh-30861
Closes gh-30898
Previously, BeanInstanceSupplier had three variants of the
`withGenerator` callback, one with a bi function, one with a function,
and with a supplier. This could lead to compilation failure when the
target type has a method with the same name and a number of arguments
that match another variant.
It turns out the supplier-based variant is only used a shortcut. This
commit deprecates it and update ghe code generation to use the function
instead.
Closes gh-29278