cujojs/meld

[mozart & meld]

Closed this issue · 5 comments

Hi,
I started a study of the framework nodejs and I found the following modules on the site https://www.npmjs.com :

I coded a HelloWorld sample in which I used :

  • mozart to build class with public,protected and private features.
  • meld to instrument with AOP my source code
  • log4js to log several informations for the previous instrumentation

I can intrument and log the public and protected functions.
But, I can't instrument private functions.

Thank you in advance for your help to understand this problem and solve it.

Best regards,

Franck

Hey @franck-serot!

Many AOP tools that work in compiled languages, such as Java, apply advice via byte-code manipulation or other compile-time mechanisms. However, JavaScript is not a compiled language. Therefore, meld.js can't do this. Instead, meld.js applies advice at run time via function replacement.

Since JavaScript VMs disallow access to "private" functions at run-time, there is no way to advise these functions with meld.js.

It might be possible to apply advice to JavaScript functions, including private ones, via source code transformation. I am unaware of any JavaScript AOP libraries that do this, but I haven't looked, either. :)

Have you investigated source code transformation options?

-- John

Hey,
I haven't investigated source code transformation options of meld.js.
Could you please give me information about 'source code transformation options of meld.js' ?
BR
Franck

Hi @franck-serot. Sorry if there was confusion, but meld.js does not support source code or AST transformation.

Source code and AST transformations for AOP would be very interesting to explore, but we haven't had the time. If you find a tool that supports it, please let us know!

Hi,
I find the solution of my problem.
In fact, it's a bad use of mozart module because the private functions are only instrumented for the current class by comparaison with the public or protected functions that could be instrumented in the mother class.
BR
Franck

@franck-serot Cool, glad you found a solution. Closing this issue, but feel free to reopen if you feel there's more to discuss.