1 Reply Latest reply on Aug 23, 2003 1:33 AM by chiba

    to change a field modifier

    vc

      Could anybody help me with the following problem that looks trivial? I need to change a field modifier for a certain class.

      my code is:

      ClassPool pool = ClassPool.getDefault();
      pool.insertClassPath("C:/...");
      Loader classLoader = new Loader(pool);
      CtClass clazz = pool.get("HelloWorld");
      CtField f = clazz.getField("text");
      f.setModifiers(Modifier.PUBLIC);
      pool.writeFile("HelloWorld");

      The "text" field stayed private, why?

      I'm using javassist2.5.1

      Thankx

        • 1. Re: to change a field modifier
          chiba

          That was a bug. It has been fixed and the updated
          code is in the CVS. You can download it from the
          CVS if you need the fix right now.

          I'll make a new release package 2.6 by the end of
          August.