Examples of CtConstructor


Examples of javassist.CtConstructor

      body.append(");");
      body.append(aspectInitialization);
      body.append(init.toString());
     
      body.append("}");  
      CtConstructor ctor = CtNewConstructor.make(
          params,
          superCtor.getExceptionTypes(),
          body.toString(),
          clazz);
         ctor.setModifiers(superCtor.getModifiers());
         clazz.addConstructor(ctor);
   }
View Full Code Here

Examples of javassist.CtConstructor

         }
         superClass = superClass.getSuperclass();
      }
      body.append("}");
     
      CtConstructor copyCtor = CtNewConstructor.make(new CtClass[] {clazz}, new CtClass[0], body.toString(), clazz);
      copyCtor.setModifiers(Modifier.PRIVATE);
      clazz.addConstructor(copyCtor);
     
      CtMethod superCopy = pool.get(Invocation.class.getName()).getDeclaredMethod("copy");
      String copyBody =
         "{" +
View Full Code Here

Examples of javassist.CtConstructor

  
   private void copyConstructors(CtClass superclass, CtClass proxy) throws Exception
   {
      CtConstructor[] ctors = superclass.getConstructors();
      int minParameters = Integer.MAX_VALUE;
      CtConstructor bestCtor = null;
      for (int i = 0 ; i < ctors.length ; i++)
      {
         CtClass[] params = ctors[i].getParameterTypes();
        
         CtConstructor ctor = CtNewConstructor.make(
            ctors[i].getParameterTypes(),
            ctors[i].getExceptionTypes(),
            CtNewConstructor.PASS_PARAMS,
            null,
            null,
            proxy);
         ctor.setModifiers(ctors[i].getModifiers());
         proxy.addConstructor(ctor);

         if (params.length < minParameters)
         {
            bestCtor = ctor;
View Full Code Here

Examples of javassist.CtConstructor

            CtField field = CtField.class.cast(member);
            return new JavassistFieldSignature(field);
         }
         if (member instanceof CtConstructor)
         {
            CtConstructor constructor = CtConstructor.class.cast(member);
            return new JavassistConstructorSignature(constructor);
         }
      }
      catch (NotFoundException e)
      {
View Full Code Here

Examples of javassist.CtConstructor

        CtClass[] ctParameters = convertClasses(parameterTypes);
        CtClass[] ctExceptions = convertClasses(exceptions);

        try
        {
            CtConstructor constructor = new CtConstructor(ctParameters, getCtClass());
            constructor.setExceptionTypes(ctExceptions);
            constructor.setBody(body);

            getCtClass().addConstructor(constructor);
        }
        catch (Exception ex)
        {
View Full Code Here

Examples of javassist.CtConstructor

        CtClass ctClass = pool.makeClass(CLASS);

        ctClass.setModifiers(Modifier.ABSTRACT | Modifier.PUBLIC);
        ctClass.addInterface(pool.get(ReloadableService.class.getName()));

        CtConstructor constructor = new CtConstructor(new CtClass[0], ctClass);

        constructor.setBody("return $0;");

        constructor.setModifiers(Modifier.PROTECTED);

        ctClass.addConstructor(constructor);

        ctClass.writeFile(classesDir.getAbsolutePath());
    }
View Full Code Here

Examples of javassist.CtConstructor

  
   private void copyConstructors(CtClass superclass, CtClass proxy) throws Exception
   {
      CtConstructor[] ctors = superclass.getConstructors();
      int minParameters = Integer.MAX_VALUE;
      CtConstructor bestCtor = null;
      for (int i = 0 ; i < ctors.length ; i++)
      {
         CtClass[] params = ctors[i].getParameterTypes();
        
         CtConstructor ctor = CtNewConstructor.make(
            ctors[i].getParameterTypes(),
            ctors[i].getExceptionTypes(),
            CtNewConstructor.PASS_PARAMS,
            null,
            null,
            proxy);
         ctor.setModifiers(ctors[i].getModifiers());
         proxy.addConstructor(ctor);

         if (params.length < minParameters)
         {
            bestCtor = ctor;
View Full Code Here

Examples of javassist.CtConstructor

      return getMethodSignature(info);
   }
  
   private static SignatureAttribute.MethodSignature getMethodSignature(Constructor c)
   {
      CtConstructor con = JavassistUtil.getCtConstructor(c);
      MethodInfo info = con.getMethodInfo2();
      return getMethodSignature(info);
   }
View Full Code Here

Examples of javassist.CtConstructor

        
         if (INIT.equals(name))
         {
            try
            {
               CtConstructor ctConstructor = clazz.getConstructor(descriptor);
               ctConstructor.getParameterTypes();
            }
            catch (NotFoundException e)
            {
               if (failed == 0)
                  System.out.println("==== " + info.getFile());
               System.out.println("Cannot find constructor parameter types " + name + "." + descriptor);
               ++failed;
            }
            try
            {
               CtConstructor ctConstructor = clazz.getConstructor(descriptor);
               ctConstructor.getExceptionTypes();
            }
            catch (NotFoundException e)
            {
               if (failed == 0)
                  System.out.println("==== " + info.getFile());
View Full Code Here

Examples of javassist.CtConstructor

   /**
    * Currently only method joinpoints need serialization and thus a default ctor
    */
   private void createDefaultConstructor(CtConstructor superCtor, CtClass clazz) throws CannotCompileException
   {
      CtConstructor ctor = CtNewConstructor.defaultConstructor(clazz);
      clazz.addConstructor(ctor);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.