Package javassist

Examples of javassist.ClassPool.makeClass()


                        return null;
                    }
                }
                if (isValidPattern) {
                    classPool = ClassPool.getDefault();
                    clazz = classPool.makeClass(new ByteArrayInputStream(classfileBuffer), false);
                    List<?> attributes = clazz.getClassFile().getAttributes();
                    Iterator<?> itr = attributes.iterator();
                    List<String> templates = new ArrayList<String>();
                    List<Boolean> skips = new ArrayList<Boolean>();
                    List<Boolean> renames = new ArrayList<Boolean>();
View Full Code Here


                    StringUtils.join(xformVals, ",")));
            CtClass clazz = null;
            try {
                // Load the destination class and defrost it so it is eligible for modifications
                ClassPool classPool = ClassPool.getDefault();
                clazz = classPool.makeClass(new ByteArrayInputStream(classfileBuffer), false);
                clazz.defrost();

                for (String xformVal : xformVals) {
                    // Load the source class
                    String trimmed = xformVal.trim();
View Full Code Here

                }
                Annotation inheritance = new Annotation(Inheritance.class.getName(), constantPool);
                ClassPool pool = ClassPool.getDefault();
                pool.importPackage("javax.persistence");
                pool.importPackage("java.lang");
                EnumMemberValue strategy = (EnumMemberValue) Annotation.createMemberValue(constantPool, pool.makeClass("InheritanceType"));
                strategy.setType(InheritanceType.class.getName());
                strategy.setValue(InheritanceType.SINGLE_TABLE.name());
                inheritance.addMemberValue("strategy", strategy);
                annotationsAttribute.addAnnotation(inheritance);
                if (myInfo.getDiscriminatorName() != null) {
View Full Code Here

                if (myInfo.getDiscriminatorName() != null) {
                    Annotation discriminator = new Annotation(DiscriminatorColumn.class.getName(), constantPool);
                    StringMemberValue name = new StringMemberValue(constantPool);
                    name.setValue(myInfo.getDiscriminatorName());
                    discriminator.addMemberValue("name", name);
                    EnumMemberValue discriminatorType = (EnumMemberValue) Annotation.createMemberValue(constantPool, pool.makeClass("DiscriminatorType"));
                    discriminatorType.setType(DiscriminatorType.class.getName());
                    discriminatorType.setValue(myInfo.getDiscriminatorType().name());
                    discriminator.addMemberValue("discriminatorType", discriminatorType);
                    IntegerMemberValue length = new IntegerMemberValue(constantPool);
                    length.setValue(myInfo.getDiscriminatorLength());
View Full Code Here

    if (pool.find(Enhancer.class.getName()) == null) {
      pool.appendClassPath(new LoaderClassPath(getClass().getClassLoader()));
    }
    try {
      // TODO extract this enhancement to an interface and test it appart
      CtClass newType =   pool.makeClass("br.com.caelum.restfulie." + originalType.getSimpleName() + "_" + System.currentTimeMillis());
      newType.setSuperclass(pool.get(originalType.getName()));
      newType.addInterface(pool.get(Resource.class.getName()));
//      enhanceMustIgnore(newType);
      enhanceLinks(newType);
      return newType.toClass();
View Full Code Here

            // get super class
            CtClass base = classPool.get(UDFunction.class.getName());

            // prepare class to generate
            CtClass cc = classPool.makeClass(GENERATED_CODE_PACKAGE + clsName, base);
            cc.setModifiers(cc.getModifiers() | Modifier.FINAL);

            // add c'tor plus methods (order matters)
            cc.addConstructor(CtNewConstructor.make(codeCtor, cc));
            cc.addMethod(CtNewMethod.make(codeExecInt, cc));
View Full Code Here

        ClassPool pool = new ClassPool(null);

        pool.appendSystemPath();
        pool.appendClassPath(classesDir.getAbsolutePath());

        CtClass ctClass = pool.makeClass(CLASS);

        ctClass.setSuperclass(pool.get(BASE_CLASS));

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

    {
        ClassPool pool = new ClassPool(null);

        pool.appendSystemPath();

        CtClass ctClass = pool.makeClass(className);

        ctClass.addInterface(pool.get(ReloadableService.class.getName()));

        CtMethod method = new CtMethod(pool.get("java.lang.String"), "getStatus", null, ctClass);
View Full Code Here

    {
        ClassPool pool = new ClassPool(null);

        pool.appendSystemPath();

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

    if (className.equals("org/stagemonitor/benchmark/profiler/ClassJavassistProfiled")) {

      try {
        ClassPool cp = ClassPool.getDefault();
        CtClass cc = cp.makeClass(new java.io.ByteArrayInputStream(classfileBuffer));
        for (CtMethod m : cc.getDeclaredMethods()) {
          m.insertBefore("org.stagemonitor.requestmonitor.profiler.Profiler.start();");
          m.insertAfter("org.stagemonitor.requestmonitor.profiler.Profiler.stop(\""+m.getLongName()+"\");", true);
        }
        byteCode = cc.toBytecode();
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.