typetools / typetools/checker-framework
Index Checker `startsWith` refinement
Open
Nobody has claimed this yet.
False Positive (false warning or imprecision)
good first issue
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Consider this code (which is in checker/tests/index/StartsEndsWith.java):
final String prefix;
String propertyName(String methodName) {
if (methodName.startsWith(prefix)) {
String result = methodName.substring(prefix.length());
return result;
} else {
return null;
}
}
The Index Checker issues the following warning:
StartsEndsWith.java:17: error: [argument] incompatible argument for parameter beginIndex of substring.
String result = methodName.substring(prefix.length());
^
found : @LTEqLengthOf("this.prefix") int
required: @LTEqLengthOf("methodName") int
but the code is correct because methodName is at least as long as this.prefix.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the warning using checker/tests/index/StartsEndsWith.java and read the Index Checker handling involved in startsWith refinement. Determine how the length relationship between methodName and prefix should be represented, then verify that the shown substring call is accepted without weakening valid index checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100