RFR: 8162839: JavaAdapters do not work with ScriptObjectMirror objects

Hannes Wallnöfer hannes.wallnoefer at oracle.com
Thu Nov 17 15:50:29 UTC 2016

Thanks for the reviews.

I already pushed the change, but I think the demand for a test that runs under SecurityManager makes sense, given that the change contains privileged code to access the ScriptObjectMirror fields.

I field a new bug to add a simple test running with security on. Please review:

Bug: https://bugs.openjdk.java.net/browse/JDK-8169886
Webrev: http://cr.openjdk.java.net/~hannesw/8169886/webrev/ 


> Am 17.11.2016 um 12:11 schrieb Sundararajan Athijegannathan <sundararajan.athijegannathan at oracle.com>:
> Looks good!
> PS. Would be nice if we have with security manager test (perhaps .js
> test?) that exercises ScriptObjectMirror to adapter conversion. But, no
> biggie..
> -Sundar
> On 11/16/2016 8:43 PM, Hannes Wallnöfer wrote:
>> 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