3 Replies Latest reply on Oct 28, 2005 11:16 AM by chiba

    Constructor -> Method

    marcinbr

      Is it possible to change constructor in method? I tried to change method name but unfortunately there was "super()" statement which left in method and that's why my class isn't compiling. Is it any other way of changing constructor into method?

        • 1. Re: Constructor -> Method
          chiba

          Hi,

          You can remove super()/this() call from a constructor
          if you use javassist.expr.ExprEditor. Please read
          the tutorial for more details.

          • 2. Re: Constructor -> Method
            klagesb5

            I have looked at the tutorial and I can't see how to do this. If you use an ExprEditor to dont you don't get the super call on the edit call back.

            • 3. Re: Constructor -> Method
              chiba

              I have just implemented a convenient method
              toMethod() in CtConstructor. It changes a
              constructor to a method. super() or this() in the
              body of the original constructor is eliminated.

              Please download from CVS HEAD.