Commit Graph

3413 Commits

Author SHA1 Message Date
Juergen Hoeller
8b589db028 Avoid NoSuchMethodException for annotation attribute checks
Closes gh-32921

(cherry picked from commit b08883b65c)
2024-06-03 12:51:47 +02:00
Juergen Hoeller
206a89017c Test detection of original generic method for CGLIB bridge method
See gh-32888
2024-05-24 12:29:31 +02:00
Juergen Hoeller
c8c95e360f Polishing (aligned with 6.1.x) 2024-05-15 14:31:48 +02:00
Juergen Hoeller
4caf6bc5b8 Polishing 2024-05-14 13:45:38 +02:00
Juergen Hoeller
ee3e1591de Polishing 2024-05-14 13:03:35 +02:00
Juergen Hoeller
77951dc622 Consistent RuntimeHintsRegistrar signature (plus related polishing) 2024-05-07 15:43:17 +02:00
Juergen Hoeller
43dd22ba31 Polishing
(cherry picked from commit 05d9b52b19)
2024-05-06 20:28:41 +02:00
Sam Brannen
9c775d2643 Fix compilation error in test 2024-05-03 12:40:14 +03:00
Sam Brannen
3b50b6ef94 Include repeatable annotation container in MergedAnnotations results
A bug has existed in Spring's MergedAnnotations support since it was
introduced in Spring Framework 5.2. Specifically, if the
MergedAnnotations API is used to search for annotations with "standard
repeatable annotation" support enabled (which is the default), it's
possible to search for a repeatable annotation but not for the
repeatable annotation's container annotation.

The reason is that MergedAnnotationFinder.process(Object, int, Object,
Annotation) does not process the container annotation and instead only
processes the "contained" annotations, which prevents a container
annotation from being included in search results.

In #29685, we fixed a bug that prevented the MergedAnnotations support
from recognizing an annotation as a container if the container
annotation declares attributes other than the required `value`
attribute. As a consequence of that bug fix, since Spring Framework
5.3.25, the MergedAnnotations infrastructure considers such an
annotation a container, and due to the aforementioned bug the container
is no longer processed, which results in a regression in behavior for
annotation searches for such a container annotation.

This commit addresses the original bug as well as the regression by
processing container annotations in addition to the contained
repeatable annotations.

See gh-29685
Closes gh-32731

(cherry picked from commit 4baad16437)
2024-05-03 12:19:27 +03:00
Juergen Hoeller
f7b7e29fd7 Ignore non-String keys in PropertiesPropertySource.getPropertyNames()
Closes gh-32742

(cherry picked from commit 610626aec6)
2024-05-01 15:45:21 +02:00
Juergen Hoeller
9d2c6f80b8 Polishing 2024-04-23 16:25:24 +02:00
Juergen Hoeller
5c9f364352 Polishing
(cherry picked from commit ec1f5ca600)
2024-04-22 14:07:51 +02:00
Juergen Hoeller
55f9581743 Try early initialization for all user-declared methods (including interfaces)
Closes gh-32682

(cherry picked from commit 62efdfb89c)
2024-04-22 13:51:15 +02:00
Sam Brannen
7d178c6771 Detect bridge methods across ApplicationContexts in MethodIntrospector
Prior to this commit, MethodIntrospector failed to properly detect
bridge methods for subsequent invocations of selectMethods() with the
same targetType and MetadataLookup, if such subsequent invocations
occurred after the ApplicationContext had been refreshed.

The reason this occurs is due to the following.

- Class#getDeclaredMethods() always returns "child copies" of the
  underlying Method instances -- which means that `equals()` should be
  used instead of `==` whenever the compared Method instances can come
  from different sources (such as the static caches mentioned below).

- BridgeMethodResolver caches resolved bridge methods in a static cache
  -- which is never cleared.

- ReflectionUtils caches declared methods in a static cache
  -- which gets cleared when an ApplicationContext is refreshed.

Consequently, if you attempt to load an ApplicationContext twice in the
same ClassLoader, the second attempt uses the existing, populated cache
for bridged methods but a cleared, empty cache for declared methods.
This results in new invocations of Class#getDeclaredMethods(), and
identity checks with `==` then fail to detect equivalent bridge methods.

This commit addresses this by additionally comparing bridge methods
using `equals()` in MethodIntrospector.selectMethods().

Note that the `==` checks remain in place as an optimization for when
`equals()` is unnecessary.

Closes gh-32586

(cherry picked from commit e702733c7b)
2024-04-09 19:05:53 +02:00
Juergen Hoeller
eea00628f9 Polishing 2024-03-18 16:22:03 +01:00
Sam Brannen
ed6c25fb6e Avoid unnecessary Annotation array cloning in TypeDescriptor
Closes gh-32476

(cherry picked from commit 42a4f28962)
2024-03-18 15:18:43 +01:00
Juergen Hoeller
8460a2d285 Restore original toString representation (revert accidental backport)
See gh-32405
2024-03-17 20:43:07 +01:00
Juergen Hoeller
c3d186b4d0 Remove superfluous @NonNull declarations 2024-03-16 14:23:12 +01:00
Juergen Hoeller
f8926d6a66 Avoid cloning empty Annotation array in TypeDescriptor (backport)
Closes gh-32405
2024-03-16 14:23:06 +01:00
Juergen Hoeller
a3647a8c5e Polishing
(cherry picked from commit 723c94e5ac)
2024-03-12 20:26:24 +01:00
Juergen Hoeller
40d5196243 Polishing 2024-03-08 19:40:45 +01:00
Juergen Hoeller
9ac1feceb5 Restore ability to return original method for proxy-derived method
Closes gh-32365
2024-03-04 23:32:27 +01:00
Juergen Hoeller
7029042e44 Polishing
(cherry picked from commit e9110c0729)
2024-03-04 23:31:51 +01:00
Juergen Hoeller
8fba4a448a Polishing 2024-02-16 22:41:50 +01:00
Simon Baslé
70be04ba81 Infer reflection hints for Jackson annotations builder attributes
This notably enables Jackson to reflectively call a user-provided
builder class and invoke its declared methods (setters and build) in
a native app.

See gh-32238
Closes gh-32257
2024-02-13 15:16:04 +01:00
Juergen Hoeller
72835f10b9 Polishing 2024-02-01 14:58:13 +01:00
Arjen Poutsma
0c22866b72 Ensure correct capacity in DefaultDataBuffer
See gh-31873
Closes gh-31979
2024-01-09 10:40:41 +01:00
Juergen Hoeller
1b4a4ac51f Polishing 2024-01-06 23:21:57 +01:00
Juergen Hoeller
dd0d26b4ba Refine exception handling for type not present versus access exception
Includes TypeVariable bypass for reflection-free annotation retrieval.
Includes info log message for annotation attribute retrieval failure.

Closes gh-27182

(cherry picked from commit 70247c4a94)
2024-01-06 23:10:30 +01:00
Juergen Hoeller
198cf063fd Polishing 2023-12-30 11:45:34 +01:00
Juergen Hoeller
033c8df53f Polishing 2023-12-22 12:54:16 +01:00
Arjen Poutsma
b272f4e615 Correctly set capacity of remainder in DefaultDataBuffer::split
This commit ensures that the capacity of the remainder buffer after a
split operation is set directly on the field. Calling capacity(int)
caused a new buffer to be allocated.

See gh-31848
Closes gh-31859
2023-12-18 11:50:30 +01:00
Sam Brannen
1e742aae34 Scan annotations on method in interface hierarchy only once
Prior to this commit, the AnnotationsScanner used in the
MergedAnnotations infrastructure found duplicate annotations on methods
within multi-level interface hierarchies.

This commit addresses this issue by scanning methods at a given level
in the interface hierarchy using ReflectionUtils#getDeclaredMethods
instead of Class#getMethods, since the latter includes public methods
declared in super-interfaces which will anyway be scanned when
processing super-interfaces recursively.

Closes gh-31803

(cherry picked from commit 75da9c3c47)
2023-12-12 18:39:38 +01:00
Sam Brannen
20dd585c93 Polish MergedAnnotation tests
(cherry picked from commit 952223dcf9)
2023-12-12 18:38:06 +01:00
Juergen Hoeller
627d9cf8be Polishing 2023-12-10 00:26:22 +01:00
Sam Brannen
85cc229063 Fix and polish Javadoc for MimeTypeUtils
(cherry picked from commit 1afea0b144)
2023-12-06 14:31:35 +01:00
Johnny Lim
fa95f12be0 Fix condition for "Too many elements" in MimeTypeUtils.sortBySpecificity()
See gh-31254
See gh-31769
Closes gh-31773

(cherry picked from commit 7b95bd72f7)
2023-12-06 14:31:16 +01:00
Juergen Hoeller
6fae3e150e Consider generics in equals method (for ConversionService caching)
Closes gh-31672

(cherry picked from commit 710373d286)
2023-11-24 23:29:02 +01:00
“7fantasy7”
ed613e767a Skip buffer in StreamUtils#copy(String)
(cherry picked from commit 54f87f1ff7)
2023-11-20 21:30:01 +01:00
Stéphane Nicoll
0fc38117df Handle default package with AOT processing
Adding generated code in the default package is not supported as we
intend to import it, most probably from another package, and that is
not supported. While this situation is hard to replicate with Java,
Kotlin is unfortunately more lenient and users can end up in that
situation if they forget to add a package statement.

This commit checks for the presence of a valid package, and throws
a dedicated exception if necessary.

Closes gh-31629
2023-11-20 11:54:55 +01:00
Juergen Hoeller
e5f04e5ddf Polishing 2023-11-16 11:34:31 +01:00
Stéphane Nicoll
d93114df9a Polish "Provide invalid class name in exception message"
See gh-31612
2023-11-15 20:45:24 +01:00
PiotrFLEURY
5ac4c3bd76 Provide invalid class name in exception message
See gh-31612
2023-11-15 20:40:45 +01:00
rstoyanchev
05c3ffb2fb Use InvalidMimeTypeException in MimeTypeUtils#sortBySpecificity
Closes gh-31254
2023-11-15 18:57:23 +00:00
Arjen Poutsma
8868fe2ea5 Fix position bug in NettyDataBuffer::toByteBuffer
Closes gh-31605
2023-11-15 14:23:43 +01:00
Sam Brannen
e71117dcdf Polish contribution
See gh-31598
2023-11-14 14:46:34 +01:00
Jason
d5874ab99e Avoid duplicate resources in PathMatchingResourcePatternResolver on Windows
This commit updates PathMatchingResourcePatternResolver to avoid
returning duplicate resources on MS Windows when searching using the
`classpath*:` prefix and a wildcard pattern that matches resources
which are directly present in a JAR as well as present via classpath
manifest entries.

Closes gh-31598
2023-11-14 14:39:48 +01:00
Sébastien Deleuze
620f558547 Register hints for superclass in BindingReflectionHintsRegistrar
Closes gh-31552
2023-11-09 13:11:36 +01:00
lorenzsimon
6a7a0bddb7 Restore support for recursive annotations in Kotlin
This commit reinstates support for recursive annotations in Kotlin.

See gh-28012
See gh-28618
See gh-31400
Closes gh-31518
2023-11-08 13:28:28 +01:00
Sam Brannen
5752e03d97 Polishing 2023-11-07 16:58:21 +01:00