Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: Run-time compilation

Reply
Thread Tools

Re: Run-time compilation

 
 
Stefan Ram
Guest
Posts: n/a
 
      11-10-2008
Jon Harrop <(E-Mail Removed)> writes:
>Are there any examples of run-time compilation from the Java
>language anywhere?


http://www.purl.org/stefan_ram/pub/e...ions-with-java

(I am using files there, which is not necessary,
it all could also have been compiled in memory.)

 
Reply With Quote
 
 
 
 
Mark Space
Guest
Posts: n/a
 
      11-11-2008
Jon Harrop wrote:

> I see there is also a ClassLoader. Is there an API to generate classes
> directly, i.e. without going through Java source code as text?
>


I haven't tried any of these libraries myself, but is this along the
lines of what you're looking for?

<http://java-source.net/open-source/bytecode-libraries>
 
Reply With Quote
 
 
 
 
Stefan Ram
Guest
Posts: n/a
 
      11-11-2008
Jon Harrop <(E-Mail Removed)> writes:
>I see there is also a ClassLoader. Is there an API to generate classes
>directly, i.e. without going through Java source code as text?


The class file format is being described in

http://java.sun.com/docs/books/jvms/...sFile.doc.html

. Well-known tools to generate this include BCEL and ASM.

 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      11-11-2008
Jon Harrop wrote:
> Stefan Ram wrote:
>
>> Jon Harrop <(E-Mail Removed)> writes:
>>> Are there any examples of run-time compilation from the Java
>>> language anywhere?

>> http://www.purl.org/stefan_ram/pub/e...ions-with-java
>>
>> (I am using files there, which is not necessary,
>> it all could also have been compiled in memory.)

>
> Ok, so you're generating Java source code in a file and then invoking the
> Java compiler using the new API.
>
> I see there is also a ClassLoader. Is there an API to generate classes
> directly, i.e. without going through Java source code as text?


The class file format is documented in the Java Virtual
Machine Specification. Before friendlier tools came on the
scene, I used that documentation to write a compiler that
turned a String like "cos(x) * sin(y)" into an object of a
freshly-loaded class with an evaluate() method that performed
the calculation. So I can testify that the task is do-able.
A bit tedious, but do-able. (The fact that evaluate() would
always be straight-line code without branches, try blocks,
loops, and so on helped minimize the tedium; there were big
chunks of the class file format I could simply ignore.)

--
Eric Sosman
http://www.velocityreviews.com/forums/(E-Mail Removed)lid
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compilation error with seperate compilation C__chp C++ 4 02-15-2008 03:57 PM
Preprocessor conditional compilation variable not being saved Chris P ASP .Net 0 10-28-2003 08:48 PM
compilation error with ModelSim Vincent VHDL 3 09-17-2003 01:30 AM
Compilation error YesMann VHDL 2 08-08-2003 12:51 PM
Re: Compilation error reason??? Weng Tianxiang VHDL 1 07-24-2003 03:08 PM



Advertisments