Package javassist

Examples of javassist.CtClass.writeFile()


                ctClass);
        ctClass.addMethod(method);

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

        ctClass.writeFile(_extraClasspath.getAbsolutePath());
    }

    private Component createComponent(Class componentClass)
    {
        String classname = componentClass.getName();
View Full Code Here


        method.setBody("return " + number + ";");

        ctClass.addMethod(method);

        ctClass.writeFile(classesDir.getAbsolutePath());
    }

    /**
     * Copies a source file (from the classpath) to a directory as a new file name.
     *
 
View Full Code Here

        CtMethod method = CtNewMethod.make("public String getName() { return \"" + name + "\"; }", ctClass);
        ctClass.addMethod(method);

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

        ctClass.writeFile(extraClasspath.getAbsolutePath());
    }

    private Component createComponent(Class componentClass)
    {
        String classname = componentClass.getName();
View Full Code Here

        CtClass ctClass = pool.makeClass(CLASS);

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

        ctClass.writeFile(classesDir.getAbsolutePath());

        Registry registry = createRegistry();

        ReloadableService reloadable = registry.getService(ReloadableService.class);
View Full Code Here

        method.setBody(String.format("return \"%s\";", status));

        ctClass.addMethod(method);

        ctClass.writeFile(classesDir.getAbsolutePath());
    }

    private void createInvalidImplentationClass() throws Exception
    {
        ClassPool pool = new ClassPool(null);
View Full Code Here

        constructor.setModifiers(Modifier.PROTECTED);

        ctClass.addConstructor(constructor);

        ctClass.writeFile(classesDir.getAbsolutePath());
    }

    @Test
    public void eager_load_service_with_proxy()
    {
View Full Code Here

         CtClass clazz = instrumentClass(className);
         if (path != null && clazz.isModified())
         {
            try
            {
               clazz.writeFile(path);
            }
            catch (IOException e)
            {
               throw new RuntimeException(e);
            }
View Full Code Here

                ctClass);
        ctClass.addMethod(method);

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

        ctClass.writeFile(_extraClasspath.getAbsolutePath());
    }

    private Component createComponent(Class componentClass)
    {
        String classname = componentClass.getName();
View Full Code Here

        else {
            for (int i = 0; i < args.length; i++) {
                CtClass cc = ClassPool.getDefault().get(getClassName(args[i]));
                System.out.println(cc.getName());
                rebuildStackMaps2(cc);
                cc.writeFile("rebuild");
            }
        }
    }

    public static String getClassName(String fileName) {
View Full Code Here

    public void testRebuild() throws Exception {
        CtClass cc = loader.get("javassist.bytecode.StackMapTest$T1");
        rebuildStackMaps2(cc);
        //Class c = cc.toClass();
        //Object t1 = c.newInstance();
        cc.writeFile();
        Object t1 = make(cc.getName());
        assertEquals(3, invoke(t1, "test"));
    }

    public static interface Intf {
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.