Review request for JDK-8006984
Andreas Rieber
rieberandreas at gmail.com
Tue Feb 26 07:47:27 PST 2013
Hm, i would like to get that scriptpad sample working but what should i
say... The next scope problem is here:
var guiPkgs = new JavaImporter(javax.swing);
with (guiPkgs) {
var main = function() {
var frame;
function createFrame() {
frame = new JFrame();
}
createFrame();
print("created");
};
}
main();
I checked out all again, recompiled, this time a clean jdk8/tl without
any rhino or other hack. This sample fails with jjs and jrunscript:
/usr/local/src/jdk8tl/build/linux-x86-normal-server-release/images/j2sdk-image/bin/jjs
scriptpad.js
scriptpad.js:9 ReferenceError: "JFrame" is not defined
- Andreas
On 26.02.13 04:08, A. Sundararajan wrote:
> Hi Andreas,
>
> Yep, I wrote that "scriptpad" sample - as a demo for embedded Rhino in
> jdk6/7. Yes, when nashorn is changed to fix as per spec, I/we need to
> fix that sample to work on nashorn as well.
>
> Function-declaration-to-expression fix needs to be done on this sample
> as well as other such script, if any, in jdk code/samples/docs.
>
> -Sundar
>
> On Tuesday 26 February 2013 12:33 AM, Andreas Rieber wrote:
>> Hi Attila,
>>
>> i can't read that out of ecma-262 spec but i guess you read that many
>> times more than i did. I try to follow "The Good Pars", which would
>> make all easier.
>>
>> Is there a way to access the issue tracking? I mean it would make my
>> live easier. At the moment i follow every commit and try to get in
>> but i don't see what is open, coming, etc.
>>
>> cheers
>> Andreas
>>
>> PS: if i am not totally wrong - that code was from Sundar.
>>
>>
>> On 25.02.13 18:46, Attila Szegedi wrote:
>>> Excellent…
>>>
>>> On that note, I want to make you aware that we'll soon make Nashorn
>>> reject with a syntax error those function declarations that occur
>>> within "with" and "catch" blocks; we're shooting for 100% ECMAScript
>>> 5.1 compliance, and it disallows function declarations except
>>> directly on the top-level of script and in another function's body.
>>> In such cases, you'll need to use a function expression instead. So
>>> this:
>>>
>>> var guiPkgs = { JFrame: function() { print("created"); } };
>>>
>>> with (guiPkgs) {
>>> function main() { // <---- this is not legal in ECMAScript 5.1
>>> var frame;
>>>
>>> function createFrame() {
>>> frame = new JFrame();
>>> }
>>>
>>> createFrame();
>>> }
>>> }
>>> main();
>>>
>>> will soon stop working. If you want the "main" function and whatever
>>> is in it to be affected by the with() block, you'll have to use a
>>> function expression instead like this:
>>>
>>> with (guiPkgs) {
>>> var main = function() { // <---- this expresses your actual
>>> intent, and is the only valid construct here in ES5.1
>>> var frame;
>>>
>>> function createFrame() { // <-- this is still okay, as it's
>>> defined directly on the function body level of main()
>>> frame = new JFrame();
>>> }
>>>
>>> createFrame();
>>> }
>>> }
>>> main();
>>>
>>> Attila.
>>>
>>> On Feb 25, 2013, at 6:37 PM, Andreas Rieber <rieberandreas at gmail.com
>>> <mailto:rieberandreas at gmail.com>> wrote:
>>>
>>>> Hi Attila,
>>>>
>>>> i found that fix and retested. One line more and another one...
>>>> couldn't break it ;-)
>>>>
>>>> Andreas
>>>>
>>>> On 25.02.13 16:36, Attila Szegedi wrote:
>>>>> Second review request, now with the test:
>>>>> http://cr.openjdk.java.net/~attila/8006984/webrev.01/
>>>>> <http://cr.openjdk.java.net/%7Eattila/8006984/webrev.01/>
>>>>>
>>>>> On Feb 25, 2013, at 3:43 PM, Attila Szegedi
>>>>> <attila.szegedi at oracle.com <mailto:attila.szegedi at oracle.com>> wrote:
>>>>>
>>>>>> Please review JDK-8006984 at
>>>>>> http://cr.openjdk.java.net/~attila/8006984/webrev.00
>>>>>> <http://cr.openjdk.java.net/%7Eattila/8006984/webrev.00>
>>>>>>
>>>>>> Thanks,
>>>>>> Attila.
More information about the nashorn-dev
mailing list