3 Replies Latest reply on Dec 1, 2005 6:09 AM by Ben Klages

    How to replace classname in local var declaration?

    david ding Newbie

      Hi,

      I encountered a problem in trying to replace classname in a class.
      Original code looks like:

       public void test()
       {
       String str = new String("123");
       System.out.println(str);
       }
      

      When I apply replaceClassName("java.lang.String", "MyString") on the containing class, I got:
       public void test()
       {
       String str = new MyString("123");
       System.out.println(str);
       }
      

      But I want it to be:
       public void test()
       {
       MyString str = new MyString("123");
       System.out.println(str);
       }
      

      How could I do this with javassist? Thanks!

      best,