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