コード例 #1
0
ファイル: JvstTest2.java プロジェクト: romix/javassist
 // not used anymore.
 private void notTestGetInner() throws Exception {
   ClassPool pool = ClassPool.getDefault();
   CtClass c = pool.get("javassist.CtMethod.ConstParameter");
   CtClass d = pool.get("javassist.CtMethod.ConstParameter");
   CtClass e = pool.get("javassist.CtMethod$ConstParameter");
   assertSame(c, d);
   assertSame(c, e);
   try {
     c = pool.get("test2.Inner.Fake");
     fail("found not-existing class");
   } catch (NotFoundException ex) {
   }
 }
コード例 #2
0
ファイル: JvstTest2.java プロジェクト: romix/javassist
  public void testInheritance() throws Exception {
    ClassPool pool = ClassPool.getDefault();
    String classname = "test2.Inherit";
    CtClass target = pool.get(classname);
    String src =
        "public void sampleMethod() {"
            + "  test2.Inherit i = new test2.Inherit();"
            + "  test2.Inherit2 i2 = i;"
            + "  test2.Inherit3 i3 = i;"
            + "  i3.foo2(); i3.foo2(); i2.foo1(); }";

    CtMethod newmethod = CtNewMethod.make(src, target);
    target.addMethod(newmethod);
    target.writeFile();
  }
コード例 #3
0
ファイル: JvstTest2.java プロジェクト: romix/javassist
  public void testInner() throws Exception {
    ClassPool pool = ClassPool.getDefault();
    String classname = "test2.Inner";
    CtClass target = pool.get(classname);
    String src =
        "public void sampleMethod() throws Exception {"
            + "java.util.Properties props = new java.util.Properties();"
            + "java.rmi.activation.ActivationGroupDesc.CommandEnvironment ace "
            + " = null;"
            + "java.rmi.activation.ActivationGroupDesc agd "
            + " = new java.rmi.activation.ActivationGroupDesc(props,ace);}";
    CtMethod newmethod = CtNewMethod.make(src, target);
    target.addMethod(newmethod);

    String src2 =
        "public java.lang.Character.Subset sampleMethod2() {"
            + "  java.lang.Character.Subset s "
            + "    = Character.UnicodeBlock.HIRAGANA; "
            + "  return s; }";
    CtMethod newmethod2 = CtNewMethod.make(src2, target);
    target.addMethod(newmethod2);

    target.writeFile();
  }
コード例 #4
0
ファイル: JvstTest2.java プロジェクト: romix/javassist
 public void testToClass() throws Exception {
   ClassPool cp = ClassPool.getDefault();
   CtClass cc = cp.makeClass("test2.ToClassTest");
   Class c = cc.toClass();
   assertEquals(getClass().getClassLoader(), c.getClassLoader());
 }