anonymous wrote : 1. Methods such as getMethods, getMethod, getClassInitializer are not implemented functionable in CtClass. Are we expecting them to be implemented soon?
CtClass is an abstract class! Those methods have been implemented in CtClassType. The implementation in CtClass is mainly for primitive types. anonymous wrote : 2. In FieldAccess class, why isn't there a getOpcode() function? Do you want to know which the opcode is, getstatic, getfield, putstatic, or putfield? If yes, you can instead use FieldAccess#isStatic(), #isReader(), #isWriter(). anonymous wrote : However, this does not work anymore as the static method ClassPool.GetDefault() does not take Translator as parameter anymore in javassist 3. Yes, the article http://www-106.ibm.com/developerworks/java/library/j-dyn0302.html depends on 2.6. I showed a modified version of Listing 3 in the article above: | public class Dissect | { | public static void main(String[] args) { | if (args.length >= 1) { | try { | // set up class loader with translator | Translator xlat = new DissectionTranslator(); | ClassPool pool = ClassPool.getDefault(); | Loader loader = new Loader(); | loader.addTranslator(pool, xlat); | | // invoke the "main" method of the application class | String[] pargs = new String[args.length-1]; | System.arraycopy(args, 1, pargs, 0, pargs.length); | loader.run(args[0], pargs); | } catch (Throwable ex) { | ex.printStackTrace(); | } | } else { | System.out.println | ("Usage: Dissect main-class args..."); | } | } | | public static class DissectionTranslator implements Translator | { | public void start(ClassPool pool) {} | public void onLoad(ClassPool pool, String cname) | throws NotFoundException, CannotCompileException { | System.out.println("Dissecting class " + cname); | CtClass clas = pool.get(cname); | clas.instrument(new VerboseEditor()); | } | } In 3.0, Translator must be passed to Loader instead of ClassPool. Translator#onWrite() was renamed into #onLoad because of this move. This is for clarifying the role of ClassPool (and also to make Javassist work better with JBoss AOP. :p) View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3852236#3852236 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3852236 ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user