OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | asm List | November 2008 Index

<--  Date Index  --> <--  Thread Index  -->

[asm] Re: Re: Class load via a classloader back to byte[] bytecode ?


Hello Eugene,

JavaSourceClassLoader, in the words of the author is :

"""A ClassLoader that, unlike usual ClassLoaders, does not load byte code, but reads JavaTM source code and then scans, parses, compiles and loads it into the virtual machine. """

http://www.janino.net/javadoc/index.html?org/codehaus/janino/JavaSourceClassLoader.html


I could obviously dig into the code, and try to modify it but that would mean I will need to maintain a fork of my own for Janino releases - Something I would not like to do.


The real question splits into 2 :
a. Does someone of the bytecode manipulation experts on this list knows how to inject Class objects into an existing Classloader - The parent of the current classloader.

b. Assuming (a.) isn't possible, which is not hard to believe (mainly due to security constraints). How (if at all possible) can I use asm to save a compiled class to on disk bytecode OR manipulate some object and then save the outcome to disk OR compile java code the same way as Janino does currently and then save it to disk. I guess you can find the pattern here which comes as a work around for not being able to fulfil requirement a.


Help is very much appreciated, both as an project requirement and as a personal interest to find out if/how this can be done.


Thank you for reading,
Maxim.

On Sat, Nov 22, 2008 at 9:59 AM, Eugene Kuleshov <eu@xxxxxxxxxx> wrote:

 What is JavaSourceClassLoader? If that thing creates some bytecode you probably should dig into its code and see if it allows to save generated classes to the file system.

 regards,
 Eugene



Maxim Veksler wrote:
Hello Everyone,

I'm looking for a solution that would allow me to write class object
back to it's bytecode from, which will be later saved to the FS.

The real motivation is to enable DynamicBeans, which get complied
during system runtime.

The process is:
1. Create dynamic java code which describes a Bean class.
2. Compile the class and load it using a classloader.

I'm currently using Janino's :
"""
               cl = new JavaSourceClassLoader(
                       this.getClass().getClassLoader(),  // parentClassLoader
                       pathFiles, // optionalSourcePath
                       "UTF8",                     // optionalCharacterEncoding
                       DebuggingInformation.ALL          // debuggingInformation
"""

My problem now comes to the issue of enabling the WebAppClassloader to
load these classes.

I've seen ASM has a ClassWriter object which seems to be able to
perform exactly what I'm after, but I'm failing to use it - Either
from a loaded class or directly from .java code.


Help is very much appreciated.
Maxim.
 




--
You receive this message as a subscriber of the asm@xxxxxxx mailing list.
To unsubscribe: mailto:asm-unsubscribe@xxxxxxx
For general help: mailto:sympa@xxxxxxx?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




--
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?


<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 2006-2007, OW2 Consortium | contact | webmaster.