0 Replies Latest reply on Mar 28, 2013 1:42 PM by darthrooster

    Multi ClassPool

    darthrooster Newbie

      Hi, i am newbe in Javassist and i have this problem:

       

      i have below code:

       

              ClassPool pool = ClassPool.getDefault();

              ClassPool pool2 = ClassPool.getDefault();

              ClassPool pool1 = new ClassPool(true); //Copy default classload

           

              Loader cl = new Loader(pool);

              Loader cl1 = new Loader(pool2);

              Loader cl2 = new Loader(pool1);

             

              ResProtAdapt.add(pool,"packageMain.TestMedia", "public static int TestMedia(int i, int j) { System.out.println(i+j); return i+j; }", "method");

              ResProtAdapt.add(pool, "packageMain.TestMedia","public int Sum(int i) { return i + 1;  }" , "method");

              ResProtAdapt.add(pool2, "packageMain.TestMedia","public int Summ(int i) { return i + 1;  }" , "method");

       

      When it run, i have this output:

       

      Description for class: packageMain.TestMedia

       

      POOL:

      Summary

      -------------------------------------

      Constructors: 1

      Fields: 0

      Methods: 5

       

      Details

      -------------------------------------

       

      Constructors:

      public packageMain.TestMedia()

       

      Methods:

      public static int packageMain.TestMedia.TestMedia(int,int)

      public int packageMain.TestMedia.test(int)

      public static int packageMain.TestMedia.calcolaMedia(int[])

      public int packageMain.TestMedia.Sum(int)

      public int packageMain.TestMedia.Summ(int)

      Description for class: packageMain.TestMedia

       

       

       

      POOL2:

      Summary

      -------------------------------------

      Constructors: 1

      Fields: 0

      Methods: 2

       

        

      Details

      -------------------------------------

       

       

      Constructors:

      public packageMain.TestMedia()

       

       

      Methods:

      public int packageMain.TestMedia.test(int)

      public static int packageMain.TestMedia.calcolaMedia(int[])

      Description for class: packageMain.TestMedia

       

      POOL1:

      Summary

      -------------------------------------

      Constructors: 1

      Fields: 0

      Methods: 5

         

      Details

      -------------------------------------

       

       

      Constructors:

      public packageMain.TestMedia()

       

       

      Methods:

      public static int packageMain.TestMedia.TestMedia(int,int)

      public int packageMain.TestMedia.test(int)

      public static int packageMain.TestMedia.calcolaMedia(int[])

      public int packageMain.TestMedia.Sum(int)

      public int packageMain.TestMedia.Summ(int)

       

      I would like that when i insert method in pool,it is not also projected in pool2...

       

      I hope I was clear

       

      thanks