Package javassist

Examples of javassist.CtConstructor


        int lineNumber = 0;

        try
        {
            CtConstructor ctConstructor = ctClass.getConstructor(descripton.toString());

            lineNumber = ctConstructor.getMethodInfo().getLineNumber(0);

            String sourceFile = ctConstructor.getDeclaringClass().getClassFile2().getSourceFile();

            builder.append(String.format(" (at %s:%d)", sourceFile, lineNumber));
        }
        catch (Exception ex)
        {
View Full Code Here


        try
        {
            // And have a public constructor.

            CtConstructor ctor = ctClass.getConstructor("()V");

            if (!Modifier.isPublic(ctor.getModifiers())) return;
        }
        catch (NotFoundException ex)
        {
            return;
        }
View Full Code Here

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

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

            _ctClass.addConstructor(constructor);

            _constructors.add(new AddedConstructor(parameterTypes, exceptions, body));
        }
View Full Code Here

   protected ConstructorInfo generateConstructorInfo(SignatureKey key)
   {
      CtClass[] params = getParameterTypes(key);
      try
      {
         CtConstructor ctConstructor = ctClass.getDeclaredConstructor(params);
         return generateConstructorInfo(ctConstructor);
      }
      catch (NotFoundException e)
      {
         throw JavassistTypeInfoFactoryImpl.raiseMethodNotFound("for constructor " + getName(), e);
View Full Code Here

         try {
            CtClass targetCt = classPool.makeClass("com.codahale.metrics.MetricRegistry");
            targetCt.setModifiers(Modifier.PUBLIC | Modifier.FINAL);

            CtConstructor constructorCt = new CtConstructor(null, targetCt);
            constructorCt.setModifiers(Modifier.PUBLIC);
            constructorCt.setBody("{ throw new RuntimeException(\"HikariCP Codahale shim says: Codahale metrics library is required but was not found in the classpath\"); }");
            targetCt.addConstructor(constructorCt);

            targetCt.toClass(classPool.getClassLoader(), getClass().getProtectionDomain());
         }
         catch (CannotCompileException cce) {
View Full Code Here

        director.getCtClass(JavassistTemplateBuilder.JavassistTemplate.class.getName()));
  }

  protected void buildConstructor() throws CannotCompileException, NotFoundException {
    // Constructor(Class targetClass, Template[] templates)
    CtConstructor newCtCons = CtNewConstructor.make(
      new CtClass[] {
        director.getCtClass(Class.class.getName()),
        director.getCtClass(Template.class.getName()+"[]")
      },
      new CtClass[0],
View Full Code Here

        director.getCtClass(JavassistTemplateBuilder.JavassistTemplate.class.getName()));
  }

  protected void buildConstructor() throws CannotCompileException, NotFoundException {
    // Constructor(Class targetClass, Template[] templates)
    CtConstructor newCtCons = CtNewConstructor.make(
      new CtClass[] {
        director.getCtClass(Class.class.getName()),
        director.getCtClass(Template.class.getName()+"[]")
      },
      new CtClass[0],
View Full Code Here

        // constructors
        List constructorList = new ArrayList();
        CtConstructor[] constructors = javaClass.getConstructors();
        for (int i = 0; i < constructors.length; i++) {
            CtConstructor constructor = constructors[i];
            constructorList.add(createConstructorMetaData(constructor));
        }
        classMetaData.setConstructors(constructorList);

        // methods
View Full Code Here

            final CtConstructor[] constructors = ctClass.getConstructors();
            for (int i = 0; i < constructors.length; i++) {
                ConstructorMetaData constructorMetaData = JavassistMetaDataMaker.createConstructorMetaData(
                        constructors[i]
                );
                CtConstructor constructor = constructors[i];
                if (constructorFilter(definition, classMetaData, constructorMetaData)) {
                    continue;
                }
                context.markAsAdvised();
View Full Code Here

        for (int i = 0; i < parameterTypes.length; i++) {
            newParameterTypes[i] = parameterTypes[i];
        }
        newParameterTypes[parameterTypes.length] =
        ClassPool.getDefault().get(TransformationUtil.JOIN_POINT_MANAGER_CLASS);
        CtConstructor newConstructor = CtNewConstructor.make(
                newParameterTypes,
                constructor.getExceptionTypes(),
                CtNewConstructor.PASS_NONE,
                null,
                CtMethod.ConstParameter.string(constructor.getSignature()),
                ctClass
        );
        newConstructor.setBody(constructor, null);
        newConstructor.setModifiers(accessFlags);
        CodeAttribute codeAttribute = newConstructor.getMethodInfo().getCodeAttribute();
        codeAttribute.setMaxLocals(codeAttribute.getMaxLocals() + 1);

        ctClass.addConstructor(newConstructor);
    }
View Full Code Here

TOP

Related Classes of javassist.CtConstructor

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.