JBoss Community

Re: Can I delete the modifier of a method with Javassist?

created by Nils Andreas Svee in Javassist - View the full discussion

I would have done something like this:

 

{code}

ClassPool pool = ClassPool.getDefault();

CtClass cc = pool.get("ClsSync");

 

CtMethod m = cc.getDeclaredMethod("biat");

int oldMod = m.getModifiers();

int mod = Modifier.clear(oldMod, Modifier.SYNCHRONIZED);

m.setModifiers(mod);

 

Class newClass = cc.toClass(); // or cc.writeFile() if you wish to keep the changes

{/code}

Reply to this message by going to Community

Start a new discussion in Javassist at Community