Assert keyword position in constructors

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Won't Fix
    • Priority: P4
    • None
    • Affects Version/s: 1.4.2
    • Component/s: specification
    • x86
    • windows_nt

      Name: rmT116609 Date: 08/28/2003


      A DESCRIPTION OF THE REQUEST :
      You cannot make an assertion on constructor parameters before you call this(...) or super(...). E.G.:

      public Class(int value)
      {
        // Intended, but does not work
        assert value < 100 : "value < 100";

        super();

        // Possible, but too late
        assert value < 100 : "value < 100";

        ....
      }


      JUSTIFICATION :
      It must be possible to check parameters before calling super() or this(). Otherwise false parameters would not be checked at the right time and debugging gets more complicated.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      See above in the example
      ACTUAL -
      See above in the example

      ---------- BEGIN SOURCE ----------
      class MyClass
      {

        public MyClass(int value)
        {
          // Intended, but not compilable
          assert value < 100 : "value < 100";

          super();
        }

      }

      ---------- END SOURCE ----------
      (Incident Review ID: 200127)
      ======================================================================

            Assignee:
            Alex Buckley
            Reporter:
            Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: