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

JLS doesnt specify behavior for 1/0 as a constant expression

XMLWordPrintable

    • merlin
    • x86
    • windows_nt



      Name: tb29552 Date: 10/01/98


      The following code is illegal:

      class X
      {
          static final int i = 1 / 0;
      }

      The value of this compile-time constant is undefined, therefore this
      has to be a compile-time error. Guy Steele confirmed about 18 months
      ago that this was indeed the intended behaviour.

      A compile-time constant has to have its value available statically (that's
      what makes it a compile-time constant ;-) For example, the value of other
      constants whose values are determined by a constant that contains a division
      by zero are undefined. This affects the semantics of switch statements,
      definite assigment and unassignment, etc.

      (Review ID: 39565)
      ======================================================================

            gbrachasunw Gilad Bracha (Inactive)
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: