Package javassist

Examples of javassist.ClassPool.makeClass()


        try {
            CtClass iface = classPool.get(messagesClass.getName());
            CtClass messageFormat = classPool.get(MessageFormat.class.getName());
            CtClass stringClass = classPool.get(String.class.getName());
            CtClass localeClass = classPool.get(Locale.class.getName());
            CtClass impl = classPool.makeClass(ifaceName+"Impl_"+locale.toString());
            impl.addInterface(iface);
           
            KeyGenerator keyGenerator = new MethodNameKeyGenerator();
            for(Object ann : iface.getAnnotations()) {
                if(ann instanceof GenerateKeys) {
View Full Code Here


        final ClassPool classPool = getClassPool();
        try {
            CtClass iface = classPool.get(constantsClass.getName());
            CtClass baseConstantsImpl = classPool.get(BaseConstantsImpl.class.getName());
            CtClass stringClass = classPool.get(String.class.getName());
            CtClass impl = classPool.makeClass(ifaceName+"Impl_"+locale.toString(), baseConstantsImpl);
            impl.addInterface(iface);
            final CtClass resourceBundle = classPool.get(ResourceBundle.class.getName());
            CtField resField = new CtField(resourceBundle, "res", impl);
            impl.addField(resField);
           
View Full Code Here

     * @return Create a class to generate the copy row strings.
     */
    @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_" + extractorNameSuffix.incrementAndGet());

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

    * @throws Throwable for any error
    */
   public JavassistMethod createMethod(CtMethod ctMethod) throws Throwable
   {
      ClassPool pool = JavassistTypeInfoFactoryImpl.pool;
      final CtClass result = pool.makeClass(JavassistMethod.class.getName() + counter.incrementAndGet());
      /* TODO JBMICROCONT-133 figure out how to do this on all JDKs
      try
      {
         CtClass magic = pool.get("sun.reflect.MagicAccessorImpl");
         result.setSuperclass(magic);
View Full Code Here

    * @throws Throwable for any error
    */
   public JavassistConstructor createConstructor(CtConstructor ctConstructor) throws Throwable
   {
      ClassPool pool = JavassistTypeInfoFactoryImpl.pool;
      final CtClass result = pool.makeClass(JavassistConstructor.class.getName() + counter.incrementAndGet());
      try
      {
         CtClass magic = pool.get("sun.reflect.MagicAccessorImpl");
         result.setSuperclass(magic);
      }
View Full Code Here

    * @throws Throwable for any error
    */
   public JavassistField createField(CtField ctField) throws Throwable
   {
      ClassPool pool = JavassistTypeInfoFactoryImpl.pool;
      final CtClass result = pool.makeClass(JavassistField.class.getName() + counter.incrementAndGet());
      try
      {
         CtClass magic = pool.get("sun.reflect.MagicAccessorImpl");
         result.setSuperclass(magic);
      }
View Full Code Here

     * @return Create a class to generate the copy row strings.
     */
    @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

     * @return Create a class to generate the copy row strings.
     */
    @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_" + extractorNameSuffix.incrementAndGet());

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

            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

  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

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.