fix: allow reserved keywords in package names for class references (#103)#486
Merged
lukaszlenart merged 1 commit intomainfrom Nov 29, 2025
Merged
Conversation
440beab to
fbebd26
Compare
) This commit resolves Issue #103 where the OGNL parser would fail to parse class references containing reserved keywords (like "or", "and", "not", etc.) in package names. Problem: -------- Expressions like `@jp.or.example.IdUtils@generateId()` would fail at parse time with ExpressionSyntaxException because "or" was tokenized as a keyword rather than as part of the package name. Root Cause: ----------- In JavaCC, string literals used as operators in grammar productions (e.g., "or" for logical OR) become implicit keyword tokens that take precedence over generic IDENT tokens during lexical analysis. Solution: --------- - Added new `classNamePart()` production that accepts either IDENT tokens or any reserved keywords, treating them as identifiers in the context of class/package names - Updated `className()` production to use `classNamePart()` instead of direct IDENT references - Updated `instanceof` production similarly to handle keywords in type names Changes: -------- - Modified: ognl/src/main/javacc/ognl.jj - Added classNamePart() helper production (lines 1389-1418) - Updated className() to use classNamePart() (lines 1374-1382) - Updated instanceof production to use classNamePart() (lines 948-969) - Added: ognl/src/test/java/ognl/test/PackageKeywordTest.java - Comprehensive test coverage for keywords in package names - Tests for: or, and, not, in, and multiple keywords - Validates that parsing succeeds (no ExpressionSyntaxException) - Added: ISSUE_103_ANALYSIS.md - Detailed analysis of the problem and solution - Impact analysis and backward compatibility notes - Build and verification instructions Impact: ------- - Fully backward compatible (only expands valid expressions) - No ambiguity introduced (context is unambiguous) - Keywords remain functional as operators in expression contexts - Aligns with real-world Java package naming (e.g., jp.or.* domains) Testing: -------- The fix requires regenerating the parser via `mvn compile` which runs the javacc-maven-plugin. All existing tests should continue to pass. Fixes #103
fbebd26 to
08748f0
Compare
|
lukaszlenart
pushed a commit
that referenced
this pull request
Nov 11, 2025
…3-4-x) Port the fix from PR #486 to resolve issue #103 where OGNL parser fails to parse class references containing reserved keywords in package names (e.g., @jp.or.example.Utils@method()). Changes: - Modified ognl.jj grammar to add classNamePart() production that accepts both identifiers and reserved keywords (or, and, not, in, etc.) - Updated instanceof and className() productions to use classNamePart() - Added PackageKeywordTest.java with comprehensive test coverage This allows package names commonly used in Japanese domains (.jp.or.) and other scenarios where reserved keywords appear in package names. Fixes #103
lukaszlenart
pushed a commit
that referenced
this pull request
Nov 11, 2025
…3-4-x) Port the fix from PR #486 to resolve issue #103 where OGNL parser fails to parse class references containing reserved keywords in package names (e.g., @jp.or.example.Utils@method()). Changes: - Modified ognl.jj grammar to add classNamePart() production that accepts both identifiers and reserved keywords (or, and, not, in, etc.) - Updated instanceof and className() productions to use classNamePart() - Added PackageKeywordTest.java with comprehensive test coverage This allows package names commonly used in Japanese domains (.jp.or.) and other scenarios where reserved keywords appear in package names. Fixes #103
lukaszlenart
added a commit
that referenced
this pull request
Nov 29, 2025
…3-4-x) (#491) Port the fix from PR #486 to resolve issue #103 where OGNL parser fails to parse class references containing reserved keywords in package names (e.g., @jp.or.example.Utils@method()). Changes: - Modified ognl.jj grammar to add classNamePart() production that accepts both identifiers and reserved keywords (or, and, not, in, etc.) - Updated instanceof and className() productions to use classNamePart() - Added PackageKeywordTest.java with comprehensive test coverage This allows package names commonly used in Japanese domains (.jp.or.) and other scenarios where reserved keywords appear in package names. Fixes #103 Co-authored-by: Claude <[email protected]>
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.



Summary
Fixes parsing error when OGNL class references contain reserved keywords like or, and, not in package names.
Before:
@jp.or.example.Utils@method()→ ExpressionSyntaxExceptionAfter:
@jp.or.example.Utils@method()→ ✅ Parses successfullyProblem
The parser treated or, and, not, etc. as operator keywords everywhere, preventing their use in package names. This broke support for Japanese domain packages like jp.or.*.
Solution
Added classNamePart() helper that accepts both identifiers and reserved keywords when parsing class names. Updated className() and instanceof productions to use it.
Fixes #103