1 Reply Latest reply on Apr 13, 2005 12:23 PM by Shigeru Chiba

    Use JavAssist to obtain class annotation-list

    gilad haimov Newbie

      Hi All,

      I am currently working of a project which involves applying bytecode manipulation via Javassist to a set of annotation-marked methods.

      We do so by traversing & loading all relevant classes,
      going through all of its methods and use reflection to
      examine their annotation list, i.e.:

      Class clazz = Class.forName(..);
      Method[] methodList = clazz.getMethods();
      for each method {
      Annotation[] annotationList = method.getAnnotations()
      // and look for my own marker annotation here

      I have recently read a post by Bill Burke which leads
      me to believe that there might be a more efficient
      way of achieving my task:

      "I have to iterate through all classes in the jar to see if they are annotated. I do this through Javassist (so the classes don't have to be loaded. )"

      Can I, and how can I, use JavAssist to check class's
      annotation list without loading it?

      Thanks in advance,

      Gilad Haimov