1

javassist の検索パスに jar ファイルを追加して正しく動作させるにはどうすればよいですか? unjar してから rejar せずに jar ファイルを変更しようとしています。

import javassist.*;

class Injector
{

  public static void main(String[] argv) throws Exception
  {
    // Load the class representation
    ClassPool pool = ClassPool.getDefault();
    pool.insertClassPath( "myjarfile.jar" ); 
    CtClass cc = pool.get("org.mine.Myclass"); ////////// Not reading Myclass from myjarfile.jar


    // Find the method we want to patch and rename it 
    // (we will be creating a new method with the original name).
    CtMethod m_old = cc.getDeclaredMethod("methodToRename");
    // m_old.setName( "methodToRename" );

    cc.removeMethod( m_old );


  }
}
4

1 に答える 1

5

簡単に解決しました:

pool.insertClassPath( "/Path/from/root/myjarfile.jar" );
于 2013-05-25T04:24:23.967 に答える