Package javassist

Examples of javassist.CtClass.toClass()


            logger.error(e.getMessage(), "Compiled body is:\n" + methodBody.toString());
            throw Throwables.propagate(e);
        }

        try {
            return (CopyExtractor<E>) cc.toClass().newInstance();
        } catch (InstantiationException | IllegalAccessException | CannotCompileException e) {
            throw Throwables.propagate(e);
        }
    }
View Full Code Here


        ctor.setBody("{super();}");
        javassistClass.addConstructor(ctor);

        long javassistSerialVerUid = JavassistHelper.calculateSerialVerUid(javassistClass);

        Class javaClassGenerated = javassistClass.toClass();
        long javaSerialVerUid = ObjectStreamClass.lookup(javaClassGenerated).getSerialVersionUID();

        assertEquals(javaSerialVerUid, javassistSerialVerUid);

    }
View Full Code Here

      wrapper.addMethod(getter);
      wrapper.addMethod(setter);
      _addMethodsForValueType(wrapper, valueType, valueType.isPrimitive());
     
      @SuppressWarnings("unchecked")
      Class<_KeyBinding> wrapperClass = wrapper.toClass(classLoader, getClass().getProtectionDomain());
      _KeyBinding binding = wrapperClass.newInstance();
      return binding;
    } catch (NotFoundException e) {
      return null;
    } catch (Exception e) {
View Full Code Here

     
      wrapper.addMethod(getter);
      _addMethodsForValueType(wrapper, valueType, false);

      @SuppressWarnings("unchecked")
      Class<_KeyBinding> wrapperClass = wrapper.toClass(classLoader, getClass().getProtectionDomain());
      _KeyBinding binding = wrapperClass.newInstance();
      return binding;
    } catch (NotFoundException e) {
      return null;
    } catch (Exception e) {
View Full Code Here

      wrapper.addMethod(setter);
      _addMethodsForValueType(wrapper, valueType, valueType.isPrimitive());
     
      @SuppressWarnings("unchecked")
      Class<_KeyBinding> wrapperClass = wrapper.toClass(classLoader, getClass().getProtectionDomain());
      _KeyBinding binding = wrapperClass.newInstance();
      return binding;
    } catch (NotFoundException e) {
      return null;
    } catch (Exception e) {
View Full Code Here

    cc.addConstructor(constructor);
   
    cc.addMethod(CtMethod.make("public Method method(){return method;}", cc));
    cc.addMethod(CtMethod.make(createInvokeMethodCode(method), cc));
   
    MethodProxy ret = (MethodProxy) cc.toClass().getConstructor(Method.class).newInstance(method);
//    long end = System.currentTimeMillis();
//    System.out.println("Javassist generates class proxy time -> " + (end - start));
    return ret;
  }
View Full Code Here

   
    cc.addMethod(CtMethod.make("public Field field(){return field;}", cc));
    cc.addMethod(CtMethod.make(createFieldGetterMethodCode(field), cc));
    cc.addMethod(CtMethod.make(createFieldSetterMethodCode(field), cc));
   
    FieldProxy ret = (FieldProxy) cc.toClass().getConstructor(Field.class).newInstance(field);
//    long end = System.currentTimeMillis();
//    System.out.println("Javassist generates class proxy time -> " + (end - start));
    return ret;
  }
View Full Code Here

   
    cc.addMethod(CtMethod.make(createArraySizeCode(clazz), cc));
    cc.addMethod(CtMethod.make(createArrayGetCode(clazz), cc));
    cc.addMethod(CtMethod.make(createArraySetCode(clazz), cc));
   
    ArrayProxy ret = (ArrayProxy) cc.toClass().getConstructor().newInstance();
//    long end = System.currentTimeMillis();
//    System.out.println("Javassist generates class proxy time -> " + (end - start));
    return ret;
  }
 
View Full Code Here

                } else {
                    cls.addMethod(CtNewMethod.make("public " + method, cls));
                }
            }
        }
        return cls.toClass(ClassHelper.getCallerClassLoader(getClass()), JavassistCompiler.class.getProtectionDomain());
    }

}
View Full Code Here

            logger.error(e.getMessage(), "Compiled body is:\n" + methodBody.toString());
            throw Throwables.propagate(e);
        }

        try {
            return (CopyExtractor<E>) cc.toClass().newInstance();
        } catch (InstantiationException | IllegalAccessException | CannotCompileException e) {
            throw Throwables.propagate(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.