{
if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug(introduction.getAnnotation() + " binds to " + clazz.getName());
javassist.bytecode.annotation.Annotation info = AnnotationInfoCreator.createAnnotationInfo(classPool, clazz.getClassFile2().getConstPool(), introduction.getAnnotation());
if (introduction.isInvisible())
{
AnnotationsAttribute invisible = (AnnotationsAttribute) clazz.getClassFile2().getAttribute(AnnotationsAttribute.invisibleTag);
if (invisible == null)
{
invisible = new AnnotationsAttribute(clazz.getClassFile2().getConstPool(), AnnotationsAttribute.invisibleTag);
clazz.getClassFile2().addAttribute(invisible);
}
changed = true;
invisible.addAnnotation(info);
}
else
{
AnnotationsAttribute visible = (AnnotationsAttribute) clazz.getClassFile2().getAttribute(AnnotationsAttribute.visibleTag);
if (visible == null)
{
visible = new AnnotationsAttribute(clazz.getClassFile2().getConstPool(), AnnotationsAttribute.visibleTag);
clazz.getClassFile2().addAttribute(visible);
}
changed = true;
visible.addAnnotation(info);
}
}
CtMethod[] methods = clazz.getDeclaredMethods();
for (int i = 0; i < methods.length; i++)
{
if (introduction.matches(advisor, methods[i]))
{
javassist.bytecode.annotation.Annotation info = AnnotationInfoCreator.createAnnotationInfo(classPool, methods[i].getMethodInfo2().getConstPool(), introduction.getAnnotation());
MethodInfo mi = methods[i].getMethodInfo2();
if (introduction.isInvisible())
{
AnnotationsAttribute invisible = (AnnotationsAttribute) mi.getAttribute(AnnotationsAttribute.invisibleTag);
if (invisible == null)
{
invisible = new AnnotationsAttribute(mi.getConstPool(), AnnotationsAttribute.invisibleTag);
mi.addAttribute(invisible);
}
changed = true;
invisible.addAnnotation(info);
}
else
{
AnnotationsAttribute visible = (AnnotationsAttribute) mi.getAttribute(AnnotationsAttribute.visibleTag);
if (visible == null)
{
visible = new AnnotationsAttribute(mi.getConstPool(), AnnotationsAttribute.visibleTag);
mi.addAttribute(visible);
}
changed = true;
visible.addAnnotation(info);
}
}
}
CtConstructor[] cons = clazz.getDeclaredConstructors();
for (int i = 0; i < cons.length; i++)
{
if (introduction.matches(advisor, cons[i]))
{
javassist.bytecode.annotation.Annotation info = AnnotationInfoCreator.createAnnotationInfo(classPool, cons[i].getMethodInfo2().getConstPool(), introduction.getAnnotation());
MethodInfo mi = cons[i].getMethodInfo2();
if (introduction.isInvisible())
{
AnnotationsAttribute invisible = (AnnotationsAttribute) mi.getAttribute(AnnotationsAttribute.invisibleTag);
if (invisible == null)
{
invisible = new AnnotationsAttribute(mi.getConstPool(), AnnotationsAttribute.invisibleTag);
mi.addAttribute(invisible);
}
changed = true;
invisible.addAnnotation(info);
}
else
{
AnnotationsAttribute visible = (AnnotationsAttribute) mi.getAttribute(AnnotationsAttribute.visibleTag);
if (visible == null)
{
visible = new AnnotationsAttribute(mi.getConstPool(), AnnotationsAttribute.visibleTag);
mi.addAttribute(visible);
}
changed = true;
visible.addAnnotation(info);
}
}
}
CtField[] fields = clazz.getDeclaredFields();
for (int i = 0; i < fields.length; i++)
{
if (introduction.matches(advisor, fields[i]))
{
javassist.bytecode.annotation.Annotation info = AnnotationInfoCreator.createAnnotationInfo(classPool, fields[i].getFieldInfo2().getConstPool(), introduction.getAnnotation());
FieldInfo mi = fields[i].getFieldInfo2();
if (introduction.isInvisible())
{
AnnotationsAttribute invisible = (AnnotationsAttribute) mi.getAttribute(AnnotationsAttribute.invisibleTag);
if (invisible == null)
{
invisible = new AnnotationsAttribute(mi.getConstPool(), AnnotationsAttribute.invisibleTag);
mi.addAttribute(invisible);
}
changed = true;
invisible.addAnnotation(info);
}
else
{
AnnotationsAttribute visible = (AnnotationsAttribute) mi.getAttribute(AnnotationsAttribute.visibleTag);
if (visible == null)
{
visible = new AnnotationsAttribute(mi.getConstPool(), AnnotationsAttribute.visibleTag);
mi.addAttribute(visible);
}
changed = true;
visible.addAnnotation(info);
}
}
}
}
return changed;