Commit Graph

158 Commits

Author SHA1 Message Date
Juergen Hoeller
b2d87abcbb Polishing 2018-03-28 12:06:38 +02:00
Juergen Hoeller
c60cefa331 SimpleEvaluationContext.Builder withRootObject/withTypedRootObject
Issue: SPR-16588
2018-03-27 00:22:54 +02:00
Juergen Hoeller
9128226da4 SimpleEvaluationContext.Builder withMethodResolvers/withInstanceMethods
Includes DataBindingMethodResolver as ReflectiveMethodResolver subclass.

Issue: SPR-16588
2018-03-24 16:30:37 +01:00
Juergen Hoeller
51c57d77d9 SimpleEvaluationContext with dedicated factory methods for common cases
Aligned with DataBindingPropertyAccessor and shown in ref doc examples.

Issue: SPR-16588
2018-03-22 18:09:27 +01:00
Juergen Hoeller
b5511645b8 DataBindingPropertyAccessor with factory methods (forReadOnlyAccess etc)
Includes configurable write support at ReflectivePropertyAccessor level.

Issue: SPR-16588
2018-03-22 00:03:06 +01:00
Juergen Hoeller
c1405ef140 Polishing 2018-03-21 16:12:42 +01:00
Juergen Hoeller
639d2c6fe7 Polishing 2018-03-21 12:39:15 +01:00
Juergen Hoeller
1fd5935afa SimplePropertyAccessor with configurable write support
Issue: SPR-16588
2018-03-21 12:06:40 +01:00
Andy Clement
1db7e02de3 Modify SpEL code gen to take account of null safe refs
With this change the code generation for method and property
references is modified to include branching logic in the
case of null safe dereferencing (?.). This is complicated
by the possible usage of primitives on the left hand side
of the dereference. To cope with this case primitives are
promoted to boxed types when this situation occurs enabling
null to be passed as a possible result.

Issue: SPR-16489
2018-03-12 15:58:59 -07:00
Juergen Hoeller
c543368aad Polishing 2018-03-03 17:33:48 +01:00
igor-suhorukov
06fef1e5a4 Polish: assertion arguments should be passed in the correct order 2018-03-03 16:14:45 +01:00
Juergen Hoeller
fa670dd07d Indexer enforces target descriptor only after non-null target check
Issue: SPR-16544
2018-03-01 13:31:56 +01:00
Juergen Hoeller
3b810f3544 Consistent Class array vs vararg declarations (and related polishing) 2018-02-14 14:44:00 +01:00
Juergen Hoeller
d5cabca2f7 Internal adaptation to Deque semantics 2018-02-12 15:55:09 +01:00
Juergen Hoeller
b5bd977d9a Revised assertion refactoring in AbstractExpressionTests 2018-02-10 18:17:40 +01:00
igor-suhorukov
0ee505b73e Polish: assertion arguments should be passed in the correct order,
use assertNull instead of assertEquals(null, value),
declare delta as double value in assertEquals
2018-02-10 17:17:28 +01:00
Juergen Hoeller
4a57e26d76 Polishing 2018-01-07 23:33:35 +01:00
Juergen Hoeller
c30145d6f9 MethodReference treats proxy-targeting expressions as non-compilable
Issue: SPR-16191
2017-11-13 23:00:53 +01:00
Juergen Hoeller
78284a62e2 Polishing 2017-10-27 15:28:51 +02:00
Juergen Hoeller
419b4440a7 Introspect interface-declared methods in case of proxy (for varargs)
Issue: SPR-16122
2017-10-27 10:52:44 +02:00
Juergen Hoeller
fd6f2bd6a4 Test for null value against boolean property
Issue: SPR-16123
2017-10-26 22:49:34 +02:00
Juergen Hoeller
03b68286a2 Tokenizer uses single process step and length-based exhaustion check
Issue: SPR-16032
2017-10-04 12:23:16 +02:00
Juergen Hoeller
7ae59d0c2a Nullability refinements on private and static methods
Based on IntelliJ IDEA 2017.3 introspection results.

Issue: SPR-15756
2017-09-22 18:22:14 +02:00
Juergen Hoeller
efc5b47b9a Polishing 2017-07-14 17:37:06 +02:00
Juergen Hoeller
1ad6180019 Expression javadoc alignment 2017-07-14 16:46:22 +02:00
Juergen Hoeller
bcf9f21ecc PropertyOrFieldReference checks cached PropertyAccessor against current EvaluationContext
Issue: SPR-15769
2017-07-14 15:18:05 +02:00
Juergen Hoeller
cc74a2891a @Nullable all the way: null-safety at field level
This commits extends nullability declarations to the field level, formalizing the interaction between methods and their underlying fields and therefore avoiding any nullability mismatch.

Issue: SPR-15720
2017-06-30 01:54:16 +02:00
Juergen Hoeller
f813712f5b Consistent use of @Nullable across the codebase (even for internals)
Beyond just formally declaring the current behavior, this revision actually enforces non-null behavior in selected signatures now, not tolerating null values anymore when not explicitly documented. It also changes some utility methods with historic null-in/null-out tolerance towards enforced non-null return values, making them a proper citizen in non-null assignments.

Some issues are left as to-do: in particular a thorough revision of spring-test, and a few tests with unclear failures (ignored as "TODO: NULLABLE") to be sorted out in a follow-up commit.

Issue: SPR-15540
2017-06-07 14:19:15 +02:00
Andy Clement
c1edb3b5bd Enforce limit on classes loaded by Spel compiled expression loader
Until this change a single classloader was used to load
all compiled SpEL expressions. This meant in a context where an
expression was repeatedly flipping between compiled and interpreted
mode (which can happen if in MIXED mode compilation and changing
the context around the evaluation) the classloader would continually
load a new compiled version but not orphan the old compiled version.
This eventually uses up all the memory as the number of classes
is ever increasing.

With this change classloaders are used to load 100 compiled
expressions. The 101st will be loaded by a new one. Orphaning the
old classloader means if an expression is ever recompiled there
is more likely to be no anchored references left to the older
compiled form and it can be GC'd. In the MIXED situation above it
should help alleviate the problem of older classes never being
candidates for GC.

Issue: SPR-15460
2017-04-27 11:31:56 -07:00
Juergen Hoeller
214d0d76a5 Polishing 2017-02-18 01:01:35 +01:00
Christoph Dreis
5cfa7e71bb Use Class.getTypeName() where appropriate
Issue: SPR-15237
2017-02-08 20:36:41 +01:00
Andy Clement
d41d28f8ce Fix compilation of SpEL elvis/ternary expressions
Without this fix the compiled version of elvis
actual behaved differently to the interpreted version
if the value being queried was an empty string. This
is now fixed. It also now correctly handles the
query value being a primitive and addresses the
findings of SPR-15192 where some type inferencing
logic was trying to be too clever, that code has
been deleted.

Issue: SPR-15192
2017-02-06 09:43:10 -08:00
Juergen Hoeller
14eba5034d Consistent ExpressionException-style quoting of expression string and position
Issue: SPR-14942
2016-11-24 11:08:55 +01:00
Juergen Hoeller
3e419cde7d Polishing
Issue: SPR-14863
2016-11-02 12:44:12 +01:00
Juergen Hoeller
82fa4ef274 Polishing
Issue: SPR-14863
2016-11-02 11:45:59 +01:00
Andy Clement
9000acd39d Rework compilation of OpNE/OpEQ SpEL operators
For SPR-14863 we need to adjust the code generation for OpNE
to use !x.equals(y) rather than x!=y. There are also further
cases in the equalityCheck() code in Operator that were not
being handled in the compilation case (when comparators are
used for example). This latter issue also affects OpEQ.

Rather than add yet more bytecode generation, both OpNE and
OpEQ generateCode() methods have been simplified. The
generated code now delegates to equalityCheck() in Operator
which is exactly what the interpreted case does.

This ensures that the compiled code continues to behave just
like the interpreted case. It ensures changes to the interpreted
case are automatically picked up for the compiled case. It
makes the bytecode generation simpler.

The benefit of compilation of SpEL expressions is to avoid
slow reflective calls - that doesn't apply for a basic
(in)equality test so there is no need to go crazy in bytecode
gen.

Issue: SPR-14863
2016-11-01 13:42:23 -07:00
Sam Brannen
d6d05e8ca0 Remove trailing whitespace in Java source code 2016-08-29 15:25:10 +02:00
Juergen Hoeller
99be15f58b Revise encoding steps towards use of JDK Charset and StandardCharsets
Issue: SPR-14492
2016-07-19 23:43:06 +02:00
Stephane Nicoll
2bf9bc312e Remove Guava cache support
This commit removes `GuavaCache` and support classes. Caffeine supersedes
the caching support in the Google Guava library with an actively maintained
Java 8+ version in standalone form.

As it is the only Guava feature Spring framework integrates with, this
commit removes effectively any reference to Guava.

Issue: SPR-13797
2016-07-08 10:57:05 +02:00
Sam Brannen
1391248ea6 Introduce log4j 2 for Spring's test suite
This commit adds a test runtime dependency on log4j 2 for every project
and migrates all log4j.properties files to log4j2-test.xml files.

Issue: SPR-14431
2016-07-05 19:19:09 +02:00
Stephane Nicoll
00d2606b00 Explicit type can be replaced by <>
Issue: SPR-13188
2016-07-05 17:00:34 +02:00
Andy Clement
a31f0bb3c0 Fix compilation of expressions using instanceof and primitives
Prior to this commit the SpEL compiler would generate bad bytecode
if the left hand operand of an instanceof was a primitive or
if the right hand operand was a primitive type reference.
With the fixes primitives on the left hand side are now
correctly boxed and special handling is in place for when the
right hand side is a primitive type reference. Using a primitive
type reference on the right always causes the instanceof
check to return false.

Additionally a guard has been added such that compilation is
not allowed when the right hand side of an expression
is not a type reference. If it is, for example, a variable
reference that evaluates to a type reference then that
cannot be expressed in bytecode so compilation is not performed.

Issue: SPR-14250
2016-05-05 09:57:15 -07:00
Johnny Lim
44e652f99e Remove duplicate words
Closes gh-1039
2016-04-19 08:24:21 +02:00
Juergen Hoeller
4ae065996b Polishing
(cherry picked from commit aa5c12c)
2016-04-08 23:06:25 +02:00
Juergen Hoeller
517ebd1d3e Consistent formatting 2016-03-24 19:22:50 +01:00
Sam Brannen
61824b1ade Remove trailing whitespace from source code 2016-02-29 18:52:57 +01:00
Juergen Hoeller
43bcab9c1a ReflectiveMethodResolver lets local static methods override java.lang.Class methods
Issue: SPR-13918
2016-02-08 13:23:02 +01:00
Andy Clement
a12f23936c Allow use of '&' prefix to access factory bean in SpEL
Prior to this change SpEL did not have an syntactic
construct enabling easy access to a FactoryBean. With this
change it is now possible to use &foo in an expression when
the factory bean should be returned.

Issue: SPR-9511
2016-01-21 16:14:16 -08:00
Andy Clement
a28fc760ba Fix SpEL compilation of static method/property/field operations
Before this change the compilation of a method reference or property/field
access was not properly cleaning up the stack if compilation meant
calling a static method or accessing a static field. In these cases there
is no need for a target object on the stack and it should be removed if
present. For a simple expression it is harmless since the end result of
the expression is the thing on the top of the stack, but for nested
expressions if the inner expression suffered this issue, the outer
expression can find itself operating on the wrong element.

The particular issue covered the case of a static field access but this
fix (and associated tests) cover static method, property and field access.

Issue: SPR-13781
2015-12-11 15:59:40 -08:00
Juergen Hoeller
8c4436926f Polishing 2015-11-26 02:09:37 +01:00