Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Dynamically modifying Java class structure

Why is it impossible?

Many years ago before I knew about AJ, I created a program that writes a Java program, invokes the compiler, then uses reflection to load the created program. Couldn't he do something similar and use AJ to simplify the modification process? Admittedly, he might need to start a child ClassLoader and unload the whole thing if he needs to load, unload, modify, and reload; however, he shouldn't even need to do that if he only needs to load the modified version once per program execution.

The only special thing I see is that he'll need access to javac, AJ, BCEL, or whatever other tool he chooses to accomplish the modification.


On Oct 16, 2007, at 11:55 PM, Eric Bodden wrote:

Hi, Hendrik. What do you mean by "dynamically"? Do you mean "at
runtime"? If so, that's impossible to do...

Eric

On 16/10/2007, Hendrik Gani <s2116865@xxxxxxxxxxxxxxxxxxx> wrote:
Hi,

I am not sure whether the mailing list is an appropriate place to ask
the following questions, but I could not find the relevant newsgroup for
aspectj users (only found AJDT newsgroup),

I am trying to develop a solution to automatically insert new
constructors to existing classes. I've considered using AspectJ to do
it, however as far as I know it will only work if the name of the class to be modified was known beforehand (has to be hardcoded in the aspect),
which is not applicable in my case.

So, could anyone please give me some suggestions or recommendations on
this? Especially in terms of the following:
- Is Aspectj the best tool to do this? If so, how to do it without
hardcoding class names?
- Should I look at bytecode reengineering/manipulation tools instead? If so, what's the most suitable library for my case (since I am aware that
there are a lot of choices out there when it comes to bytecode
manipulation)?

Thanks a lot for any helps, suggestions, and ideas.

Regards,

Hendrik
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



--
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top