As a follow up to 332b25b680, this commit consistently avoids the use of
reflection for annotation attribute method invocations.
See gh-29301
Closes gh-29448
When a hint such as `graphql/*.*` is registered for resources that are
looked up via classpath scanning using a pattern such as
`classpath*:graphql/**/*.graphqls`, an appropriate pattern is in fact
registered in the generated `resource-config.json` file for GraalVM
native images; however, classpath scanning fails since GraalVM
currently does not make the `graphql` directory automatically available
as a classpath resource.
This can be very confusing and cumbersome for users since a file such
as `graphql/schema.graphqls` will not be discovered via classpath
scanning even though the file is present in the native image filesystem.
To address this, this commit automatically registers resource hints for
enclosing directories for a registered pattern.
If the GraalVM team later decides to perform automatic directory
registration, we can then remove the code introduced in conjunction
with this issue.
Closes gh-29403
Prior to this commit, it was not possible to register the root
directory as a native image resource; however, it is necessary to be
able to register the root directory to enable classpath scanning of the
root directory within a native image -- for example, to support
resource patterns such as `classpath*:/*.properties`.
This commit therefore relaxes the precondition check in the
ResourcePatternHint constructor to allow explicit registration of the
root directory.
Closes gh-29402
As can be seen in a modified version of the following example project,
attempting to access a resource discovered via classpath scanning
within a GraalVM native image -- for example via the Files.exists(...)
invocation in FileSystemResource -- currently results in a
ClosedFileSystemException since PathMatchingResourcePatternResolver
explicitly closes the native image FileSystem that backs `resource:`
resources.
Sample project: https://github.com/joshlong/spring-boot-3-aot-graphql
To address this issue, this commit removes the explicit close()
invocation for custom FileSystems after classpath scanning in
PathMatchingResourcePatternResolver.
See https://github.com/spring-projects/spring-graphql/issues/495
Closes gh-29397
DefaultValueStyler hard codes conventions for styling that are verbose
and do not align well with standard toString() implementations in the
JDK for arrays, collections, and maps. Furthermore, the default styling
for classes and methods may not be suitable or desirable for certain
use cases.
To address these shortcomings, this commit introduces a
SimpleValueStyler for use with ToStringCreator. The default behavior of
SimpleValueStyler aligns with toString() implementations for arrays,
collections, and maps in the JDK, and styling for classes and methods
is configurable via a dedicated constructor.
Closes gh-29381
The `style(Object)` method in DefaultValueStyler delegates to several
internal methods. Prior to this commit those methods were private,
which prevented users from extending DefaultValueStyler without
rewriting most of the functionality.
This commit addresses this by making those methods protected so that
DefaultValueStyler can be extended. In addition, this commit introduces
protected methods for styling null, strings, classes, methods, and
objects that are not covered by any of the other style*() methods.
Closes gh-29380
LeakAwareDataBufferFactory#checkForLeaks automatically waits up to 5
sec for buffers to be released, which could be used as a way of
awaiting on some async logic to complete, and as long as buffers are
released, it shouldn't be long. However, the leak test in
LeakAwareDataBufferFactoryTests actually expects to find a leak, and
always ends up waiting the full 5 seconds.
This change, makes the wait configurable, with the no-arg method
using 0 (no waiting). AbstractLeakCheckingTests uses 1 second by
default since ResourceRegionEncoderTests did fail locally. If more
tests need this, we can adjust the settings.
This new GraalVM feature replaces ConstantFieldFeature and
introduces various enhancements:
- Leverage the new FieldValueTransformer API
- Use GraalVM 22.3 graal-sdk dependency instead of svm one
- Avoid using internal GraalVM APIs
- No need to configure JPMS exports
- Directly integrated in spring-core module
- Simplified build configuration
Closes gh-29081
Closes gh-29080
Closes gh-29089
Provide a better Javadoc to clarify that @RegisterReflectionForBinding
should annotate a bean and that the types where reflection is needed
should be specified in the annotation attributes.
Closes gh-29345
Tested successfully using the following locally built GraalVM dev build.
OpenJDK Runtime Environment GraalVM 22.3.0-dev (build 17.0.5+5-jvmci-22.3-b07)
Closes gh-29214