On PROPOSAL Narrow Hexadecimal and Binary Integer Literals

Weijun Wang Weijun.Wang at Sun.COM
Tue May 5 02:07:51 PDT 2009


Hi All

I'm reading this proposal, which recommends:

   byte[] stuff = { 0x00, 0x7F, (byte)0x80,  (byte)0xFF};

can be recoded as

   byte[] ufum7 = { 0h00, 0h7F, 0h80, 0hFF};

How about using the C style?

   byte[] bs = '\x00\x7f\x80\xff';

This should work since multiple bytes in '' is illegal now. When you
want to create a byte[] with only one element, you still have to write

   byte[] bs = { 0x00 };

BTW, if the VM can be enhanced to support byte[] in constant pool, that
will be even better. Of course, if the VM is already able to view
bytecodes from the statement above as a single byte block reference,
that's enough.

Thanks
Max




More information about the coin-dev mailing list