File: LessThanLenBug.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 (21 lines) | stat: -rw-r--r-- 651 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
20
21
import org.checkerframework.checker.index.qual.LTLengthOf;
import org.checkerframework.common.value.qual.MinLen;

public class LessThanLenBug {
    public static void m1(int[] shorter) {
        int[] longer = new int[4 * shorter.length];
        // :: error: (assignment.type.incompatible)
        @LTLengthOf("longer") int x = shorter.length;
        int i = longer[x];
    }

    public static void m2(int @MinLen(1) [] shorter) {
        int[] longer = new int[4 * shorter.length];
        @LTLengthOf("longer") int x = shorter.length;
        int i = longer[x];
    }

    public static void main(String[] args) {
        m1(new int[0]);
    }
}