1 Reply Latest reply on Nov 23, 2005 11:06 PM by chiba

    copying methods

    johncoleman

      How would I implement methods that I copy from an interface in a CtClass,
      to a class I have as a ClassFile.

      ClassFile seems only to allow to add methods using a MethodInfo, so how is the body added?

      Basically I want to implement an interface on a class, and if that class has some getter or setter methods of the interface missing, then I want to add those methods in using the definition in the interface, and providing bodies that interact with a superclass for values.

        • 1. Re: copying methods
          chiba

          I again recommend you to use ClassPool and CtClass, CtMethod, ... They provide a number of utility methods
          for creating a getter method etc.

          Otherwise, you must construct a MethodInfo by hand
          (you must specify a sequence Java bytecode as a body).
          Bytecode class would help you.