Bug report: instanceof incompatible with mozilla_compat's importClass

A. Sundararajan sundararajan.athijegannathan at oracle.com
Wed Oct 9 22:08:54 PDT 2013


I hope you call load('nashorn:mozilla_compat.js') as a top-level 
expression -- and not within a function. Because mozilla_compat.js 
assumes it is being evaluated with 'this' as global scope.

ReferenceError may be from importPackage -- because importPackage is the 
one that installs __noSuchProperty__ hook to the global scope. That is 
to make sure unresolved globals are checked for possible imports.

Other than that I can't think of anything else ... (without more context 
to the script that fails)

-Sundar

On Thursday 10 October 2013 05:56 AM, Tal Liron wrote:
> Hm, something very strange is happening, because I'm also unable to 
> isolate this exception.
>
> Moreover, the exception is coming from importPackage in 
> mozilla_compat, not importClass. However, nowhere am I calling 
> importPackage. Do you have any idea what could be causing this oddity?
>
> On 10/10/2013 03:06 AM, A. Sundararajan wrote:
>> var x  = {}
>>     load('nashorn:mozilla_compat.js')
>>
>>     importClass(java.io.File)
>>     print(x instanceof File)
>>
>>     var y  =  new File("foo");
>>     print(y instanceof File)
>>
>> works fine for me. Tried with latest nashorn tip:
>>
>> changeset:   596:03a68e7ca1d5
>> tag:         tip
>> user:        lagergren
>> date:        Wed Oct 09 17:53:22 2013 +0200
>> summary:     8026137: Fix Issues with Binary Evaluation Order
>>
>>
>> PS. I am sure this should work with early access jdk8 snapshot too -- 
>> as I don't recall any bugfix in this area in the recent past.
>>
>> -Sundar
>>
>> On Wednesday 09 October 2013 08:40 PM, Tal Liron wrote:
>>> Example:
>>>
>>> importClass(java.io.File)
>>> x instanceof File
>>>
>>> Will throw an exception:
>>>
>>> nashorn:mozilla_compat.js:65:20 ReferenceError: File is not defined
>>>     at 
>>> jdk.nashorn.internal.scripts.Script$\=nashorn\!mozilla_compat._L47$_L51(nashorn:mozilla_compat.js:65)
>>>
>>> However, this works:
>>>
>>> x instanceof java.io.File
>>>
>>
>



More information about the nashorn-dev mailing list