Introduction | Learning More |
Sample Code | Links |
Limitations |
Creating Java byte code while a program is running either by using javac.exe or the deprecated undocumented sun.com.javac.Main or JavaCompiler, or by composing the byte code directly.
You might use the technique for example to compose customised byte code for a particular spreadsheet or regex then let Hotspot turn it into native code, rather than using in interpretive spreadsheet or regex engine that Hotspot has turned into native code. The advantage is speed.
Beware! The following example uses an undocumented, deprecated technique calling com.sun.tools.javac.Main. Normally you would use javax.tools.JavaCompiler
Here is what the dynamically generated Hypotenuse class looks like:One additional problem with this technique is you need com.sun.tools.javac.Main which lives in tools.jar which is not traditionally on the classpath.
This page is posted |
http://mindprod.com/jgloss/onthefly.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\onthefly.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[18.217.98.175] |
| |
Feedback |
You are visitor number | |