3 Replies Latest reply on Nov 23, 2005 9:44 AM by Shigeru Chiba

    field = new CtField seems to do nothing

    Dominik Bernhard Newbie


      i just started with javassist and did some research for myself. I generated a CtClass, added some field, methods and constructors, wrote it to a file and loaded it.

      While i`m not able to view the code i use java.reflect to get some information about my class.

      So heres the Problem:

      Generated a field:

      field = new CtField(CtClass.intType,"y",cc);

      Then with reflect:

      Field[] fields = clazz2.getFields();
      ...(Where clazz2 is the loaded CtClass cc)

      The Output said: 0. This was a little bit confusing while i just added the field, so i thought.

      Then my next approch:

      Also created a field:

      field = CtField.make("public int z;",cc);

      And now the .lengt Output said: 1.

      So whats wrong does either java.reflect not work or javassist.

      With Regards
      Dominik Bernhard