Package javassist

Examples of javassist.CtClass.writeFile()


        CtClass cc = loader.get("javassist.bytecode.StackMapTest$C4");
        MethodInfo mi = cc.getDeclaredMethod("foo").getMethodInfo();
        mi.rebuildStackMapForME(loader);
        CodeIterator ci = mi.getCodeAttribute().iterator();
        ci.insertGap(0, 7);
        cc.writeFile();
        Object t1 = make(cc.getName());
        assertEquals(6, invoke(t1, "test"));
    }

    public static class C4 {
View Full Code Here


                    return;

                f.replace("{ $_ = $proceed($$); if (false) return $_;}");
            }
        });
        cc.writeFile();
        Object t1 = make(cc.getName());
        assertEquals(3, invoke(t1, "test"));
    }

    public static class C5 {
View Full Code Here

                // this will make a 1-byte dead code.
                f.replace("{ $_ = $proceed($$); return $_;}");
            }
        });
        cc.writeFile();
    }

    public static class C6 {
        String value;
        int ivalue;
View Full Code Here

        cc.addConstructor(CtNewConstructor.make("public StackMapTestJsrTest() {}", cc));
        cc.addMethod(CtMethod.make("public static void main(String[] args) {"
                                 + "new javassist.bytecode.StackMapTestJsrTest().test();"
                                 + "}",
                                   cc));
        cc.writeFile();
        Object t1 = make(cc.getName());
        assertEquals(3, invoke(t1, "test"));
    }

    public void tstCtClassType() throws Exception {
View Full Code Here

            public void edit(MethodCall c) throws CannotCompileException {
                c.replace("try{ $_ = $proceed($$); } catch (Throwable t) { throw t; }");
            }
        });
        mth.getMethodInfo().rebuildStackMap(ClassPool.getDefault());
        cc.writeFile();
    }

    public static void main(String[] args) throws Exception {
        new Jassist150().testJIRA152();
    }
View Full Code Here

        CtClass clazz = loadClassFile(pool, file);

        if (transformation.shouldTransform(clazz)) {
          clazz.defrost();
          transformation.applyTransformations(clazz);
          clazz.writeFile(this.destinationDir.toString());
        }
      }
    } catch (Exception e) {
      throw new GradleException("An error occurred while trying to process class file ", e);
    }
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

                        ctField.getFieldInfo().addAttribute(annotAttr);
                    }
                }

                ctClass.writeFile(args[0]);
            }
        }
    }
}
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.