File: StartsEndsWith.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,104 kB
  • sloc: java: 145,916; xml: 839; sh: 518; makefile: 404; perl: 26
file content (19 lines) | stat: -rw-r--r-- 642 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Tests string length refinement after startsWith or endsWith return true
// https://github.com/kelloggm/checker-framework/issues/56

import org.checkerframework.common.value.qual.MinLen;

class StartsEndsWith {

    // This particular test is here rather than in the framework tests because it depends on purity
    // annotations for these particular JDK methods.
    void refineStartsConditional(String str, String prefix) {
        if (prefix.length() > 10 && str.startsWith(prefix)) {
            @MinLen(11) String s11 = str;
        }
    }
}

class StartsEndsWithExternal {
    public static final String staticFinalField = "str";
}