aspose file tools*
The moose likes Java in General and the fly likes Can I create a Class object without VM/Native? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Can I create a Class object without VM/Native?" Watch "Can I create a Class object without VM/Native?" New topic
Author

Can I create a Class object without VM/Native?

Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
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 ]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I create a Class object without VM/Native?