Package javassist

Examples of javassist.CodeConverter


    * @return
    * @throws NotFoundException
    */
   public boolean replaceFieldAccess(List<CtField> fields, CtClass clazz, ClassAdvisor fieldsAdvisor) throws NotFoundException
   {
      CodeConverter converter = instrumentor.getCodeConverter();
      boolean converted = false;
      for (CtField field : fields)
      {
         if (!Modifier.isPrivate(field.getModifiers()) && Advisable.isAdvisable(field))
         {
            JoinpointClassification fieldGetClassification = classifier.classifyFieldGet(field, fieldsAdvisor);

            if (fieldGetClassification.equals(JoinpointClassification.WRAPPED))
            {
               converted = true;
               converter.replaceFieldRead(field, clazz, fieldRead(field.getName()));
            }
            JoinpointClassification fieldSetClassification = classifier.classifyFieldSet(field, fieldsAdvisor);
            if (fieldSetClassification.equals(JoinpointClassification.WRAPPED))
            {
               converted = true;
               converter.replaceFieldWrite(field, clazz, fieldWrite(field.getName()));
            }
         }
      }
      return converted;
   }
View Full Code Here


/*     */   }
/*     */
/*     */   public boolean replaceFieldAccess(List fields, CtClass clazz, ClassAdvisor fieldsAdvisor)
/*     */     throws NotFoundException
/*     */   {
/* 207 */     CodeConverter converter = this.instrumentor.getCodeConverter();
/* 208 */     boolean converted = false;
/* 209 */     Iterator it = fields.iterator();
/* 210 */     while (it.hasNext())
/*     */     {
/* 212 */       CtField field = (CtField)it.next();
/* 213 */       if ((!Modifier.isPrivate(field.getModifiers())) && (Advisable.isAdvisable(field)))
/*     */       {
/* 215 */         JoinpointClassification fieldGetClassification = this.classifier.classifyFieldGet(field, fieldsAdvisor);
/*     */
/* 217 */         if (fieldGetClassification.equals(JoinpointClassification.WRAPPED))
/*     */         {
/* 219 */           converted = true;
/* 220 */           converter.replaceFieldRead(field, clazz, fieldRead(field.getName()));
/*     */         }
/* 222 */         JoinpointClassification fieldSetClassification = this.classifier.classifyFieldSet(field, fieldsAdvisor);
/* 223 */         if (fieldSetClassification.equals(JoinpointClassification.WRAPPED))
/*     */         {
/* 225 */           converted = true;
/* 226 */           converter.replaceFieldWrite(field, clazz, fieldWrite(field.getName()));
/*     */         }
/*     */       }
/*     */     }
/* 230 */     return converted;
/*     */   }
View Full Code Here

         AspectManager manager,
         JoinpointClassifier joinpointClassifier,
         DynamicTransformationObserver observer)
   {
      this.classPool = pool;
      this.converter = new CodeConverter();
      this.manager = manager;
      this.joinpointClassifier = joinpointClassifier;
      this.dynamicTransformationObserver = observer;
      intitialiseTransformers();
   }
View Full Code Here

    * @param joinpointUpdates a collection of <code>org.jboss.aop.instrument.JoinpointStatusUpdate</code>.
    * @param hotSwapper object capable of hot swapping classes.
    */
   public synchronized void interceptorChainsUpdated(Collection joinpointUpdates, HotSwapper hotSwapper) {
      //creates a converter
      this.converter = new CodeConverter();
      // list of instrumented classes
      Collection classes = new HashSet();
      try {
         // transform classes whose joinpont status have changed
         for (Iterator iterator = joinpointUpdates.iterator(); iterator.hasNext(); )
View Full Code Here

    */
   public void convertProcessedClasses(HotSwapper hotSwapper, CtClass clazz,
         Collection fieldReads, Collection fieldWrites, boolean constructor)
   {
      AOPClassPool classPool = (AOPClassPool) clazz.getClassPool();
      CodeConverter codeConverter = new CodeConverter();
      for (Iterator iterator = fieldReads.iterator(); iterator.hasNext(); )
      {
         CtField field = (CtField) iterator.next();
         codeConverter.replaceFieldRead(field, clazz, fieldAccessTransformer.fieldRead(field.getName()));
      }
      for (Iterator iterator = fieldWrites.iterator(); iterator.hasNext(); )
      {
         CtField field = (CtField) iterator.next();
         codeConverter.replaceFieldWrite(field, clazz, fieldAccessTransformer.fieldWrite(field.getName()));
      }
      if (constructor)
      {
         codeConverter.replaceNew(clazz, clazz, ConstructorExecutionTransformer.constructorFactory(clazz.getSimpleName()));
      }

      synchronized(processedClasses)
      {
      for (Iterator iterator = processedClasses.iterator(); iterator.hasNext();)
View Full Code Here

/*     */   }
/*     */
/*     */   public Reflection()
/*     */   {
/*  96 */     this.classPool = null;
/*  97 */     this.converter = new CodeConverter();
/*     */   }
View Full Code Here

    public void setUp() throws Exception {
        ClassPool pool = new ClassPool(true);
        CtClass echoClass = pool.get(ArrayAccessReplaceTest.class.getName() + "$Echo");
        CtClass simpleClass = pool.get(ArrayAccessReplaceTest.class.getName() + "$Simple");
        CodeConverter converter = new CodeConverter();
        converter.replaceArrayAccess(echoClass, new CodeConverter.DefaultArrayAccessReplacementMethodNames());
        simpleClass.instrument(converter);
        //simpleClass.writeFile("/tmp");
        simple = (SimpleInterface) simpleClass.toClass(new URLClassLoader(new URL[0], getClass().getClassLoader()), Class.class.getProtectionDomain()).newInstance();
    }
View Full Code Here

    public void testComplex() throws Exception {
        ClassPool pool = new ClassPool(true);
        CtClass clazz = pool.get(ArrayAccessReplaceTest.class.getName() + "$Complex");

        CodeConverter converter = new CodeConverter();
        converter.replaceArrayAccess(clazz, new CodeConverter.DefaultArrayAccessReplacementMethodNames());
        clazz.instrument(converter);
        ComplexInterface instance = (ComplexInterface) clazz.toClass(new URLClassLoader(new URL[0], getClass().getClassLoader()), Class.class.getProtectionDomain()).newInstance();
        assertEquals(new Integer(5), instance.complexRead(4));
    }
View Full Code Here

         AspectManager manager,
         JoinpointClassifier joinpointClassifier,
         DynamicTransformationObserver observer)
   {
      this.classPool = pool;
      this.converter = new CodeConverter();
      this.manager = manager;
      this.joinpointClassifier = joinpointClassifier;
      this.dynamicTransformationObserver = observer;
      intitialiseTransformers();
   }
View Full Code Here

    * @param joinpointUpdates a collection of <code>org.jboss.aop.instrument.JoinpointStatusUpdate</code>.
    * @param hotSwapper object capable of hot swapping classes.
    */
   public synchronized void interceptorChainsUpdated(Collection<JoinpointStatusUpdate> joinpointUpdates, HotSwapper hotSwapper) {
      //creates a converter
      this.converter = new CodeConverter();
      // list of instrumented classes
      Collection<CtClass> classes = new HashSet<CtClass>();
      try {
         // transform classes whose joinpont status have changed
         for (JoinpointStatusUpdate update : joinpointUpdates)
View Full Code Here

TOP

Related Classes of javassist.CodeConverter

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.