Commit Graph

128 Commits

Author SHA1 Message Date
Andy Clement 813cc3b339 Fix compilation of SpEL Indexer nodes involving map references
There is special handling for SpEL expressions involving a map
and an unquoted string literal key (e.g. mymap[key1]). SpEL does
not require key1 to be quoted. This special handling which is done
in Indexer getValueRef() was not being also done in the Indexer
generateCode() method that compiles the expression. Also fixed
a problem where the key was not being compiled in a new
sub scope. Without the new scope the key expression was failing
to reload the relevant context object when it needed it.

Issue: SPR-12045
2014-07-30 12:48:54 -07:00
Andy Clement d30174897d Support compilation of the SpEL operator OpModulus
This commit enables the modulus operator to be compiled when
it is used as part of a SpEL expression.

Issue: SPR-12041
2014-07-29 12:34:44 -07:00
Andy Clement 59080ff2b2 Cope with generic methods during SpEL compilation
This commit allows the SpEL compiler to cope with generic methods
being used in expressions involving numeric operands. Due to the
use of unbound type variables the methods may look like they
return Object but in fact they are returning objects of a numeric
type that are suitable for compilation. The changes here ensure
the runtime types are looked at if the discovered declared types
are not providing enough information. This impacts all the
operands involving numerics (mathematical and relational).

Issue: SPR-12040
2014-07-29 11:02:56 -07:00
Juergen Hoeller 4b09fcc67c Revised exitTypeDescriptor handling to avoid NPEs
Issue: SPR-12014
2014-07-22 16:24:39 +02:00
Juergen Hoeller 9d6c38bd54 Consistent bracket alignment 2014-07-18 17:21:58 +02:00
Juergen Hoeller bad74dc836 Revision of SpelCompiler support, resolving a subpackage cycle through moving CodeFlow and CompilablePropertyAccessor to the main spel package
Also contains explicit ClassLoader management, passed through StandardBeanExpressionResolver and SpelParserConfiguration to SpelCompiler lookup.

Issue: SPR-10943
2014-07-16 14:41:46 +02:00
Andy Clement 2eeb2e9235 Add a compiler for SpEL
With these changes an optional compiler is added for SpEL
expressions. The compiler is off by default but can be enabled
via the SpEL parser configuration object or system property
(when SpEL is embedded and parser configuration is not possible).
Not all expressions are currently handled but the common
cases are and it is an extensible compilation framework.

Issue: SPR-10943
2014-07-10 17:49:05 +01:00
Juergen Hoeller b559f15a00 Polishing 2014-07-07 21:45:40 +02:00
Juergen Hoeller a8848cb670 TypedValue implements equals/hashCode based on value and TypeDescriptor
Issue: SPR-11960
2014-07-07 11:29:29 +02:00
Juergen Hoeller b0f0d2f289 Polishing 2014-05-15 14:39:06 +02:00
Juergen Hoeller 6cb45f714e General defensiveness about the bootstrap ClassLoader (i.e. null ClassLoader)
Issue: SPR-11721
(cherry picked from commit 59cef3c)
2014-04-28 00:47:21 +02:00
Philippe Marschall 84f6d17c7b Clean up spring-expression tests warnings
Clean up compiler warnings in the tests of spring-expression. This
commit adds type parameters to some of the types (mostly `List` and
`Map`). Some of them can't be cleaned up, some tests are even
specifically for raw types.
2014-04-22 07:30:17 +02:00
Juergen Hoeller 66bae99d86 EQ/NE do not fail in case of a Comparable mismatch and apply a specific CharSequence equality check
Issue: SPR-11708
2014-04-21 23:29:40 +02:00
Sam Brannen d9ee44cd7c Clean up warnings that show up in Gradle build 2014-04-06 16:25:28 +02:00
Juergen Hoeller 3af8a3260a Correctly resolve accessors for static properties on Class
Issue: SPR-11609
2014-03-26 21:46:38 +01:00
Stephane Nicoll 4cd818b9e4 Harmonize log configuration
Prior to this commit, the codebase was using a mix of log4j.xml
and log4j.properties for test-related logging configuration. This
can be an issue as log4j takes the xml variant first when looking
for a default bootstrap configuration.

In practice, some modules declaring the properties variant were
taking the xml variant configuration from another module.

The general structure of the configuration has also been
harmonized to provide a standard console output as well as an
easy way to enable trace logs for the current module.
2014-03-20 09:43:29 -07:00
Juergen Hoeller 4d3ca4319e Polishing 2014-03-11 22:09:46 +01:00
Juergen Hoeller 27cacf0672 SpEL property-not-found message hints at non-public method/field
Issue: SPR-11535
(cherry picked from commit eeb82c4)
2014-03-11 11:20:29 +01:00
Juergen Hoeller 40b81fcc3e SPR11348 test should use LinkedHashSet since it relies on insertion order of elements 2014-03-10 13:33:56 +01:00
Stephane Nicoll 519799e1cf Fix double SPeL evaluation of parameter
When a node of an SPeL expression was a call to a bean referenced
 in a method argument, the expression was resolved twice.

 The resolved arguments are now specified to MethodValueRef instead
 of resolving the arguments again in the constructor

 Issue: SPR-11445
2014-03-06 15:11:22 +01:00
Juergen Hoeller 2a2816dfc3 Restored proper handling of varargs in case of unresolvable type variable
Fixed through falling back to the raw parameter type in the TypeDescriptor(MethodParameter) constructor, properly detecting the vararg array even in case of an unresolvable type variable, and through restoring getElementTypeDescriptor's original behavior for arrays, i.e. always returning a non-null descriptor.

Issue: SPR-11494
2014-03-05 22:36:12 +01:00
Phillip Webb 7efd54e243 Additional caching for ResolvableTypes
Add additional caching to ResolvableTypes and SerializableTypeWrapper
in order to improve SpEL performance.

Issue: SPR-11388
2014-02-18 15:27:28 -08:00
Juergen Hoeller 14e5a02870 Mixed polishing along with recent changes 2014-02-14 21:39:40 +01:00
Sam Brannen c335e99e3f Remove trailing whitespace from source code 2014-02-08 17:30:39 +01:00
Sam Brannen 1f778530b5 Polish test classes
- Consistent importing of org.junit.Assert.*;
- Proper declaration of expected exceptions via @Test(expected).
- Renamed SpEL ExpressionTestCase to AbstractExpressionTests.
- Formatting and test method naming conventions.
2014-02-08 17:24:11 +01:00
Juergen Hoeller 426f52b393 Polishing 2014-02-06 20:35:59 +01:00
Juergen Hoeller 42db41e007 Polishing 2014-01-23 20:59:53 +01:00
Juergen Hoeller 86fc2dd556 Fixed regression in SpEL's constructor resolution
Issue: SPR-11348
2014-01-23 20:52:21 +01:00
Juergen Hoeller 6f5a7f65ac Polishing 2014-01-16 18:18:00 +01:00
Juergen Hoeller 6051ea8ae3 Polishing 2014-01-16 16:54:49 +01:00
Juergen Hoeller 838855b1aa Fixed accidental use of JDK 1.7+ Integer/Long.compare methods
Issue: SPR-11319
2014-01-16 16:54:40 +01:00
Juergen Hoeller 8da9e5466a Turned ArgumentsMatchKind and ArgumentsMatchInfo to package-visible 2014-01-15 15:28:20 +01:00
Juergen Hoeller 5d06bcec70 Fixed getTypeDifferenceWeight algorithm in ReflectionHelper, and removed unused argsRequiringConversion storage
Issue: SPR-11306
2014-01-15 13:36:50 +01:00
Juergen Hoeller 3bed6cfc7c Activated through rename to *Tests, and added method call interaction tests
Issue: SPR-7831
2014-01-03 22:11:12 +01:00
Juergen Hoeller 234272eb8f Polishing
Issue: SPR-11215
2013-12-17 21:39:40 +01:00
Juergen Hoeller 67abeb4722 SpEL performs String->String type conversion even within concatenated String
Issue: SPR-11215
2013-12-17 21:35:14 +01:00
Phillip Webb 85b0bfff58 Only consider "is" methods with boolean returns
Fix regression introduced in b25e91a5 where ReflectivePropertyAccessor
does not consider the return type for "is" getters.

Issue: SPR-11142
2013-12-03 12:01:24 -08:00
Phillip Webb 043a41e382 Consistent whitespace after imports
Update code to have a consistent number of new-line characters after
import statements.
2013-11-26 15:14:43 -08:00
Phillip Webb 59002f2456 Fix remaining compiler warnings
Fix remaining Java compiler warnings, mainly around missing
generics or deprecated code.

Also add the `-Werror` compiler option to ensure that any future
warnings will fail the build.

Issue: SPR-11064
2013-11-25 12:52:42 -08:00
giovannidalloglio d0ab131a57 Add BigDecimal support for SpEl numeric operations
Prior to this change, SpEL supported numeric operations for int, float,
ect. `new java.math.BigDecimal('0.1') > 0` evaluated to false
(BigDecimal is truncated to int)

This commit introduces support for BigDecimal operations for all
mathematical operators. `new java.math.BigDecimal('0.1') > 0` now
evaluates to true (the comparison is made with BigDecimals)

Issue: SPR-9164
2013-11-21 14:28:29 -08:00
Andy Clement 2a05e6afa1 Change SpEL equality operators to use .equals
Prior to this commit the SpEL operators `==` and `!=` were using the
Java `==` comparison operator as part of their equality checking. It is
more flexible to use the equals() method on Object.

Under this commit the change to .equals() has been made and the equality
checking code has been pushed into a common method in the Operator
superclass. This commit also makes some tweaks to the other operator
classes - the Float case was missing from OpGT.

Issue: SPR-9194
2013-11-21 12:06:31 -08:00
Phillip Webb 014d156f5b Make EvaluationException more informative
Update EvaluationException to expose the toDetailedString() method as
the exception message. The simple message can now be accessed via the
new getSimpleMessage() method.

Issue: SPR-10938
2013-10-25 17:55:02 -07:00
Juergen Hoeller 4aab31531b ExpressionState.getConfiguration() should never return null
Issue: SPR-11031
2013-10-26 00:01:31 +02:00
Phillip Webb 6d882b149d Add targetIsClass to SpEL property cache key
Update the `CacheKey` class used by `ReflectivePropertyAccessor` to
include if the target object is class. The prevents an incorrect cache
hit from being returned when a property with the same name is read on
both an object and its class. For example:

	#{class.name}
	#{name}

Issue: SPR-10486
2013-10-21 11:02:09 -07:00
Phillip Webb 686cd79bdd Propagate EvaluationContext from LiteralExpression
Update getValue(EvaluationContext context, Object rootObject,
Class<T> desiredResultType) to propagate the EvaluationContext to
ExpressionUtils.

Issue: SPR-10953
2013-10-18 17:52:31 -07:00
Phillip Webb b25e91a550 Relax JavaBean rules for SpEL property access
Relax the method search algorithm used by `ReflectivePropertyAccessor`
to include methods of the form `getXY()` for properties of the form
`xy`.

Although the JavaBean specification indicates that a property `xy`
should use the accessors `getxY()` and `setxY()`, in practice many
developers choose to have an uppercase first character. The
`ReflectivePropertyAccessor` will now consider these style methods if
the traditional conventions fail to find a match.

Issue: SPR-10716
2013-10-18 16:20:57 -07:00
Clément Plantier 824ac535d2 Fix "Problem locating method" SpEL error message
Replace "Problem locating method {0} cannot on type {1}" with
"Problem locating method {0} on type {1}".

Issue: SPR-10928
2013-09-20 11:38:51 -07:00
Juergen Hoeller c54b6e9e82 Polished exception message
(cherry picked from commit 6110919)
2013-09-04 22:33:31 +02:00
Juergen Hoeller baa698eddf Polishing
Issue: SPR-9495
2013-09-04 16:44:07 +02:00
Juergen Hoeller b7ff26aafb Only cache resolved method when coming from ReflectiveMethodResolver
Issue: SPR-9495
2013-09-04 16:43:51 +02:00