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

    to change a field modifier

    vc Newbie

      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