Helma Logo
main list history
previous version  overview  next version

Version 4 by hannes on 15. January 2008, 12:27

This is a comparison of *JSAdapter|http://blogs.sun.com/sundararajan/entry/self_javascript_and_jsadapter* and *JOMP|http://www.bias2build.com/thesis/javascript_mop_expanded.html*, two approaches to add metaprogramming features to Rhino.

=== JSAdapter

* Inheritance not as easyeasy as with plain JS objects. Normal use needs wrapped object, but for prototype use in inheritance chain we need unwrapped adaptee object,. so As a result we need two constructorsseparate constructors/factory methods for the wrapped and unwrapped object, or wrap the object manually. 
* getDefaultValue is forwarded to the adaptee object, so a toString() that relies on adapter functionality won't work. This is rather easy to fix.

=== JOMP

* Adds a burden overhead to all property access methods of the default JS object.
* Not thread-safe,. and making Making it threadsafe will would probably require using a java.lang.ThreadLocal to disable the metaobject during invocation, which would put an even bigger penalty burden on the default JS object.

=== Test code

This is a script that implements a base and extended object using both techniques, and a patch for adding JOMP support to Rhino.

<% this.attachments %>

     removed
     added