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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]