File: BitwiseAnd.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,840 kB
  • sloc: java: 145,910; xml: 839; sh: 518; makefile: 401; perl: 26
file content (36 lines) | stat: -rw-r--r-- 1,165 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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import org.checkerframework.common.value.qual.IntRange;

public class BitwiseAnd {

    public static void Case11(@IntRange(from = 0) byte b) {
        @IntRange(from = 0, to = 0xf0) int i1 = b & 0xf0;
    }

    public static void Case12(@IntRange(to = -1) byte b) {
        @IntRange(from = 0, to = 0xf0) int i1 = b & 0xf0;
    }

    public static void Case13(byte b) {
        @IntRange(from = 0, to = 0xf0) int i1 = b & 0xf0;
    }

    public static void Case21(@IntRange(from = 0) byte b) {
        @IntRange(from = 0, to = 0x0f) long i1 = b & 0x800000000000000fL;
    }

    public static void Case22(@IntRange(to = -1) byte b) {
        @IntRange(from = 0x8000000000000000L, to = 0x80000000ffffffffL) long i1 = b & 0x80000000ffffffffL;
    }

    public static void Case23(byte b) {
        @IntRange(from = 0x8000000000000000L, to = 0xf0) long i1 = b & 0x80000000000000f0L;
    }

    public static void Issue1623(byte[] bytes) {
        for (int i = 0; i < bytes.length; i++) {
            byte b = bytes[i];
            @IntRange(from = 0, to = 15) int i1 = (b & 0xf0) >> 4;
            @IntRange(from = 0, to = 15) int i2 = b & 0x0f;
        }
    }
}