RFR: 8162839: JavaAdapters do not work with ScriptObjectMirror objects
Hannes Wallnöfer
hannes.wallnoefer at oracle.com
Wed Nov 16 15:13:41 UTC 2016
Please review:
Bug: https://bugs.openjdk.java.net/browse/JDK-8162839
Webrev: http://cr.openjdk.java.net/~hannesw/8162839/webrev.00/
This makes JavaAdapters work with ScriptObjectMirrors in addition to ScriptObjects and ScriptFunctions.
A few notes:
- NashornLinker.getSamTypeConverter now gets the constructor with Object.class extra parameter if sourceType is more generic than ScriptFunction.class. However, this really is an OverloadedMethod constructor, so the ScriptFunction constructor will be called if the argument happens to be a ScriptFunction.
- Unfortunately the only way to get at the ScriptObject and Global of a ScriptObjectMirror is to use reflection, making the fields accessible. Since ScriptObjectMirror is in a package that’s exported to the world we can’t add public getters. Field accessors are created lazily and cached in JavaAdapterServices.MirrorFieldHolder.
- When writing the test for this I noticed that some of our java tests are not run in „ant run“. I added the missing test packages to build.xml.
- This contains cleanup for indentation in JavaAdapterByteCodeGenerator.java. That class had wrong indentation in various places.
Thanks,
Hannes
More information about the nashorn-dev
mailing list