langtools/test/tools/javac/literals/BadBinaryLiterals.java
author ssides
Wed, 09 Jul 2014 15:14:06 +0400
changeset 25760 7955db32d6b0
parent 7335 8b390fd27190
permissions -rw-r--r--
8046597: fix doclint issues in swing classes, part 4 of 4 Reviewed-by: pchelko
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3895
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     1
/*
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     2
 * @test /nodynamiccopyright/
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     3
 * @bug 6860965
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     4
 * @summary Project Coin: binary literals
7335
8b390fd27190 6900037: javac should warn if earlier -source is used and bootclasspath not set
jjg
parents: 3895
diff changeset
     5
 * @compile/fail/ref=BadBinaryLiterals.6.out -XDrawDiagnostics -source 6 -Xlint:-options BadBinaryLiterals.java
3895
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     6
 * @compile/fail/ref=BadBinaryLiterals.7.out -XDrawDiagnostics BadBinaryLiterals.java
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     7
 */
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     8
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     9
public class BadBinaryLiterals {
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    10
    int valid = 0b0;            // valid literal, illegal in source 6
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    11
    int baddigit = 0b012;       // bad digit
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    12
                    //aaaabbbbccccddddeeeeffffgggghhhh
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    13
    int overflow1 = 0b111111111111111111111111111111111; // too long for int
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    14
                    //aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooopppp
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    15
    int overflow2 = 0b11111111111111111111111111111111111111111111111111111111111111111L; // too long for long
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    16
    float badfloat1 = 0b01.01;  // no binary floats
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    17
    float badfloat2 = 0b01e01;  // no binary floats
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    18
}