Repository navigation
Conversation
The expressions embedded in an interpolation string or an interpolated property name were parsed with the features of the engine. The parser now hands its current features to the interpolation it creates, so that a script created with its own features has them enforced, and its declared antish names solved, inside interpolations; cached interpolation expressions are keyed by those features. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open issues
The changelog entry describes the buggy behavior as if it were the current behavior. Since this… · New The comment says interpolations are not cached, but the code clearly enables caching whencached… · New The helper method namefeatures(...)is ambiguous and easy to confuse with local variables named… · New The exception message has a grammatical error (\"a accessible\"). Consider changing it to a clearer… · New
What changed in this PR
This PR fixes JEXL-477 by ensuring expressions embedded in interpolations (template literals and interpolated property names) are parsed using the containing script’s JexlFeatures, not the engine’s.
Changes:
- Pass the current parser/script features through AST nodes and into interpolation parsing.
- Update
TemplateEngineexpression creation/caching to derive features from the embedded script and include them in cache keys and deferred parses. - Add regression tests validating feature enforcement (method calls + declared antish names) in interpolations.
| File | Description |
|---|---|
| src/test/java/org/apache/commons/jexl3/JxltFeatureEnforcementTest.java | Adds regression tests ensuring interpolations honor script-level features (including caching and antish names). |
| src/main/java/org/apache/commons/jexl3/parser/Parser.jjt | Propagates current parsing features into Jxlt literal and identifier-access interpolation nodes. |
| src/main/java/org/apache/commons/jexl3/parser/JexlParser.java | Extends interpolation parsing API to accept script features and forwards them into TemplateEngine. |
| src/main/java/org/apache/commons/jexl3/parser/ASTJxltLiteral.java | Stores interpolation expressions created with the script’s features. |
| src/main/java/org/apache/commons/jexl3/parser/ASTIdentifierAccessJxlt.java | Ensures interpolated identifier access is parsed with the script’s features. |
| src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java | Derives/normalizes expression features from embedded script features and includes them in caching + nested parsing. |
| src/main/java/org/apache/commons/jexl3/internal/Engine.java | Adds an overload to parse with explicit JexlFeatures and routes existing calls through it. |
| src/changes/changes.xml | Adds a changelog entry for JEXL-477. |
Review effort: Lite
…error message Address review comments. Co-Authored-By: Claude <noreply@anthropic.com>
…rcing GC The loop that fills the heap to force a GC relies on the JVM clearing soft references rather than failing an allocation; on Java 27 (Windows), the allocation failed. Catch the error, release the big objects and carry on. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
This release note reads like the current behavior is still incorrect (“are parsed with… instead… · New CatchingOutOfMemoryErrorand then continuing can make this test pass even when the expected… · New Whennoscript && ftrs.supportsScript()is true, this allocates a newJexlFeaturesinstance for… · New
4 resolved since last review
The comment says interpolations are not cached, but the code clearly enables caching whencached… The changelog entry describes the buggy behavior as if it were the current behavior. Since this… The exception message has a grammatical error (\"a accessible\"). Consider changing it to a clearer… The helper method namefeatures(...)is ambiguous and easy to confuse with local variables named…
Review effort: Lite
| <body> | ||
| <release version="3.7.2" date="YYYY-MM-DD" description="This is a feature and maintenance release. Java 8 or later is required."> | ||
| <!-- FIX --> | ||
| <action dev="henrib" due-to="Claude" type="fix" issue="JEXL-477">Interpolation strings are parsed with the engine features instead of those of their script.</action> |
There was a problem hiding this comment.
Kept as is, same as the earlier thread: in this file, fix entries state the problem as the JIRA title does.
| try { | ||
| for (int b = 0; b < 1024 && Runtime.getRuntime().freeMemory() > MEGA; ++b) { | ||
| final BigObject big = new BigObject(b); | ||
| stuff.add(new InstanceReference(big, queue)); | ||
| } | ||
| } catch (final OutOfMemoryError oom) { | ||
| // exhausting the heap is the intent; if the JVM fails an allocation instead of | ||
| // clearing the soft references, release the big objects and carry on | ||
| for (final Reference<?> soft : stuff) { | ||
| if (soft instanceof InstanceReference) { | ||
| soft.clear(); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Kept as is: what the test asserts is unchanged, a generated class must be collected and reloaded (gced >= 0, second pass). Filling the heap is only a means to provoke a GC, and the clearing of soft references is the JVM's business, not what is under test.
| private JexlFeatures features(final JexlFeatures ftrs) { | ||
| if (ftrs == null) { | ||
| return noscript ? jexl.expressionFeatures : jexl.scriptFeatures; | ||
| } | ||
| return noscript && ftrs.supportsScript() ? new JexlFeatures(ftrs).script(false) : ftrs; | ||
| } |
There was a problem hiding this comment.
This is not a hot path: the features are derived when the parser builds an interpolation node, once per node, and evaluation uses the expression stored in the node. Still, scripts created with the features of the engine did not need a copy before this change; e0f00f2 reuses the engine expression features for them, so only scripts created with their own features derive one.
…engine scripts Only derive expression features when a script was created with its own features; a script created with the features of the engine parses its interpolations with the engine expression features, as before. Co-Authored-By: Claude <noreply@anthropic.com>


JEXL-477. Stacked on #425 (JEXL-476); the base branch is
JEXL-476so that only this change shows.Problem
The expressions embedded in an interpolation string (
`${...}`,`#{...}`) or in an interpolated property name (x.`${...}`) were parsed with the features of the engine, not with those of the script that contains them. This only shows when a script is created with its own features throughJexlEngine.createScript(JexlFeatures, JexlInfo, String, String...):methodCall(false):s.length()is rejected but`${s.length()}`evaluated as 3;x.yevaluated but`${x.y}`failed.Fix
The parser hands its current features to the interpolation it creates (
Parser.jjt,ASTJxltLiteral,ASTIdentifierAccessJxlt,JexlParser.parseInterpolation).TemplateEngine.createExpressionderives the expression features from them, uses them to parse and as part of the cache key, and nested expressions keep them for their deferred parse. Scripts created with the features of the engine are not affected. All signature changes are in theparserandinternalpackages.Tests
JxltFeatureEnforcementTest.testInterpolationHonorsScriptFeatures(both directions, including the cached expression) andtestInterpolationHonorsDeclaredAntish.🤖 Generated with Claude Code