Commit Graph

412 Commits

Author SHA1 Message Date
Sam Brannen
4c246b7c96 Consistently use canonical annotation names in string representations 2024-03-10 15:54:53 +01:00
Stéphane Nicoll
e53ed3e3c6 Merge branch '6.1.x' 2024-03-09 16:03:04 +01:00
Stéphane Nicoll
4983a802a7 Polish "Fix Javadoc"
See gh-32403
2024-03-09 16:02:01 +01:00
Maksim Sasnouski
abdccffa39 Fix Javadoc
This commit fixes various Javadoc issues across the code base.

See gh-32403
2024-03-09 16:02:00 +01:00
Sam Brannen
65d77624d1 Support SpEL compilation for public methods in private subtypes
Commit c79436f832 ensured that methods are invoked via a public
interface or public superclass when compiling Spring Expression
Language (SpEL) expressions involving method references or property
access (see MethodReference, PropertyOrFieldReference, and
collaborating support classes). However, compilation of expressions
that access properties by indexing into an object by property name is
still not properly supported in all scenarios.

To address those remaining use cases, this commit ensures that methods
are invoked via a public interface or public superclass when accessing
a property by indexing into an object by the property name – for
example, `person['name']` instead of `person.name`.

In addition, SpEL's Indexer now properly relies on the
CompilablePropertyAccessor abstraction instead of hard-coding support
for only OptimalPropertyAccessor. This greatly reduces the complexity
of the Indexer and simultaneously allows the Indexer to potentially
support other CompilablePropertyAccessor implementations.

Closes gh-29857
2024-03-09 14:01:00 +01:00
Sam Brannen
107f47cfcf Add tests for status quo for SpEL compiler 2024-03-09 13:46:39 +01:00
Sam Brannen
3577e3b758 Polish SpEL internals and tests 2024-03-08 17:49:58 +01:00
Sam Brannen
90867e7e62 Merge branch '6.1.x' 2024-03-08 15:50:29 +01:00
Sam Brannen
fea1464562 Ensure SpEL can compile an expression indexing into a boolean array
Closes gh-32400
2024-03-08 15:32:57 +01:00
Sam Brannen
c79436f832 Support SpEL compilation for public methods in private subtypes
Although the Spring Expression Language (SpEL) generally does a good
job of locating the public declaring class or interface on which to
invoke a method in a compiled expression, prior to this commit there
were still a few unsupported use cases.

To address those remaining use cases, this commit ensures that methods
are invoked via a public interface or public superclass whenever
possible when compiling SpEL expressions.

See gh-29857
2024-03-07 16:20:50 +01:00
Sam Brannen
9eea768205 Polish SpEL internals 2024-03-06 11:31:10 +01:00
Sam Brannen
b44c31e997 Polishing 2024-03-05 12:01:55 +01:00
Sam Brannen
4a6dbb17f4 Merge branch '6.1.x' 2024-03-03 14:51:01 +01:00
Sam Brannen
380184e85a Support SpEL compilation of #root or #this with non-public type
Prior to this commit, if a Spring Expression Language (SpEL) expression
referenced the root context object via the #root or #this variable, we
inserted a checkcast in the generated byte code that cast the object to
its concrete type. However if the root context object's type was
non-public, that resulted in an IllegalAccessError when the compiled
byte code was executed.

VariableReference.getValueInternal() already contains a solution for
global variables which inserts a checkcast to Object in the generated
byte code instead of to the object's concrete non-public type.

This commit therefore applies the same logic to #root (or #this when
used to reference the root context object) that is already applied to
global variables.

Closes gh-32356
2024-03-03 14:49:42 +01:00
Sam Brannen
a29c84f663 Merge branch '6.1.x' 2024-03-02 18:08:27 +01:00
Sam Brannen
11c40b5c1c Restructure SpEL indexer compilation tests 2024-03-02 18:03:44 +01:00
Sam Brannen
fdbefad59c Improve documentation for SpEL indexing support
Prior to this commit, the reference manual only documented indexing
support for arrays, lists, and maps.

This commit improves the overall documentation for SpEL's property
navigation and indexing support and introduces additional documentation
for indexing into Strings and Objects.

Closes gh-32355
2024-03-01 18:08:29 +01:00
Sam Brannen
9c610d9a70 Spring cleaning: remove unnecessary semicolon 2024-02-23 12:21:22 +01:00
Sam Brannen
734fc476ee Polish SpEL's Indexer and test 2024-02-21 17:44:09 +01:00
Sam Brannen
d4cde29f75 Clean up TODOs in SpEL 2024-02-17 15:33:05 +01:00
Sam Brannen
ab48ac36e9 Deprecate local variable support in SpEL's internal ExpressionState
Since the Spring Expression Language does not actually support local
variables in expressions, this commit deprecates all public APIs
related to local variables in ExpressionState (namely, the two
enterScope(...) variants that accept local variable data,
setLocalVariable(), and lookupLocalVariable()).

In addition, we no longer invoke `state.enterScope("index", ...)` in
the Projection and Selection AST nodes since the $index local variable
was never accessible within expressions anyway.

See gh-23202
Closes gh-32004
2024-02-16 18:29:00 +01:00
Sam Brannen
4a3ef3e24a Document safe navigation semantics within compound expressions in SpEL
Closes gh-21827
2024-02-11 18:36:14 +01:00
Sam Brannen
4a5dc7c1b0 Document null-safe collection selection/projection support in SpEL
Closes gh-32208
2024-02-11 17:21:47 +01:00
Sam Brannen
347d085020 Polishing 2024-02-11 17:14:24 +01:00
Sam Brannen
f295def2a8 Include function name in SpelMessage.INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION
Closes gh-32239
2024-02-11 13:52:25 +01:00
Sam Brannen
dc2dbd9700 Polishing 2024-02-11 13:52:25 +01:00
Sam Brannen
6b67972ec4 Polishing 2024-02-10 16:56:02 +01:00
Sam Brannen
64fc9ee301 Test function registration with SimpleEvaluationContext 2024-02-10 16:55:21 +01:00
Sam Brannen
dc73ec76fc Address TODOs in SpEL's Indexer
This commit deletes outdated TODOs and addresses a remaining "current"
TODO in SpEL's Indexer.
2024-02-10 15:39:18 +01:00
Sam Brannen
888e50175d Polish SpEL Javadocs and internals 2024-02-10 15:39:18 +01:00
Sam Brannen
e72b523995 Polish SpEL support 2024-02-09 14:04:08 +01:00
Sam Brannen
78c96b6d78 Fix SpEL collection selection/projection examples in reference manual
This commit also updates and polishes the documentation tests.
2024-02-07 18:49:01 +01:00
Sam Brannen
43bbe8f3e8 Add tests for collection selection with Iterables 2024-02-07 13:32:22 +01:00
Sam Brannen
7d612e8958 Polishing 2024-02-07 13:29:33 +01:00
Sam Brannen
9a38355896 Improve tests for indexing and collection selection/projection in SpEL 2024-02-07 11:46:13 +01:00
Sam Brannen
7025b7aac2 Provide example for calculating Integer.MIN_VALUE with SpEL's power operator 2024-02-02 14:43:56 +01:00
Sam Brannen
1e432ff95d Improve documentation for overloaded operators in SpEL
See gh-32182
2024-02-02 14:39:09 +01:00
Sam Brannen
af2934c09b Document support for overloading operators in SpEL in reference manual
Closes gh-32182
2024-02-01 17:24:25 +01:00
Sam Brannen
17ee82e004 Organize and clean up SpEL documentation tests 2024-02-01 16:22:14 +01:00
Sam Brannen
2b52582dff Polishing 2024-01-31 16:41:15 +01:00
Sam Brannen
db535863dd Consistently use class literals for primitive types
To improve consistency and avoid confusion regarding primitive types
and their wrapper types, this commit ensures that we always use class
literals for primitive types.

For example, instead of using the `Void.TYPE` constant, we now
consistently use `void.class`.
2024-01-30 15:26:12 +01:00
Sam Brannen
84cce6018c Document the between operator in SpEL
Closes gh-32140
2024-01-29 18:34:12 +01:00
Sam Brannen
0ee2d41528 Delete obsolete test utility method
Commit dc6ce30663 made this method obsolete.
2024-01-28 18:44:56 +01:00
Sam Brannen
dc6ce30663 Polishing 2024-01-28 18:31:31 +01:00
Sam Brannen
62fa3f11c1 Correctly request primitive conversion in SpEL's Indexer
Prior to this commit, SpEL's Indexer incorrectly requested conversion
to wrappers instead of primitives when setting an element in a
primitive array.

This commit addresses this by requesting primitive conversion -- for
example, conversion to `int.class` instead of `Integer.class` when
setting a value in an `int[]` array.

For greater clarity, this commit also switches from using `TYPE`
constants in wrapper classes to primitive class literals -- for
example, from `Integer.TYPE` to `int.class`.

Closes gh-32147
2024-01-28 18:26:39 +01:00
Sam Brannen
9b0162da49 Document increment and decrement operators in SpEL
Closes gh-32136
2024-01-28 16:43:55 +01:00
Sam Brannen
ab98210e6d Polishing 2024-01-28 16:43:55 +01:00
Sam Brannen
97ad479250 Sync assignment operator test with example used in reference manual 2024-01-28 16:43:15 +01:00
Sam Brannen
24d6565cad Provide example for SpEL's exponential power operator (^) 2024-01-28 16:43:15 +01:00
Sam Brannen
e34ad6bf5f Support prefix notation for SpEL increment/decrement in AST representation
Closes gh-32144
2024-01-28 15:21:07 +01:00