[Prev] Thread [Next]  |  [Prev] Date [Next]

Class Copy yugo_amaril Wed Dec 03 05:00:23 2008

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
   ConstantPoolGen cp = new ConstantPoolGen(jClazz.getConstantPool());
   cp.setConstant(cp.lookupUtf8(jClazz.getFileName()), new
   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: 
Sent from the BCEL - User mailing list archive at Nabble.com.

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]