If you haven't seen it already, there's an article on the Swing
Connection on creating dynamic event listeners or some such which seems to
have been the basis for the Dynamic Proxy support in JDK 1.3.  It has
source code for generating classes on the fly that implement arbitrary
interfaces, including some generic routines for writing useful bits of
bytecode.  If your goals are limited enough in scope, you may want to skip
the source code and just spew out bytecode directly based on the XML file
you're reading.
        Also, I have JDK 1.2 implementation of Dynamic Proxies that you're
welcome to look at, based on the aforementioned article.

Aaron

On Thu, 4 Oct 2001, Deacon Marcus wrote:
> Hi,
>
> > From: Dmitri Colebatch [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, October 04, 2001 2:35 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [half-off-topic] Java Compilers
> >
> >
> > Hi,
> >
> > On Thu, 4 Oct 2001, Deacon Marcus wrote:
> >
> > > There would be two classes, CompileUnit and CompileContext.
> > > First, you create a CompileContext, initialize it with working dir and
> > > classpath, then you create CompileUnit, initialize it with
> > CompileContext
> > > and a .java file. Then, you can call .prepare() or .compile()
> > to compile the
> > > file, and .newInstance() to create an instance or .getClass()
> > to get Class.
> > > Or you could use Class.forName(), since in most cases CompileContext's
> > > classpath would be active classpath.
> > so you're talking about generating java source code, and compiling it on
> > the fly?
>
> Exactly.
> I'm coding it right now - looks like CompileContext is enough - I'll post
> when I finish of course.
>
> > > I'm sure you see the similarity to .JSP now.
> > if my interpretation is correct, yes (o:
> >
> > > While it may seem basic, having API for this wouldn't hurt.
> > > Possible scenario:
> > > Supponse, there's some kind of mail server with *extremely* complicated
> > > rule-set in form of 200kb+ xml. Why not take it, convert it into .java
> > > implementing some interface, convert it to java source with
> > hundreds if not
> > > more ifs and cases, and load it as compiled code.
> > > What I need: since JDK 1.4b2, tools.jar just isn't what it used
> > to be... so
> > > I need some kind of 100% java java compiler. And, I have no
> > idea where to
> > > search for one. Of course, there's dozens, but it must be both
> > stable and
> > > compatible with JDK 1.1 - 1.4.
> > Short of searching google, which I'm sure you're already doing I cant help
> > you there.  What I can suggest though, is for source code generation, a
> > project called Jenesis (http://www.inxar.org) which provides a nice API
> > based on the Java Language spec.
>
> Generating source is out of scope of this project.
> I need it mainly for the complicated configs etc - no point in generating
> structure out of xml which is then analyzed everytime when you can compile
> it into bytecode. I'm sure it's possible to do xml-config to java-source
> transformation in xsl, but I don't like it personally, so I'll leave it to
> someone else.
>
> > cheers
> > dim
>
> Greetings, deacon Marcus
> ~~~~~
> HELP STARVING JAVA PROGRAMMER: If you need cheap and reliable JSP hosting,
> please contact [EMAIL PROTECTED] (from 12$/m for 50mb WWW + 20mb mail)
>

Reply via email to