• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

in-memory compile of java source to bytecode

 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Is it possible, using existing utilities, to generate bytecode from java source at run-time without actually writing any .java or .class files to the filesystem?

Thank you,
Yuriy
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's possible. The Javassist library can do this.
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm just guessing, but cglib might be able to do that: http://cglib.sourceforge.net/
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your replies!

Jeff, can cglib generate classes from java source? I couldn't find a way to do that.

Ulf, I noticed that the JavaAssist library allows the creation of methods from source codes, but can it create an entire class given the contents of a .java file? We're thinking of using a java source generator like Axis' WSDL2Java to generate java source code, but in memory instead of on the file system. Then we would compile the source into a bytecode, again in memory. That way we could created classes at runtime without touching the filesystem. We would prefer to compile the class sources whole, without parsing for bits and pieces to add to a new class definition.

Thank you,
Yuriy
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic