• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I create a Class object without VM/Native?

 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic