javac allows to constructor invoke itself through invocations involving 'this'

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P1
    • None
    • Affects Version/s: 1.3.0
    • Component/s: tools
    • sparc
    • solaris_7

      The following code has been compiled with Kestrel's javac:

      class X {
         X(int i) {
            this();
         }
         X() {
            this(10);// error
         }
      }

      The execution of such class caused java.lang.StackOverflowError.

      According to JLS 8.6.5 "It is a compile-time error for a constructor to directly or
      indirectly invoke itself through a series of one or more explicit constructor invocations
      involving 'this'."

      So, "A constructor cannot invoke itself using "this" error message should appear.

      konstantin.boudnik@eng 2000-02-15

            Assignee:
            William Maddox (Inactive)
            Reporter:
            Konstantin Boudnik (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: