You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-user@jakarta.apache.org by yugo_amaril <ga...@iit.cnr.it> on 2008/12/03 13:07:09 UTC
Class Copy
Hi. I'm using BCEL to create a copy of a given class. I'd like to have a
perfect copy, in the same package, but with a different name. I'm trying
with this code, but when I execute a program using the new class I always
have an Error:
pubic ClassGen copy(ClassGen clazz) {
JavaClass jClazz = clazz.getJavaClass().copy();
// creates a proxy class
jClazz.setClassName(jClazz.getClassName()+"_copy");
ConstantPoolGen cp = new ConstantPoolGen(jClazz.getConstantPool());
cp.setConstant(cp.lookupUtf8(jClazz.getFileName()), new
ConstantUtf8(wrapFileName(jClazz.getFileName())));
jClazz.setFileName(wrapFileName(jClazz.getFileName()));
ClassGen copy = new ClassGen(jClazz);
}
// and after i dump the class in the right file
where wrapFileName(String name) creates the correct file name (e.g.
"MyFile.java --> MyFile_copy.java")
The Error is:
Exception in thread "main" java.lang.NoClassDefFoundError: pkg/MyClass_copy
(wrong name: pkg/MyClass)
What's wrong?
Thanks in advance for any suggestion.
--
View this message in context: http://www.nabble.com/Class-Copy-tp20811743p20811743.html
Sent from the BCEL - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org
Re: Class Copy
Posted by yugo_amaril <ga...@iit.cnr.it>.
Torsten Curdt wrote:
>
> Much easier with ASM.
>
> see org.objectweb.asm.commons.Remapper
>
> cheers
> --
> Torsten
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: bcel-user-help@jakarta.apache.org
>
>
>
Probably, but I HAVE to use BCEL
--
View this message in context: http://www.nabble.com/Class-Copy-tp20811743p20814598.html
Sent from the BCEL - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org
Re: Class Copy
Posted by Torsten Curdt <tc...@apache.org>.
Much easier with ASM.
see org.objectweb.asm.commons.Remapper
cheers
--
Torsten
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org