8010709: org on the top level doesn't resolve

Mon, 25 Mar 2013 18:20:16 +0530

author
sundar
date
Mon, 25 Mar 2013 18:20:16 +0530
changeset 146
15dac7439921
parent 145
ae4ef3102d9c
child 147
43e40c08e7f8

8010709: org on the top level doesn't resolve
Reviewed-by: lagergren, hannesw

src/jdk/nashorn/internal/objects/Global.java file | annotate | diff | comparison | revisions
test/script/basic/JDK-8010709.js file | annotate | diff | comparison | revisions
     1.1 --- a/src/jdk/nashorn/internal/objects/Global.java	Mon Mar 25 12:01:06 2013 +0100
     1.2 +++ b/src/jdk/nashorn/internal/objects/Global.java	Mon Mar 25 18:20:16 2013 +0530
     1.3 @@ -259,13 +259,29 @@
     1.4      @Property(name = "Packages", attributes = Attribute.NOT_ENUMERABLE)
     1.5      public volatile Object packages;
     1.6  
     1.7 +    /** Nashorn extension: Java access - global.com */
     1.8 +    @Property(attributes = Attribute.NOT_ENUMERABLE)
     1.9 +    public volatile Object com;
    1.10 +
    1.11 +    /** Nashorn extension: Java access - global.edu */
    1.12 +    @Property(attributes = Attribute.NOT_ENUMERABLE)
    1.13 +    public volatile Object edu;
    1.14 +
    1.15      /** Nashorn extension: Java access - global.java */
    1.16      @Property(attributes = Attribute.NOT_ENUMERABLE)
    1.17      public volatile Object java;
    1.18  
    1.19 +    /** Nashorn extension: Java access - global.javafx */
    1.20 +    @Property(attributes = Attribute.NOT_ENUMERABLE)
    1.21 +    public volatile Object javafx;
    1.22 +
    1.23      /** Nashorn extension: Java access - global.javax */
    1.24      @Property(attributes = Attribute.NOT_ENUMERABLE)
    1.25 -    public Object javax;
    1.26 +    public volatile Object javax;
    1.27 +
    1.28 +    /** Nashorn extension: Java access - global.org */
    1.29 +    @Property(attributes = Attribute.NOT_ENUMERABLE)
    1.30 +    public volatile Object org;
    1.31  
    1.32      /** Nashorn extension: Java access - global.javaImporter */
    1.33      @Property(name = "JavaImporter", attributes = Attribute.NOT_ENUMERABLE)
    1.34 @@ -320,8 +336,12 @@
    1.35      private ScriptFunction builtinTypeError;
    1.36      private ScriptFunction builtinURIError;
    1.37      private ScriptObject   builtinPackages;
    1.38 +    private ScriptObject   builtinCom;
    1.39 +    private ScriptObject   builtinEdu;
    1.40      private ScriptObject   builtinJava;
    1.41 +    private ScriptObject   builtinJavafx;
    1.42      private ScriptObject   builtinJavax;
    1.43 +    private ScriptObject   builtinOrg;
    1.44      private ScriptObject   builtinJavaImporter;
    1.45      private ScriptObject   builtinJavaApi;
    1.46      private ScriptObject   builtinArrayBuffer;
    1.47 @@ -1482,8 +1502,12 @@
    1.48      private void initJavaAccess() {
    1.49          final ScriptObject objectProto = getObjectPrototype();
    1.50          this.builtinPackages = new NativeJavaPackage("", objectProto);
    1.51 +        this.builtinCom = new NativeJavaPackage("com", objectProto);
    1.52 +        this.builtinEdu = new NativeJavaPackage("edu", objectProto);
    1.53          this.builtinJava = new NativeJavaPackage("java", objectProto);
    1.54 +        this.builtinJavafx = new NativeJavaPackage("javafx", objectProto);
    1.55          this.builtinJavax = new NativeJavaPackage("javax", objectProto);
    1.56 +        this.builtinOrg = new NativeJavaPackage("org", objectProto);
    1.57          this.builtinJavaImporter = initConstructor("JavaImporter");
    1.58          this.builtinJavaApi = initConstructor("Java");
    1.59      }
    1.60 @@ -1566,8 +1590,12 @@
    1.61          this.function          = this.builtinFunction;
    1.62          this.jsadapter         = this.builtinJSAdapter;
    1.63          this.json              = this.builtinJSON;
    1.64 +        this.com               = this.builtinCom;
    1.65 +        this.edu               = this.builtinEdu;
    1.66          this.java              = this.builtinJava;
    1.67 +        this.javafx            = this.builtinJavafx;
    1.68          this.javax             = this.builtinJavax;
    1.69 +        this.org               = this.builtinOrg;
    1.70          this.javaImporter      = this.builtinJavaImporter;
    1.71          this.javaApi           = this.builtinJavaApi;
    1.72          this.math              = this.builtinMath;
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/script/basic/JDK-8010709.js	Mon Mar 25 18:20:16 2013 +0530
     2.3 @@ -0,0 +1,46 @@
     2.4 +/*
     2.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 + * or visit www.oracle.com if you need additional information or have any
    2.24 + * questions.
    2.25 + */
    2.26 +
    2.27 +/**
    2.28 + * JDK-8010709  org on the top level doesn't resolve 
    2.29 + *
    2.30 + * @test
    2.31 + * @run
    2.32 + */
    2.33 +
    2.34 +function check(pkgName) {
    2.35 +    if (typeof this[pkgName] != 'object') {
    2.36 +        fail(pkgName + " not defined");
    2.37 +    }
    2.38 +
    2.39 +    if (String(this[pkgName]) != '[JavaPackage ' + pkgName + ']') {
    2.40 +        fail(pkgName + " is not a JavaPackage");
    2.41 +    }
    2.42 +}
    2.43 +
    2.44 +check("com");
    2.45 +check("edu");
    2.46 +check("java");
    2.47 +check("javafx");
    2.48 +check("javax");
    2.49 +check("org");

mercurial