Commit Graph

172 Commits

Author SHA1 Message Date
Sam Brannen 3f0a6e814c Suppress warnings in spring-expression tests 2015-07-04 15:46:36 +02:00
Sam Brannen 078d252d1e Delete trailing whitespace in Java source code 2015-06-19 17:09:52 +02:00
Sam Brannen 7018747cec Remove trailing whitespace in Java source code 2015-05-29 02:03:44 +02:00
Andy Clement 91ed5b6b8c SpEL: ensure correct object used for nested #this references
Before this commit the object that #this would refer to in
nested expressions within projection/selection clauses was always
the root context object. This was incorrect as it should be the
element being projected/selected over. This commit introduces
a scope root context object which is set upon entering a new
scope (like when entering a projection or selection). Any
object. With this change this kind of expression now behaves:

where #this is the element of list1. Unqualified references
are also resolved against this scope root context object.

Issues: SPR-10417, SPR-12035, SPR-13055
2015-05-22 08:07:09 -07:00
Juergen Hoeller b4095c3e1d Class identity comparisons wherever possible
Issue: SPR-12926
2015-05-20 14:34:16 +02:00
Juergen Hoeller 9799df397a PropertyOrFieldReference avoids NPE through defensive copy of volatile accessor reference
Issue: SPR-13023
2015-05-13 15:45:48 +02:00
Sam Brannen 7a690df925 Remove trailing whitespace from Java source code 2015-05-06 20:08:42 +02:00
Andy Clement c382b6f059 Allow NEW and T to be used as unquoted map keys in SpEL
This change provides support for map[NEW], map[new], map[T]
and map[t]. Prior to this change the 'new' and 't' had to
be quoted because they were keywords in SpEL for a constructor
reference and type reference respectively.

Issue: SPR-11783
2015-03-30 16:20:04 -07:00
Juergen Hoeller 9d47a2b87e Explicit test for default useDistance mode
Issue: SPR-12808
2015-03-13 18:16:58 +01:00
Juergen Hoeller 348eb91891 ReflectiveMethodResolver applies useDistance mode by default (with fine-tuned varargs handling)
Issue: SPR-12803
Issue: SPR-12808
2015-03-11 22:09:03 +01:00
Sam Brannen d90cee78ef Remove trailing whitespace in source code 2015-03-07 21:16:18 +01:00
Andy Clement b7ef04767a Reduce SpEL compilation restrictions on mathematical expressions
Prior to this change the SpEL compiler would not compile mathematical
expressions where the operands were of differing types (e.g. int
and double). This required the expression writer to do the conversion
in the expression text. For example:

T(Integer).valueOf(someInt).doubleValue()/35d

With this commit the restriction is lifted and it is more like Java
so that you can simply do someInt/35d. The mathematical operators
affected are divide/plus/minus/multiply and modulus. This change
involved removing some guards so that the exitTypeDescriptor (the
trigger for whether compilation is allowed) is set more frequently
and enhancing bytecode generation to perform more sophisticated
conversion/coercion automatically.

Issue: SPR-12789
2015-03-06 10:32:42 -08:00
Stephane Nicoll babbf6e871 Harmonize resources location
Issue: SPR-12766
2015-02-28 10:32:40 +01:00
Eric Bottard ece7eb14ff Fix copy/paste error in Javadoc 2015-02-19 15:25:26 +01:00
Juergen Hoeller d34402d3ba OperatorMatches caches compiled patterns
Issue: SPR-12610
2015-01-20 16:02:11 +01:00
Juergen Hoeller 9ac02b319d Remove pre-3.2 deprecated classes and methods
Issue: SPR-12578
2014-12-30 20:05:15 +01:00
Juergen Hoeller 26845f6f7f Polishing
Issue: SPR-12502
2014-12-30 10:04:16 +01:00
Juergen Hoeller fa138d2c70 ReflectionHelper's isFirstEntryInArray properly handles empty arrays
Issue: SPR-12522
2014-12-22 19:54:16 +01:00
Andy Clement abc3cc4dc4 Ensure correct boxing in compiled code for OpEq with primitives
Without this change when the operands to an == are a mix of a
reference type and a primitive, the failure to box the primitive
would result in a verifyerror when the compiled code is loaded.

Issue: SPR-12557
2014-12-18 13:46:55 -08:00
Juergen Hoeller 9ef0bdcb17 Consistent resolution of Class methods and static methods
Issue: SPR-12502
2014-12-03 23:03:24 +01:00
Andy Clement 94ee763bc8 Fix bytecode generation for SpEL OpPlus
Without this change the plus operator would fail to
include a CHECKCAST in generated bytecode when it
was compiled in cases where one of the operands
has a runtime type of String but a statically
declared type that was not String (i.e. Object).

Issue: SPR-12426
2014-11-13 08:12:43 -08:00
Juergen Hoeller e989b2621f Test for cyclic type declaration handling in TypeDescriptor
Issue: SPR-9735
(cherry picked from commit 7fa3e65)
2014-11-02 11:40:58 +01:00
Juergen Hoeller 1146d5ba1d Polishing 2014-10-29 22:44:59 +01:00
Juergen Hoeller 4945cf1bd1 Optimized parameter length comparisons for constructor/method sorting
Issue: SPR-12385
2014-10-28 13:22:22 +01:00
Andy Clement 03fc9e89a0 Fixed isWritable for badly formed SpEL expressions
Before this change isWritable() could return true
for a badly formed expression. That is because the
decision about whether something is writable was made
based on the node type rather than whether the node
represented something that could actually be resolved
to be a real thing. This change ensures a resolution
check is done and isWritable() should only return
true if a subsequent setValue() will succeed.

Issue: SPR-10610
2014-10-27 11:35:51 -07:00
Andy Clement 28a3cd50aa Resolved package tangle in spring-expression 2014-10-25 11:22:15 -07:00
Andy Clement a40e42479c Fix SpEL handling of function reference
These changes provide more robust handling of function
reference compilation in SpEL expressions. Prior to
this change the isCompilable check was not performing
enough visibility checks on the proposed target
function, causing bytecode to be generated that
would lead to an IllegalAccessError.
The changes also bring the argument handling for
function invocation completely inline with that used
for method invocation allowing some code to be deleted.

Many new tests are also included for function
reference compilation.

Issue: SPR-12359
2014-10-24 11:11:42 -07:00
Sam Brannen 4412bc68aa Polish Javadoc 2014-10-23 01:06:12 +02:00
Andy Clement bc8e4d3680 Fix SpEL varargs handling and usage of other getValue() methods
Building on the initial work for SPR-12326, this commit
addresses three problems:

Firstly the ReflectiveMethodResolver is modified to consider
a direct parameter match more important than a varargs match.
Also in that same type when there are a number of close
matches, the first one is taken rather than the last one.

Secondly more testcases and better support have been added
for the case of passing a single parameter to a varargs
accepting method.

Finally it is possible to set the root context object
indirectly and not pass it on getValue() calls to the
expression objects but not all variants of getValue()
were handling that. This is now fixed.

Issue: SPR-12326
2014-10-21 08:57:22 -07:00
Juergen Hoeller 8325b10080 Consistent formatting of license headers, package javadocs, and import declarations 2014-10-21 01:44:07 +02:00
Juergen Hoeller 92ad02ae8f Consistent number handling in StandardTypeComparator (BigInteger support, doubleValue fallback)
Also includes a fix for the Comparable raw type invocation.

Issue: SPR-9913
Issue: SPR-12353
2014-10-20 17:31:03 +02:00
Andy Clement aae221cb15 Fix SpEL compilation of constructor invocation
The argument processing for compiling constructor references
was very basic and this fix removes that and ensures the
comprehensive logic written for method argument processing
(under SPR-12328) is now used for both method and constructor
argument handling. This fixes the reported issue and ensures
varargs constructor references can be compiled.

This also includes a couple of small fixes for the secondary
testcase reported in SPR-12326. The first is to ensure the
right root context object is used when it is passed
to getValue() indirectly through the evaluation context.
The final fix is to ensure correct boxing of primitives is
done when a method is called upon a primitive.

Issue: SPR-12326
2014-10-17 10:26:54 -07:00
Andy Clement 115f85e44f Enhance SpEL compilation to cover additional expression types
This change introduces support for compilation of expressions
involving inline lists, string concatenation and method
invocations where the method being invoked is declared
with a varargs parameter. It also fixes a problem with
compiling existing method invocations where the target
method is on a non public type.

Issue: SPR-12328
2014-10-16 12:08:49 -07:00
Juergen Hoeller d8160b3c09 Comprehensive revision of SpEL's bytecode generation and number handling (BigInteger support, doubleValue fallback)
Issue: SPR-9913
2014-10-06 23:29:43 +02:00
Andy Clement bd7d56ac54 Fix VerifyError for SpEL ternary compilation
The ternary expression node was failing to generate the
necessary unboxing bytecode when the condition part
of the expression returned a boxed Boolean rather than
a primitive boolean.

Also fixed here is an IllegalAccessError that was
seen in the same expression due to generating a
CHECKCAST bytecode for a private type.

Issue: SPR-12271
2014-10-01 09:26:05 -07:00
Juergen Hoeller 0cc877ad0f MethodReference accesses cached executor in a thread-safe manner
Issue: SPR-12269
2014-09-30 14:06:43 +02:00
Juergen Hoeller cfd9fd6863 Polishing 2014-09-29 17:35:23 +02:00
Juergen Hoeller c508a70c15 MethodReference accesses cached executor in a thread-safe manner
Issue: SPR-12269
2014-09-29 17:31:13 +02:00
Juergen Hoeller cc29db4c50 Polishing 2014-09-18 23:48:58 +02:00
Juergen Hoeller 7387475deb Polishing 2014-09-12 23:49:14 +02:00
Juergen Hoeller 60e58a2012 Polishing 2014-08-21 14:29:14 +02:00
Stephane Nicoll 5b1341f4b5 Fix String equality
Issue: SPR-12105
2014-08-20 17:40:36 +02:00
Stephane Nicoll 0b2c0cfb4f Fix some warning 2014-08-07 15:44:39 +02:00
Andy Clement 095bd99951 Add support for inline maps in SpEL expressions
This commit introduces the ability to specify an inline map in
an expression. The syntax is similar to inline lists and of
the form: "{key:value,key2:value}". The keys can optionally
be quoted. The documentation is also updated with information
on the syntax.

Issue: SPR-9472
2014-08-06 11:15:11 -07:00
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