[antlr-interest] Dynamic Java compiler?

Jon Schewe jpschewe at mtu.net
Mon Apr 25 11:37:59 PDT 2005


On Sun, 2005-04-24 at 21:05 -0700, Terence Parr wrote:
> On Apr 24, 2005, at 6:33 PM, Jon Schewe wrote:
> 
> > On Sun, 2005-04-24 at 13:56 -0700, Terence Parr wrote:
> >> <antlr-interest at antlr.org>
> >> You can generate .class files with javac and then ask the classloader
> >> to load them.  Or, use com.sun.compiler.* or whatever it is to do
> >> inline.  See any servlet/jsp engine for the sample code I think.
> >
> > Unfortunately that requires the source for all of the files to be on 
> > the
> > filesystem when the compiler runs.  This is possible in a JSP engine
> > because it's static, not dynamic code.  However this is not the case in
> > my application, as I'm generating the source on the fly as the
> > classloader requests the classes.
> 
> Can you write to a file?  JSPs change on the fly so they must be 
> reloaded throwing out the old .class file.  :)
> 
Sure, but I don't know all of the dependencies ahead of time, so the
compile will fail and I'll have to parse the error messages to figure
out which class, then generate that and continue.  If the compiler used
a ClassLoader, like DynamicJava or Groovy do, then instead of looking
for the source on the filesystem the compiler would just ask the
ClassLoader for the Class and I can then generate the source and push it
back through the dynamic compiler.


________________________________________________________________________

Jon Schewe | http://mtu.net/~jpschewe
GPG signature at http://mtu.net/~jpschewe/gpg.sig.html
For I am convinced that neither death nor life, neither angels
nor demons, neither the present nor the future, nor any
powers, neither height nor depth, nor anything else in all
creation, will be able to separate us from the love of God that
is in Christ Jesus our Lord. - Romans 8:38-39





More information about the antlr-interest mailing list