Skip to content

Commit

Permalink
Merge branch '5.1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed May 13, 2019
2 parents 9755b59 + d3110c4 commit e0654a5
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions src/docs/asciidoc/core/core-expressions.adoc
Expand Up @@ -114,8 +114,10 @@ The following example of calling a JavaBean property calls the `String` property
<1> This line converts the literal to a byte array.


SpEL also supports nested properties by using standard dot notation (such as
`prop1.prop2.prop3`) and the setting of property values. Public fields may also be accessed.
SpEL also supports nested properties by using the standard dot notation (such as
`prop1.prop2.prop3`) and also the corresponding setting of property values.
Public fields may also be accessed.

The following example shows how to use dot notation to get the length of a literal:

[source,java,indent=0]
Expand Down Expand Up @@ -291,18 +293,16 @@ does not provide optimum performance. For occasional expression usage,
this is fine, but, when used by other components such as Spring Integration,
performance can be very important, and there is no real need for the dynamism.

The SpEL compiler is intended to address this need. During evaluation, the
compiler generates a real Java class that embodies the
expression behavior and uses that to achieve much faster expression
evaluation. Due to the lack of typing around expressions, the compiler
uses information gathered during the interpreted evaluations of an
expression when performing compilation. For example, it does not know the type
of a property reference purely from the expression, but, during the first
interpreted evaluation, it finds out what it is. Of course, basing the
compilation on this information can cause trouble later if the types of
the various expression elements change over time. For this reason, compilation
is best suited to expressions whose type information is not going to change
on repeated evaluations.
The SpEL compiler is intended to address this need. During evaluation, the compiler
generates a Java class that embodies the expression behavior at runtime and uses that
class to achieve much faster expression evaluation. Due to the lack of typing around
expressions, the compiler uses information gathered during the interpreted evaluations
of an expression when performing compilation. For example, it does not know the type
of a property reference purely from the expression, but during the first interpreted
evaluation, it finds out what it is. Of course, basing compilation on such derived
information can cause trouble later if the types of the various expression elements
change over time. For this reason, compilation is best suited to expressions whose
type information is not going to change on repeated evaluations.

Consider the following basic expression:

Expand Down Expand Up @@ -367,24 +367,22 @@ following example shows how to do so:
When you specify the compiler mode, you can also specify a classloader (passing null is allowed).
Compiled expressions are defined in a child classloader created under any that is supplied.
It is important to ensure that, if a classloader is specified, it can see all the types involved in
the expression evaluation process.
If you do not specify a classloader, a default classloader is used (typically the context classloader for
the thread that is running during expression evaluation).
the expression evaluation process. If you do not specify a classloader, a default classloader is used
(typically the context classloader for the thread that is running during expression evaluation).

The second way to configure the compiler is for use when SpEL is embedded inside some other
component and it may not be possible to configure it through a configuration object.
In these cases, it is possible to use a system property. You can set the
`spring.expression.compiler.mode` property to one of the `SpelCompilerMode`
enum values (`off`, `immediate`, or `mixed`).
component and it may not be possible to configure it through a configuration object. In these
cases, it is possible to use a system property. You can set the `spring.expression.compiler.mode`
property to one of the `SpelCompilerMode` enum values (`off`, `immediate`, or `mixed`).


[[expressions-compiler-limitations]]
==== Compiler Limitations

Since Spring Framework 4.1, the basic compilation framework is in place. However, the framework does not
yet support compiling every kind of expression. The initial focus has been on the common expressions that are
likely to be used in performance-critical contexts. The following kinds of expression cannot be compiled
at the moment:
Since Spring Framework 4.1, the basic compilation framework is in place. However, the framework
does not yet support compiling every kind of expression. The initial focus has been on the
common expressions that are likely to be used in performance-critical contexts. The following
kinds of expression cannot be compiled at the moment:

* Expressions involving assignment
* Expressions relying on the conversion service
Expand Down Expand Up @@ -1193,7 +1191,7 @@ The following example shows how to use the Elvis operator:
System.out.println(name); // 'Unknown'
----

The following listing shows A more complex example:
The following listing shows a more complex example:

[source,java,indent=0]
[subs="verbatim,quotes"]
Expand Down

0 comments on commit e0654a5

Please sign in to comment.