Repository navigation
Conversation
…tures - JexlFeatures.antishTest(Predicate): the parser rewrites references rooted on a global so that the longest declared dotted prefix is a single variable; a script parsed with declared names does not solve antish variables at runtime - with sideEffectGlobal(false) and declared names, assigning a property of a global value is not a global side effect - JexlFeatures.namePatterns(Collection), pragmaPatterns delegates to it - Interpreter: pushBlock/popBlock helpers, AntishName helper for runtime antish resolution - fix: a null local variable root is never solved as an antish variable (read was, assign was not) - fix: for-loop lexical frame leaked when an initializer throws - tests: AntishFeaturesTest, InterpreterCharacterizationTest; JMH InterpreterBenchmark (pom: jmh test deps) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Null-root safe navigation regresses, and declared dotted names fail to resolve in direct calls and interpolated expressions.
3 open issues
What changed in this PR
Adds parse-time declarations for dotted global variables in JEXL, replacing runtime name resolution for scripts using the new feature.
Changes:
- Adds
antishTestand reusable name-pattern predicates, with parser rewriting and updated global-assignment checks. - Refactors interpreter name resolution and lexical-frame handling, including local-shadowing and loop-initializer fixes.
- Adds regression tests, characterization coverage, and JMH benchmarks.
| File | Description |
|---|---|
src/test/java/org/apache/commons/jexl3/InterpreterCharacterizationTest.java |
Captures loop, scope, and antish behavior. |
src/test/java/org/apache/commons/jexl3/benchmark/InterpreterBenchmark.java |
Benchmarks interpreter operations and antish resolution. |
src/test/java/org/apache/commons/jexl3/AntishFeaturesTest.java |
Tests declared names and feature interactions. |
src/test/java/org/apache/commons/jexl3/AntishCallTest.java |
Tests null-local shadowing of dotted globals. |
src/main/java/org/apache/commons/jexl3/parser/SimpleNode.java |
Clarifies child-replacement usage in a comment. |
src/main/java/org/apache/commons/jexl3/parser/Parser.jjt |
Adds parser-stack node replacement support. |
src/main/java/org/apache/commons/jexl3/parser/JexlParser.java |
Rewrites declared dotted prefixes as identifiers. |
src/main/java/org/apache/commons/jexl3/parser/FeatureController.java |
Distinguishes global assignments from property writes. |
src/main/java/org/apache/commons/jexl3/JexlFeatures.java |
Exposes declarations and reusable name predicates. |
src/main/java/org/apache/commons/jexl3/internal/Interpreter.java |
Refactors antish resolution and lexical-frame cleanup. |
src/main/java/org/apache/commons/jexl3/internal/Engine.java |
Disables runtime antish resolution for declared names. |
src/changes/changes.xml |
Records the JEXL-474 addition. |
pom.xml |
Adds JMH test dependencies. |
Review effort: Balanced
… Debugger fixes - a method name may complete a declared antish variable, which is then called as a functor, as in f.g(42); - safe navigation: only the access applied to null decides; a.b?.c fails when a is null, x?.y().z fails when x.y() is null; - the safe option also covers array accesses; - a null local variable is reported as null, not undefined; - for loops with an empty body or multiple declarations; - Debugger: expression-bodied loops, lambda expressions and curried calls. Co-Authored-By: Claude <noreply@anthropic.com>
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

JEXL-474, stacked on #423 (JEXL-475).
Antish variables (dotted global names like
x.y.z) can now be declared at parse time:variable (
x.y.z→ variablex.y, property.z); local roots,?.and back-quoted segments stop the rewriteJexlOptions.setAntish)sideEffectGlobal(false)and declared names, only assigning a global (x = 1, declaredx.y = 1) isrejected; assigning a property of a global value (
x.y.z = 1) is allowedJexlFeatures.namePatterns(Collection);pragmaPatternsdelegates to itInterpreter:pushBlock/popBlockandAntishNamehelpers; fixes a null local root being solved as anantish variable on read (not on assign) and a lexical frame leak when a for-loop initializer throws
Declared antish variables: ~10 µs/op vs ~41 µs/op with runtime resolution (JMH
InterpreterBenchmark,mvn clean test -Pbenchmark -Dbenchmark=InterpreterBenchmark). Without a declared predicate, behavior is unchanged.Tests:
AntishFeaturesTest,InterpreterCharacterizationTest, additions toAntishCallTest.mvndefault goal passes🤖 Generated with Claude Code