0 Replies Latest reply on Nov 18, 2012 6:56 AM by amitabakoptier

    Why creating a new CtTypeClass while compiling

    amitabakoptier

      A Question regarding the usage of CtClass

      I have a scenario where I first add a new field to the class and then add insertBefore which is using that new field.

       

      I noticed javassist on the insertBefore has access to the CtClass (1st image) but later on when looking up the new field it goes through MemberResolver. lookupClass0

      The problem is that if anyone added via public CtClass makeClass(InputStream classfile)  non synchronized method a CtClass based on the original byteCode I will not find the new member I just added.

       

      My questions are

      1. Why do we need to look up the CtClass in the pool if we had it at the beginning of the insertBefore flow ?  e.g. use the same instance throughout the flow
      2. Why are some of the ClassPool makeClass syncronized and some are not ?