jjg@409: /* jjg@409: * @test /nodynamiccopyright/ jjg@409: * @bug 6860973 jjg@409: * @summary Project Coin: underscores in literals jjg@409: * jjg@409: * @compile/fail BadUnderscoreLiterals.java jjg@409: * @compile/fail/ref=BadUnderscoreLiterals.7.out -XDrawDiagnostics BadUnderscoreLiterals.java jjg@409: * jjg@409: * @compile/fail -source 6 BadUnderscoreLiterals.java jjg@757: * @compile/fail/ref=BadUnderscoreLiterals.6.out -XDrawDiagnostics -source 6 -Xlint:-options BadUnderscoreLiterals.java jjg@409: */ jjg@409: jjg@409: public class BadUnderscoreLiterals { jjg@409: int valid = 1_1; // valid literal; illegal in -source 6 jjg@409: jjg@409: // test zero jjg@409: int z1 = _0; // valid (but undefined) variable jjg@409: int z2 = 0_; // trailing underscore jjg@409: jjg@409: // test simple (decimal) integers jjg@409: int i1 = _1_2_3; // valid (but undefined) variable jjg@409: int i2 = 1_2_3_; // trailing underscore jjg@409: jjg@409: // test binary integers jjg@409: int b1 = 0b_0; // leading underscore after radix jjg@409: int b2 = 0b0_; // trailing underscore jjg@409: jjg@409: // test hexadecimal integers jjg@409: int x1 = 0x_0; // leading underscore after radix jjg@409: int x2 = 0x0_; // trailing underscore jjg@409: jjg@409: // test floating point numbers jjg@409: float f1 = 0_.1; // trailing underscore before decimal point jjg@409: float f2 = 0._1; // leading underscore after decimal point jjg@409: float f3 = 0.1_; // trailing underscore jjg@409: float f4 = 0.1_e0; // trailing underscore before exponent jjg@409: float f5 = 0e_1; // leading underscore in exponent jjg@409: float f6 = 0e1_; // trailing underscore in exponent jjg@409: jjg@409: // hexadecimal floating point jjg@409: float xf1 = 0x_0.1p0; // leading underscore after radix jjg@409: float xf2 = 0x0_.1p0; // trailing underscore before decimal point jjg@409: float xf3 = 0x0._1p0; // leading underscore after decimal point jjg@409: float xf4 = 0x0.1_p0; // trailing underscore before exponent jjg@409: float xf5 = 0x0p_1; // leading underscore after exponent jjg@409: float xf6 = 0x0p1_; // trailing underscore jjg@409: } jjg@409: