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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1
    • Resolution: Duplicate
    • Affects Version/s: 1.3.0
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      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

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: