Examples of makeClass()


Examples of javassist.ClassPool.makeClass()

  private static final FieldComparator fieldComparator = new FieldComparator();
 
  private CtClass createSerializationClass(String className, boolean deserializer) {
    ClassPool cp = ClassPool.getDefault();   
   
    CtClass cl = cp.makeClass(className+"$__"+(deserializer?"DE":"")+"SERIALIZER__");
   
    String interfaceName = (deserializer?Deserializer.class.getName():Serializer.class.getName());
    try {
      cl.addInterface(cp.get(interfaceName));
    } catch (NotFoundException e) {
View Full Code Here

Examples of javassist.ClassPool.makeClass()

         ClassPool classPool = new ClassPool();
         classPool.appendClassPath(new LoaderClassPath(this.getClass().getClassLoader()));

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

Examples of javassist.ClassPool.makeClass()

      Class wrapperType;
      try
      {
         ClassPool pool = new ClassPool(true);
         pool.appendClassPath(new LoaderClassPath(loader));
         CtClass clazz = pool.makeClass(wrapperName);
         clazz.setSuperclass(pool.get(WrapperType.class.getName()));

         for (WrappedParameter param : wrappedParameters)
         {
            CtField field = new CtField(pool.get(param.getType()), param.getVariable(), clazz);
View Full Code Here

Examples of javassist.ClassPool.makeClass()

      Class wrapperType;
      try
      {
         ClassPool pool = new ClassPool(true);
         pool.appendClassPath(new LoaderClassPath(loader));
         CtClass clazz = pool.makeClass(wrapperName);
         clazz.setSuperclass(pool.get(WrapperType.class.getName()));

         for (WrappedParameter param : wrappedParameters)
         {
            CtField field = new CtField(pool.get(param.getType()), param.getVariable(), clazz);
View Full Code Here

Examples of javassist.ClassPool.makeClass()

            Class<?> parameterClass;
            try {
                parameterClass = (Class<?>) Class.forName(parameterClassName, true, clazz.getClassLoader());
            } catch (ClassNotFoundException e) {
                ClassPool pool = ClassGenerator.getClassPool(clazz.getClassLoader());
                CtClass ctClass = pool.makeClass(parameterClassName);
                ClassFile classFile = ctClass.getClassFile();
                classFile.setVersionToJava5();
                ctClass.addConstructor(CtNewConstructor.defaultConstructor(pool.getCtClass(parameterClassName)));
                // parameter fields
                Class<?>[] parameterTypes = method.getParameterTypes();
View Full Code Here

Examples of javassist.ClassPool.makeClass()

    // generate class file
    try {
      // new class
      ClassPool pool = ClassPool.getDefault();
      CtClass clazz = pool.makeClass(fullName);

      // add a default constructor
      CtConstructor constructor = new CtConstructor(null, clazz);
      constructor.setBody("{super();}");
      clazz.addConstructor(constructor);
View Full Code Here

Examples of javassist.ClassPool.makeClass()

     * Revisit this after javassist support java 8
     */
    @SuppressWarnings({ "unchecked" })
    private <E extends Serializable> CopyExtractor<E> getExtractor(Class<E> clz, List<Method> fieldMethods) {
        ClassPool pool = ClassPool.getDefault();
        CtClass cc = pool.makeClass("com.eclecticlogic.pedal.dialect.postgresql." + clz.getSimpleName()
                + "$CopyExtractor");

        StringBuilder methodBody = new StringBuilder();
        try {
            cc.addInterface(pool.getCtClass(CopyExtractor.class.getName()));
View Full Code Here

Examples of javassist.ClassPool.makeClass()

    final ClassPool classPool = new ClassPool(true);
    classPool.appendClassPath(new LoaderClassPath(dependenciesClassLoader));

    final InputStream inputStream = new BufferedInputStream( new FileInputStream( classFile ) );
    try {
      compiledClass = classPool.makeClass( inputStream );
    } finally {
      inputStream.close();
    }
  }
View Full Code Here

Examples of javassist.ClassPool.makeClass()

    // 1.1] Create a class
   
    ClassPool pool = ClassPool.getDefault();
    // Class have to have no package name for the JPQL to work, not clear why, presumably I missed a mapping somewhere
    // but it doesn't matter because this class is internal to the process space anyway
    CtClass cc = pool.makeClass("TemplateClass" + nStep);
    cc.detach();
    // Remove all fields:
    for (CtField toRemove: cc.getFields()) {
      cc.removeField(toRemove);
    }
View Full Code Here

Examples of javassist.ClassPool.makeClass()

            Boolean[] xformRenameMethodOverlaps = null;
            if (!xformTemplates.isEmpty()) {
                if (xformTemplates.containsKey(xformKey)) {
                    xformVals = xformTemplates.get(xformKey).split(",");
                    classPool = ClassPool.getDefault();
                    clazz = classPool.makeClass(new ByteArrayInputStream(classfileBuffer), false);
                }
            } else {
                if (annotationTransformedClasses.contains(convertedClassName)) {
                    logger.warn(convertedClassName + " has already been transformed by a previous instance of DirectCopyTransfomer. " +
                            "Skipping this annotation based transformation. Generally, annotation-based transformation is handled " +
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.