This is exactly what DynaBeans were invented for.

Using BCEL to generate classes on the fly is impressive, but wouldn't it be
simpler to just use the DynaBeans, which I believe are in 1.1?

Niall

> -----Original Message-----
> From: Thorbjørn Ravn Andersen (Scandiatransplant)
> [mailto:[EMAIL PROTECTED]]
> Sent: 15 April 2002 16:15
> To: Struts Users Mailing List
> Subject: Creating beans dynamically from byte code in a byte[]
> withClassLoader.defineClass - how to do it right?
>
>
>
> I have spent some time lately figuring out how I can generate beans
> on-the-fly with fields completely specified at run-time, since this would
> be an enourmeous help when working with JDBC and Struts in an informal
> matter (which is why I ask here :-)
>
> I have used Apache Jakarta BCEL to construct the byte-code I need for the
> bean (verified by dumping it to disk, and using "java" and 'javap -c' on
> the class file), and I would then like to get the SystemClassLoader and
> call defineClass on my byte array to get a Class, and then resolve it.
>
> Unfortunately I cannot do this, since the defineClass method is protected
> final, so I am a bit at a loss here.  I just need some code which can
> instantiate my byte code into a Class, so I can get this working.   I
> would prefer not to use physical files, but I have a JSP-environment so
> that might be an option.  (Resin+Tomcat).
>
> Is there somebody who have a solution for this problem?  I would
> appreciate all pointers.
>
> --
>   Thorbjørn Ravn Andersen
>   Scandiatransplant, c/o Christian Mondrup
>   89 49 53 01
>   http://biobase.dk/~tra
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to