[DiSL-user] AspectJ in-memory weaving question problem in DiSL

Lukas Marek lukas.marek at d3s.mff.cuni.cz
Sat Jul 23 12:55:43 CEST 2016


Hi Piotr,

I'm no longer active on the project but I will try to answer your 
question with the knowledge I have. I've forwarded this answer to the 
DiSL mailing list - DiSL guys will correct me if I'm wrong.

I'm not sure if I understand your problem correctly, but DiSL is a 
framework mainly used for dynamic analysis. It was never designed to 
perform structural changes of classes like adding new fields, methods or 
interfaces.

As DiSL does not perform structural changes, most changes are not 
visible to AspecJ. However, if you use multiple instrumentation 
frameworks atop of each other, you may encounter some unwanted side effects.

If you want to modify classes of already running application, I would 
suggest that you use ASM (http://asm.ow2.org/) or some other bytecode 
manipulation library together with one of the instrumentation interfaces 
inside JVM:

  - JVMTI 
(https://docs.oracle.com/javase/8/docs/technotes/guides/jvmti/) - 
interface on JVM level using C language, but flexible

  - Java instrumentation interface 
(https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/package-summary.html) 
- Java interface with some limitations, but may be enough for your use case

Maybe even Byte Buddy contains the functionality you need:
http://stackoverflow.com/a/25822122

Best Regards,
Lukas Marek

On 07/19/2016 11:12 PM, pzabawa at pk.edu.pl wrote:
> Hi,
> I would like to inject a Java interface which is generated at run-time
> (through Byte Buddy) into a java class which is defined at compile-time.
> The interface can be loaded from my framework via Byte Buddy to JVM or can
> be availabe in the form of the bytecode byte array in memory or can be
> dumped to a *.class file (the inefficient and inacceptable option). How
> can I point this interface in any of the locations mentioned above from
> declare parents construct from the level of AspectJ only and from the
> level of Spring+AspectJ (not Spring AOP) in Spring application context XML
> file?
>
> Is it possible to make use of DiSL to solve the problem described above?
> Is your solution applicable to inter-type declaration?
>
> Thank you in advance
> Piotr Zabawa
>
>





More information about the Disl-user mailing list