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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P1
    • None
    • 1.3.0
    • tools
    • sparc
    • solaris_7

    Description

      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

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: