2 Replies Latest reply on Jul 1, 2005 2:35 AM by azzazzel

    circular references

    azzazzel

      May be I didn't read the docs carefuly enugh but I can not figure out how to create 2 (or more) classes referencing each other.

      Can someone provide an example of how to genearate these two classes for example:

      public class A {
       private B b;
      
       //get instance of B
       public B getB () {
       return b;
       }
      }
      
      public class B {
       private A a;
      
       //get instance of A
       public A getA () {
       }
      }
      


      All my attempts ended with "ClassNotFound" exception thrown by javassist at compile time



        • 1. Re: circular references
          chiba

          "Mutual recursive methods" in Section 4.3 of the tutorial
          has some hints. To create two classes that refer to each
          other, you must first create empty CtClasses for the two
          classes and then add fields and methods.

          • 2. Re: circular references
            azzazzel

            10x a lot chiba
            Should have figured this out myself. It's so obvious now.

            Now all that's left is to congratulate you the great work you have done on javassist. In today's AOP and DynaBean java world it's a life saver ;)