SA: Various fixes to sa.js to make it work in JDK8
rednaxelafx at gmail.com
Mon Jul 29 00:53:22 PDT 2013
Could I have a couple of reviews for this patch, please?
project caused a few issues that stopped sa.js from working. This is a
patch that tries to fix the issues that I've run into.
I'll walkthrough the patch below: (line numbers refer to sajs.patch, not
property name in the "dot" syntax is not a problem anymore. So I'm
un-commenting these lines.
Line 20-42, 51-76:
When implementing a JavaAdapter for SA ScriptObject, the __get__ function
calls the __has__ function:
which is working at the wrong level: __has__ is a special hook function,
and cannot be called via "this" this way. It'll trigger the __call__ hook
to find the "__has__" member, but the JavaAdapter here does not override
__call__, and then the lookup will fail.
Rather than going through the trouble of implementing the __call__ hook
just for this purpose, I move the __has__ function up, and made __get__
call __has__ directly instead. Now it won't trigger the __call__ hook for
the lookup, the things will work fine again.
Removed trailing whitespace.
This code used to work in Rhino, but apparently Nashorn doesn't
JS-to-Java interop, so this conversion has to be done manually.
I'm a little confused in this part. Nashorn exposes a "print" function
that's defined in jdk/nashorn/api/scripting/resources/engine.js, and that
it doesn't expose a corresponding "println" function. I'm not sure if this
code really worked when using Rhino...anyway, the "println" function is
missing, so "writeln = println" doesn't do anything useful. I'm adding a
shim here just in case either of "print" or "println" functions are
missing. This fixes an error when calling "println" in line 87 of this
This is the same change as purposed by Yunda back in April.  A missing
fix from the NPG changes.
Line 121-122, 129-130:
When specifying a method overload in Nashorn, the argument syntax it takes
for inner classes uses "." as the separator between the enclosing class
name and the inner class name, instead of "$" as in the "binary name".
Line 138-144, 152-160:
Nashorn has stricter default behaviors than Rhino when overriding Java
methods. Where as Rhino defaults to a "do nothing" implementation, Nashorn
defaults to throwing UnsupportedOperationException for unimplemented
Before the fix, this code only replace the first occurrence of the
specified special characters, which happens to be not enough for newer
HotSpot types in C++ templates.
That's all for this patch.
BTW, there is another patches pending review, too: JDK-8011979 
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the serviceability-dev