Summary:
Most developers think of the Java compiler,
javac
, as an unobtrusive command-line tool to invoke when you want to turn Java source code into class files. The Java Compiler API, JSR 199, released in final form last December, opens up the Java compiler to programmatic interaction as well. Artima spoke with JSR 199 spec lead and Sun engineer Peter von der Ahé about what programmatic compiler access means for developers.
The ability to add new comments in this discussion is temporarily disabled.
Most recent reply: April 6, 2007 7:38 PM by
Mark
|
In this interview, Peter von der Ahé explains how the JSR 199 Compiler API opens the Java compiler up to a new class of developer tools that know a lot more about the code being edited. What sorts of features would you like to see in IDEs that can be made possible by the Compiler API? http://www.artima.com/lejava/articles/compiler_api.html
|
|
|
I've just started working with the compiler API for an AB5k desklet. It's a lot more than I need, but looking at the API, it's clear that they've anticipated some pretty elaborate uses and provide a significant amount of flexibility for those who are able and willing to take advantage of it. I'm not terribly satisfied with the documentation, though -- creating a compilation task takes an "options" parameter that I have yet to find documentation of.
|
|
|
Could this API be used to create a dynamic extension to a running Java application, so that a module receives a block of code and generates a new class, which is then available to the running application? I'm thinking of an eval idea -- the ability to extend dynamically running Java applications. For example, by wrapping the above functionality, you could support something like Ruby's ability to dynamically extend a class -- a module could receive a class file and method code to be added (for example), combine them, and pass them to the API to parse and generate a new class. Then the newly created extended class is available in the same process.
|
|