Fix: issue #4974 How to detect array.length ValueDeclaration#5000
Merged
Conversation
…ess of the Java version, but works on Windows and macOS systems
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5000 +/- ##
===============================================
+ Coverage 58.657% 58.694% +0.036%
- Complexity 2564 2592 +28
===============================================
Files 699 700 +1
Lines 40121 40188 +67
Branches 7314 7323 +9
===============================================
+ Hits 23534 23588 +54
- Misses 13620 13630 +10
- Partials 2967 2970 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 3 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
wadoon
added a commit
to jmltoolkit/jmlparser
that referenced
this pull request
May 10, 2026
* tag 'javaparser-parent-3.28.1': (45 commits) [maven-release-plugin] prepare release javaparser-parent-3.28.1 update readme Update changelog chore(deps): update codecov/codecov-action action to v6 fix(grammar): allow empty component list in RecordPattern fix(deps): update dependency org.javassist:javassist to v3.31.0-ga (javaparser#5006) fix(deps): update dependency org.checkerframework:checker-qual to v3.55.1 (javaparser#5004) fix(deps): update dependency com.google.guava:guava to v33.6.0-jre (javaparser#5003) fix(deps): update dependency org.junit:junit-bom to v5.14.4 (javaparser#5002) chore(deps): update dependency maven to v3.9.15 (javaparser#5001) fix(deps): update byte-buddy.version to v1.18.8-jdk5 (javaparser#4995) chore(deps): update codecov/codecov-action action to v5.5.4 (javaparser#4993) Fix: issue javaparser#4974 How to detect array.length ValueDeclaration (javaparser#5000) chore(deps): update codecov/codecov-action action to v5.5.3 (javaparser#4990) chore(deps): update dependency maven to v3.9.14 (javaparser#4988) chore(deps): update dependency maven to v3.9.13 (javaparser#4983) chore(deps): update dependency org.apache.maven.plugins:maven-resources-plugin to v3.5.0 (javaparser#4981) fix(deps): update dependency org.checkerframework:checker-qual to v3.54.0 (javaparser#4980) fix(deps): update byte-buddy.version to v1.18.7-jdk5 (javaparser#4979) fix(deps): update byte-buddy.version to v1.18.6-jdk6-jdk5 (javaparser#4978) ...
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.
Fixes #4974 .
array.length is the only synthetic pseudo-field defined by the JLS (§10.7). It is a singleton with a fixed name and a fixed type (int), so a dedicated interface would carry no meaningful contract beyond the flag itself. The existing codebase already follows this lighter approach: isVariable() in ResolvedDeclaration has no companion ResolvedVariableDeclaration interface. Introducing an empty marker interface just to be symmetric with isField() / isEnumConstant() would be over-engineering for a one-off case.
The fix is therefore:
Add default boolean isArrayLength() { return false; } to ResolvedDeclaration
Override it to return true inside ArrayLengthValueDeclaration
If more extensibility were needed in the future — for instance, to expose getArrayType() to retrieve the component type of the backing array — the right move would be to introduce a ResolvedArrayLengthDeclaration interface at that point. Because all new methods on ResolvedDeclaration are default, and because ArrayLengthValueDeclaration already implements ResolvedValueDeclaration, that refactor could be done without any breaking change.