JBoss Community

adding parameter annotations dynamically

created by rpslive in Javassist Development - View the full discussion

how can i add parameter annotations to the parameters of a method?

Assume the scenario

public class A(){

       public int sum(int a,int b){

              return a+b;

              }

       public int totalsum(int a,int b,int c){

              return a+b+c;

              }

       }

now the name of this class is passed to the method which will dynamically generate a new well annotated class, say dynamic(String className). The new class should appear as:

@Start

public class newA(){

                    @MethodStart

                    public int sum(

                                   @Param1(value="1st Parameter")

                                   int a,

                                   @Param2(value="2nd Parameter")

                                   int b

                                   ){

                         return a+b;

                         }

                      public int totalsum(

                                          @Param1(value="1st Parameter")

                                          int a,

                                          @Param2(value="2nd Parameter")

                                          int b,

                                          @Param3(value="3rd Parameter")

                                          int c

                                          ){

                              return a+b+c;

                              }

adding annotation to the start of the methods and class is simple but the trickiest part is adding parameter annotations to the variable no of parameters. i found few users on net discussing a solution to this problem but it didn't seems to be working.

Reply to this message by going to Community

Start a new discussion in Javassist Development at Community