aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsundar <none@none>2013-03-25 18:20:16 +0530
committersundar <none@none>2013-03-25 18:20:16 +0530
commit33fdf006b2c7384b157894108cfa908fa41cc1c2 (patch)
tree7978e62eba77a25ef81552c2874ac98f37f9532d
parentf1d834aff48966fde88026b4852a8049a362ace5 (diff)
downloadnashorn-33fdf006b2c7384b157894108cfa908fa41cc1c2.tar.gz
8010709: org on the top level doesn't resolve
Reviewed-by: lagergren, hannesw
-rw-r--r--src/jdk/nashorn/internal/objects/Global.java30
-rw-r--r--test/script/basic/JDK-8010709.js46
2 files changed, 75 insertions, 1 deletions
diff --git a/src/jdk/nashorn/internal/objects/Global.java b/src/jdk/nashorn/internal/objects/Global.java
index e0bb9ece..e079248b 100644
--- a/src/jdk/nashorn/internal/objects/Global.java
+++ b/src/jdk/nashorn/internal/objects/Global.java
@@ -259,13 +259,29 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
@Property(name = "Packages", attributes = Attribute.NOT_ENUMERABLE)
public volatile Object packages;
+ /** Nashorn extension: Java access - global.com */
+ @Property(attributes = Attribute.NOT_ENUMERABLE)
+ public volatile Object com;
+
+ /** Nashorn extension: Java access - global.edu */
+ @Property(attributes = Attribute.NOT_ENUMERABLE)
+ public volatile Object edu;
+
/** Nashorn extension: Java access - global.java */
@Property(attributes = Attribute.NOT_ENUMERABLE)
public volatile Object java;
+ /** Nashorn extension: Java access - global.javafx */
+ @Property(attributes = Attribute.NOT_ENUMERABLE)
+ public volatile Object javafx;
+
/** Nashorn extension: Java access - global.javax */
@Property(attributes = Attribute.NOT_ENUMERABLE)
- public Object javax;
+ public volatile Object javax;
+
+ /** Nashorn extension: Java access - global.org */
+ @Property(attributes = Attribute.NOT_ENUMERABLE)
+ public volatile Object org;
/** Nashorn extension: Java access - global.javaImporter */
@Property(name = "JavaImporter", attributes = Attribute.NOT_ENUMERABLE)
@@ -320,8 +336,12 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
private ScriptFunction builtinTypeError;
private ScriptFunction builtinURIError;
private ScriptObject builtinPackages;
+ private ScriptObject builtinCom;
+ private ScriptObject builtinEdu;
private ScriptObject builtinJava;
+ private ScriptObject builtinJavafx;
private ScriptObject builtinJavax;
+ private ScriptObject builtinOrg;
private ScriptObject builtinJavaImporter;
private ScriptObject builtinJavaApi;
private ScriptObject builtinArrayBuffer;
@@ -1482,8 +1502,12 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
private void initJavaAccess() {
final ScriptObject objectProto = getObjectPrototype();
this.builtinPackages = new NativeJavaPackage("", objectProto);
+ this.builtinCom = new NativeJavaPackage("com", objectProto);
+ this.builtinEdu = new NativeJavaPackage("edu", objectProto);
this.builtinJava = new NativeJavaPackage("java", objectProto);
+ this.builtinJavafx = new NativeJavaPackage("javafx", objectProto);
this.builtinJavax = new NativeJavaPackage("javax", objectProto);
+ this.builtinOrg = new NativeJavaPackage("org", objectProto);
this.builtinJavaImporter = initConstructor("JavaImporter");
this.builtinJavaApi = initConstructor("Java");
}
@@ -1566,8 +1590,12 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
this.function = this.builtinFunction;
this.jsadapter = this.builtinJSAdapter;
this.json = this.builtinJSON;
+ this.com = this.builtinCom;
+ this.edu = this.builtinEdu;
this.java = this.builtinJava;
+ this.javafx = this.builtinJavafx;
this.javax = this.builtinJavax;
+ this.org = this.builtinOrg;
this.javaImporter = this.builtinJavaImporter;
this.javaApi = this.builtinJavaApi;
this.math = this.builtinMath;
diff --git a/test/script/basic/JDK-8010709.js b/test/script/basic/JDK-8010709.js
new file mode 100644
index 00000000..d2ec87ae
--- /dev/null
+++ b/test/script/basic/JDK-8010709.js
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8010709 org on the top level doesn't resolve
+ *
+ * @test
+ * @run
+ */
+
+function check(pkgName) {
+ if (typeof this[pkgName] != 'object') {
+ fail(pkgName + " not defined");
+ }
+
+ if (String(this[pkgName]) != '[JavaPackage ' + pkgName + ']') {
+ fail(pkgName + " is not a JavaPackage");
+ }
+}
+
+check("com");
+check("edu");
+check("java");
+check("javafx");
+check("javax");
+check("org");