[jboss-cvs] jbossretro/src/main/org/jboss/ant/tasks/retro ...

Kabir Khan kkhan at jboss.com
Tue Jul 18 07:07:52 EDT 2006


  User: kkhan   
  Date: 06/07/18 07:07:52

  Modified:    src/main/org/jboss/ant/tasks/retro  Weaver.java
  Log:
  Rewrite usage of @Inherited
  
  Revision  Changes    Path
  1.26      +33 -1     jbossretro/src/main/org/jboss/ant/tasks/retro/Weaver.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Weaver.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossretro/src/main/org/jboss/ant/tasks/retro/Weaver.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -b -r1.25 -r1.26
  --- Weaver.java	14 Apr 2006 02:58:26 -0000	1.25
  +++ Weaver.java	18 Jul 2006 11:07:52 -0000	1.26
  @@ -29,6 +29,7 @@
   import java.io.FileReader;
   import java.io.IOException;
   import java.io.PrintWriter;
  +import java.lang.annotation.Inherited;
   import java.net.URL;
   import java.net.URLClassLoader;
   import java.net.URLDecoder;
  @@ -48,6 +49,7 @@
   import javassist.CtNewConstructor;
   import javassist.CtNewMethod;
   import javassist.NotFoundException;
  +import javassist.bytecode.AnnotationsAttribute;
   import javassist.bytecode.ClassFile;
   import javassist.bytecode.ClassFileWriter;
   import javassist.bytecode.CodeAttribute;
  @@ -55,6 +57,7 @@
   import javassist.bytecode.ConstPool;
   import javassist.bytecode.MethodInfo;
   import javassist.bytecode.Opcode;
  +import javassist.bytecode.annotation.Annotation;
   import javassist.expr.ExprEditor;
   
   /**
  @@ -62,7 +65,7 @@
    *
    * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
    * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
  - * @version $Revision: 1.25 $
  + * @version $Revision: 1.26 $
    */
   public class Weaver
   {
  @@ -184,6 +187,7 @@
         // FIXME class rename configurable
         Map<String, String> classRenames = new HashMap<String, String>();
         classRenames.put("java/lang/annotation/Annotation", "org/jboss/lang/Annotation");
  +      classRenames.put("java/lang/annotation/Inherited", "org/jboss/lang/annotation/Inherited");
         classRenames.put("java/lang/Enum", "org/jboss/lang/EnumImpl");
         classRenames.put("java/lang/Iterable", "org/jboss/lang/Iterable");
         classRenames.put("java/lang/StringBuilder", "org/jboss/lang/JBossStringBuilder");
  @@ -460,6 +464,11 @@
            info.setClazz(clazz);
         }
   
  +      if (clazz.isAnnotation())
  +      {
  +         rewriteSystemAnnotations(file);
  +      }
  +
         // Run the converters
         for (CodeConverter converter : converters)
            clazz.instrument(converter);
  @@ -595,6 +604,29 @@
         return newEnum;
      }
   
  +   private void rewriteSystemAnnotations(ClassFile file)
  +   {
  +      AnnotationsAttribute visible = (AnnotationsAttribute) file.getAttribute(AnnotationsAttribute.visibleTag);
  +      if (visible != null)
  +      {
  +         //Only bother with the @Inherited annotation for now, as this is the main thing affecting the container tests
  +         Annotation[] annotations = visible.getAnnotations();
  +         boolean changed = false;
  +         for (int i = 0 ; i < annotations.length ; i++)
  +         {
  +            if (annotations[i].getTypeName().equals(Inherited.class.getName()))
  +            {
  +               annotations[i] = new Annotation("org/jboss/lang/annotation/Inherited", file.getConstPool());
  +               changed = true;
  +            }
  +         }
  +         if (changed)
  +         {
  +            visible.setAnnotations(annotations);
  +         }
  +      }
  +   }
  +   
      private class CompilerClassInfo
      {
         File file;
  
  
  



More information about the jboss-cvs-commits mailing list