Package javassist.bytecode

Examples of javassist.bytecode.FieldInfo


         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);
               }
            }
View Full Code Here


      CtClass managedCtClass,
      CtField persistentField,
      AttributeTypeDescriptor typeDescriptor)
      throws BadBytecode, CannotCompileException {

    final FieldInfo fieldInfo = persistentField.getFieldInfo();
    final String fieldName = fieldInfo.getName();
    final String readerName = EnhancerConstants.PERSISTENT_FIELD_READER_PREFIX + fieldName;

    // read attempts only have to deal lazy-loading support, not dirty checking; so if the field
    // is not enabled as lazy-loadable return a plain simple getter as the reader
    if ( ! enhancementContext.isLazyLoadable( persistentField ) ) {
View Full Code Here

  private CtMethod generateFieldWriter(
      CtClass managedCtClass,
      CtField persistentField,
      AttributeTypeDescriptor typeDescriptor) {

    final FieldInfo fieldInfo = persistentField.getFieldInfo();
    final String fieldName = fieldInfo.getName();
    final String writerName = EnhancerConstants.PERSISTENT_FIELD_WRITER_PREFIX + fieldName;

    final CtMethod writer;

    try {
View Full Code Here

        
         ArrayList<PrecedenceDefEntry> entries = new ArrayList<PrecedenceDefEntry>();
         Iterator<FieldInfo> fields = cf.getFields().iterator();
         while (fields.hasNext())
         {
            FieldInfo finfo = fields.next();
            AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
            if (mgroup == null) continue;
            javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(PrecedenceInterceptor.class.getName());
            if (binfo != null)
            {
               //TODO Make sure it is an interceptor
View Full Code Here

   throws Exception
   {
      Iterator<FieldInfo> fields = cf.getFields().iterator();
      while (fields.hasNext())
      {
         FieldInfo finfo = fields.next();
         AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
         if (mgroup == null) continue;
         javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(PointcutDef.class.getName());
         if (binfo == null) continue;
         PointcutDef pdef = (PointcutDef) AnnotationProxy.createProxy(binfo, PointcutDef.class);
View Full Code Here

   throws Exception
   {
      Iterator<FieldInfo> fields = cf.getFields().iterator();
      while (fields.hasNext())
      {
         FieldInfo finfo = fields.next();
         AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
         if (mgroup == null) continue;
         javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(PointcutDef.class.getName());
         if (binfo == null) continue;
         loaderStrategy.undeployPointcut(this, getPointcutName(cf, finfo));
      }
View Full Code Here

   throws Exception
   {
      Iterator<FieldInfo> fields = cf.getFields().iterator();
      while (fields.hasNext())
      {
         FieldInfo finfo = fields.next();
         AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
         if (mgroup == null) continue;
         javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(Introduction.class.getName());
         if (binfo == null) continue;
        
         //Since some of the values are of type Class, and method gets called by the system classloader (via Agent)
         // for loadtime aop in jdk 1.5 the classes we try to look at might not yet have been loaded. We're
         //only after the names anyway, so we bypass the AnnotationProxy/ProxyMapCreator which tries to validate
         //class names by loading the (so far) non-existent class.
        
         //Introduction introduction = (Introduction) AnnotationProxy.createProxy(binfo, Introduction.class);
         //String target = introduction.target();
         //String  typeExpression = introduction.typeExpression();
         //String[] interfaces = introduction.interfaces();
        
         MemberValue mv = binfo.getMemberValue("target");
         String target = (mv != null) ? ((ClassMemberValue) mv).getValue() : "java.lang.Class";//Note! this should be the same as the default in @Interceptor

         mv = binfo.getMemberValue("typeExpression");
         String typeExpression = (mv != null) ? ((StringMemberValue) mv).getValue() : "";//Note! this should be the same as the default in @Interceptor

         mv = binfo.getMemberValue("interfaces");
         MemberValue[] values = ((ArrayMemberValue) mv).getValue();
         String[] interfaces = new String[values.length];
         for (int i = 0; i < values.length; i++) interfaces[i] = ((ClassMemberValue) values[i]).getValue();

         String name = cf.getName() + "." + finfo.getName(); //Name of the field defined on

         InterfaceIntroductionInfo interfaceIntro = createIntroduction(name, target, typeExpression, interfaces, null, null);
         loaderStrategy.deployInterfaceIntroduction(this, interfaceIntro);
      }
   }
View Full Code Here

   throws Exception
   {
      Iterator<FieldInfo> fields = cf.getFields().iterator();
      while (fields.hasNext())
      {
         FieldInfo finfo = fields.next();
         AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
         if (mgroup == null) continue;
         javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(Introduction.class.getName());
         if (binfo == null) continue;

         String name = cf.getName() + "." + finfo.getName(); //Name of the field defined on

         loaderStrategy.undeployInterfaceIntroduction(this, name);
      }
   }
View Full Code Here

   private void deployTypedefs(ClassFile cf) throws Exception
   {
      Iterator<FieldInfo> fields = cf.getFields().iterator();
      while (fields.hasNext())
      {
         FieldInfo finfo = fields.next();
         AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
         if (mgroup == null) continue;
         javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(TypeDef.class.getName());
         if (binfo == null) continue;
         TypeDef typeDefinition = (TypeDef) AnnotationProxy.createProxy(binfo, TypeDef.class);
View Full Code Here

   private void undeployTypedefs(ClassFile cf) throws Exception
   {
      Iterator<FieldInfo> fields = cf.getFields().iterator();
      while (fields.hasNext())
      {
         FieldInfo finfo = fields.next();
         AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
         if (mgroup == null) continue;
         javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(TypeDef.class.getName());
         if (binfo == null) continue;

         AnnotationProxy.createProxy(binfo, TypeDef.class);
View Full Code Here

TOP

Related Classes of javassist.bytecode.FieldInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.