Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1185184

Compiler generates unnecessary warning.

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.0beta
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Not verified

      Description

      In this program:
      public class y {

          final static byte testbuf1[] = { -16,-93,-55,-73,-19,-37 };
          final static byte testbuf2[] = { 16, 93, 55, 73, 19, 37 };

          public static void main(String args[]){

              System.out.println("Hello");
          }
      }

      The compiler complains on every value in testbuf1 but none of the values in testbuf2, the warning
      is:
      y.oak:5: Warning: Possible loss of precision. Use an explicit cast to convert int to byte.

      It does *NOT* complain about the small positive integers in testbuf1.

      According to the oak spec, bytes are an 8 bit signed quantity. Thus the legal range for initializers
      is -127 to 128. The compiler recognizes this for the small positive integers but doesn't for the
      small negative ones.

        Attachments

          Activity

            People

            Assignee:
            ahoffsunw Arthur Hoff (Inactive)
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: