I'm using BCEL and am wondering if there's a way to create a Class object straight from the byte-code. I generate byte-code of a class using BCEL (byte-code engineering language) but I can't call defineClass because it's already been called, but i want to pass a class object back. Is this possible? What about if I serialize a Class object to a file, can I byte-code engineer that and then reinstantiate it? [ February 13, 2003: Message edited by: Robert Paris ]
posted 12 years ago
Evein if you serialize an object of a Class, you are only getting the state of the object. The JVM will still look to load the class from a .class file. If you try to grab the byte codes of a class after it is loaded into memory, even if you got it copied back into memory later it would not be registered with a classloader. Course I know nothing about BCEL - so maybe they have some magic cooked up that I have never heard of .
"JavaRanch, where the deer and the Certified play" - David O'Meara