Commit Graph

2774 Commits

Author SHA1 Message Date
Sam Brannen 29a9016809 Merge branch '5.3.x' 2022-05-23 20:36:47 +02:00
Sam Brannen 7b95c928d1 Fix Javadoc for ResourcePatternResolver 2022-05-23 20:32:01 +02:00
Sam Brannen 53f88d455f Fix Javadoc for AbstractFileResolvingResource.isFile(URI) 2022-05-23 20:32:01 +02:00
Sam Brannen 53a506f6bb Polishing 2022-05-23 20:22:37 +02:00
Sam Brannen f07e7ab39d Create UrlResource factory methods that throw unchecked exceptions
UrlResource constructors throw checked exceptions which makes it
difficult to use them in java.util.Stream and java.util.Optional APIs
or other scenarios when a checked IOException is undesirable.

To support such use cases, this commit introduces `from(URI)` and
`from(String)` factory methods in UrlResource that throw
UncheckedIOExceptions.

Closes gh-28501
2022-05-23 14:22:52 +02:00
Sam Brannen 4515180195 Polish PathMatchingResourcePatternResolver 2022-05-23 14:22:43 +02:00
Stephane Nicoll 2f94713078 Make sure that annotation hierarchy is registered
This commit improves registerAnnotation to also registers the meta
annotation sources, if any. Without them, the annotation could not
be fully resolved.

See gh-28497
2022-05-23 08:57:02 +02:00
Stephane Nicoll 4cca190aad Add support of declarative use of reflection
This commit adds a `@Reflective` annotation that can be used to declare
that the annotated element requires reflection at runtime. By default,
the annotated element is exposed but this can be customized by
specifying a dedicated `ReflectiveProcessor`.

Closes gh-28469
2022-05-20 15:02:46 +02:00
Stephane Nicoll 2517c72f7d Add a common utility to register hints for an annotation
This commit adds a utility that takes care of registering the necessary
hints to make an annotation visible at runtime. The core framework may
create a JDK proxy if necessary, which requires specific handling.

Closes gh-28497
2022-05-20 14:54:27 +02:00
Sam Brannen 70415b1781 Merge branch '5.3.x' 2022-05-17 15:41:08 +02:00
Sam Brannen 59c7bb1f86 Use Arrays.toString instead of Arrays.asList when generating Strings 2022-05-17 15:36:31 +02:00
Sam Brannen fe7c6f075b Polishing 2022-05-16 10:53:35 +02:00
izeye 0fb0335aa0 Add level guards for trace logging in SpringFactoriesLoaderRuntimeHintsRegistrar
Closes gh-28465
2022-05-16 09:07:25 +02:00
Sam Brannen 6a67b4a2aa Polish SpringFactoriesLoaderRuntimeHintsRegistrar
See gh-27955
2022-05-11 16:18:06 +02:00
Brian Clozel e6c0152916 Force AOT resolution of Spring Factories constructors
This commit forces the resolution of all declared constructors when
registering `RuntimeHints` for Spring factories. Resolving constructors
can throw additional `NoClassDefFoundError` at runtime and during native
image compilation, if a type exposed by the constructor is missing from
the current classloader.

See gh-27955
2022-05-11 12:11:14 +02:00
Phillip Webb 2961426d8a Fix checkstyle issues and test failures
See gh-27955
See gh-28442
2022-05-10 18:33:15 -07:00
Brian Clozel 267b91486e Add native hints for SpringFactoriesLoader file content
Add `SpringFactoriesLoaderRuntimeHintsRegistrar` which provides
native hints for `spring.factories` content.

Closes gh-27955

Co-authored-by: Phillip Webb <pwebb@vmware.com>
2022-05-10 17:08:49 -07:00
Phillip Webb e7e60f7cb9 Add native hints for core annotations
Add `CoreAnnotationsRuntimeHintsRegistrar` to provide native hints
for `@Order` and `@AliasFor`.

Closes gh-28442
2022-05-10 16:11:36 -07:00
Phillip Webb 4cebd9d392 Fix SpringFactoriesLoader cache key when using default classloader
Update `SpringFactoriesLoader` so that `null` is never used for the
cache key. Prior to this commit, calling `forDefaultResourceLocation`
with `null` and `ClassUtils.getDefaultClassLoader()` would provide
different `SpringFactoriesLoader` instances rather than making use
of a single shared cached instance.

See gh-28416
2022-05-10 16:07:50 -07:00
Sam Brannen 5f8a4bcdc5 Merge branch '5.3.x'
# Conflicts:
#	spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java
#	spring-context/src/main/java/org/springframework/scripting/support/StandardScriptFactory.java
2022-05-09 20:08:37 +02:00
Sam Brannen e26d8839b3 Stop referring to features as Java 6/7 features where unnecessary 2022-05-09 19:09:06 +02:00
Juergen Hoeller 2b65f274dc Use Set.of instead of HashSet with Arrays.asList 2022-05-06 16:19:27 +02:00
Sam Brannen 8627bef8d9 Polishing 2022-05-06 16:02:42 +02:00
Phillip Webb 16e7f1f212 Complete refactor of AOT concepts
Remove the AOT code that now has an alternative API.

Closes gh-28414
2022-05-05 13:34:52 -07:00
Phillip Webb c5c68a4662 Add MethodReference support
Add a `MethodReference` class which can be used to refer to a
static or instance method.

See gh-28414
2022-05-05 13:25:36 -07:00
Phillip Webb 1816c77c51 Add generation context interface
Add `GenerationContext` interface and `DefaultGenerationContext`
implementation as the central entry point for AOT processing.

See gh-28414
2022-05-05 13:25:36 -07:00
Phillip Webb d5374550e5 Add support for generating classes
Add `ClassGenerator` and `GeneratedClass` which can be used to
generated classes that will ultimately be written to a `JavaFile`.

See gh-28414
2022-05-05 13:25:36 -07:00
Phillip Webb 55d7f7a014 Add support for generating methods
Add `GeneratedMethods` and `GeneratedMethod` support classes which
can be used during code generation to generation additional methods
that will ultimately be included in a `JavaFile`.

See gh-28414
2022-05-05 13:25:36 -07:00
Phillip Webb 16456342f5 Add support for generating method names
Add `MethodNameGenerator` to support generation of method names.

See gh-28414
2022-05-05 13:25:36 -07:00
Phillip Webb ca2b5e068b Add support for generating class names
Add `ClassNameGenerator` to support generation of class names.

See gh-28414
2022-05-05 13:25:36 -07:00
Phillip Webb a605d3f6ed Add AccessVisibility detection support
Add `AccessVisibility` enum which can be used to determine the
access visibility of `Member` or `ResolvableType`.

See gh-28414
2022-05-05 13:25:36 -07:00
Phillip Webb 99173fbd4f Add GeneratedFiles interface and support classes
Add a `GeneratedFiles` interface that can be used to add generated
source, class and resource files. An in-memory implementation is
provided for testing and a filesystem implementation is provided
to actually save the files to disk.

See gh-28414
2022-05-05 13:25:36 -07:00
Phillip Webb b3efdf3c2b Add Throwable functional interfaces
Add 'Throwable' variants of the `Consumer`, `Function`, `BiFunction` and
`Supplier` interfaces that wrap checked exceptions or allow calls to be
made that throw them.

Closes gh-28417
2022-05-05 12:35:21 -07:00
Phillip Webb 58c441f961 Support multiple SpringFactoriesLoader files
Update `SpringFactoriesLoader` so that it can load files from
arbitrary locations. An instance of the loader class itself is now
returned from static factory methods that accept different
locations.

The recent `ArgumentResolver` and `FailureHandler` `loadFactories`
variants are now no longer available as static methods. They are
still available as instance methods.

The `loadFactories` static method remains to provide
back-compatibility with Spring Framework 5.x

See gh-28416
2022-05-05 12:35:21 -07:00
Phillip Webb f17372ebea Add position variant of ObjectUtils.addObjectToArray
Add an overloaded version of `ObjectUtils.addObjectToArray` that allows
inserts at a specific position.

Closes gh-28415
2022-05-05 12:35:21 -07:00
Juergen Hoeller bf4e3975fb Merge branch '5.3.x'
# Conflicts:
#	build.gradle
2022-05-05 18:07:39 +02:00
Juergen Hoeller f771603789 Polishing 2022-05-05 18:04:54 +02:00
Juergen Hoeller b55eee1b0d Upgrade to ASM 9.3
Closes gh-28390
2022-05-05 18:01:53 +02:00
Juergen Hoeller 122ca4dd98 Assert with isEqualToNormalizingNewlines for Windows compatibility 2022-05-05 17:26:33 +02:00
Sam Brannen 62fcf5e60d Merge branch '5.3.x' 2022-05-05 16:23:19 +02:00
Sam Brannen ab71ff93bb Polish package-info for org.springframework.util
See gh-28411
2022-05-05 16:22:52 +02:00
neals cf30327740 Remove Log4J configurer from package-info.java in spring-core
Closes gh-28411
2022-05-05 16:16:49 +02:00
Stephane Nicoll 5378572b00 Clarify lambda code block methods 2022-04-26 15:13:43 +02:00
Stephane Nicoll 26054fd3d4 AOT contribution for @PersistenceContext and @PersistenceUnit
Closes gh-28364
2022-04-25 11:01:09 +02:00
Stephane Nicoll 10d254983f Refine MultiStatement#toClodeBlock
Closes gh-28363
2022-04-25 09:13:50 +02:00
Stephane Nicoll ccb66247ce Merge branch '5.3.x' 2022-04-24 10:05:35 +02:00
izeye fcf64798b5 Add Javadoc since for GraphQL constants
See gh-28369
2022-04-24 09:58:50 +02:00
Stephane Nicoll f40a391916 Fix handling of reflection target name in TypeReference
This commit adds a `getName` to `TypeReference` that provides a way to
generate the reflection target name of a type. This typically handle
primitives (omitting the `java.lang` packages) and arrays.

Closes gh-28347
2022-04-15 11:47:25 +02:00
Brian Clozel 38019d2249 Allow static registration of RuntimeHints
Prior to this commit, we could only contribute `RuntimeHints` through
two mechanisms:
* `AotContributingBeanFactoryPostProcessor`, consdering the entire
  `BeanFactory` and designed for contributing both code and hints.
* `AotContributingBeanPostProcessor`, consdering beans one by one, but
  also designed for contributing both code and hints.

There are cases where libraries and applications want to contribute
`RuntimeHints` only, in a more static fashion: a dependency being
present, or a piece of infrastructure being considered by the
application context are good enough signals to contribute hints about
resources or reflection.

This commit adds the `RuntimeHintsRegistrar` contract for these cases.
Implementations can be declared as `spring.factories` and they will be
processed as soon as they're detected on the classpath. They can also be
declared with `@ImportRuntimeHints` and they will be processed if the
annotated bean definition is considered in the application context.
This annotation should be mainly used on configuration classes and on
bean methods.

```
@Configuration
@ImportRuntimeHints(CustomRuntimeHintsRegistrar.class)
public class MyConfiguration {

  @Bean
  @ImportRuntimeHints(OtherRuntimeHintsRegistrar.class)
  public MyBean myBean() {
    //...
  }
}
```

Closes gh-28160
2022-04-14 13:06:43 +02:00
Stephane Nicoll 5be6b3d2a7 Add shortcut method to register multiple types hints
Closes gh-28339
2022-04-14 10:22:07 +02:00