aboutsummaryrefslogtreecommitdiff
path: root/src/jdk/nashorn/internal/runtime/resources
diff options
context:
space:
mode:
authorsundar <none@none>2013-10-10 13:17:57 +0200
committersundar <none@none>2013-10-10 13:17:57 +0200
commit7b09f14933be3e126793574e671b792c421de3b6 (patch)
tree168e6d64d6ff861d0838f3426eea848be7f4ac42 /src/jdk/nashorn/internal/runtime/resources
parente2219d80bba51ee40d038ce843643e7612c89b97 (diff)
downloadnashorn-7b09f14933be3e126793574e671b792c421de3b6.tar.gz
8026248: importClass has to be a varargs function
Reviewed-by: jlaskey, hannesw
Diffstat (limited to 'src/jdk/nashorn/internal/runtime/resources')
-rw-r--r--src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js b/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js
index 6b934ad4..f54dcfb8 100644
--- a/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js
+++ b/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js
@@ -41,7 +41,12 @@ Object.defineProperty(this, "JavaAdapter", {
}
});
+
// importPackage
+// avoid unnecessary chaining of __noSuchProperty__ again
+// in case user loads this script more than once.
+if (typeof importPackage == 'undefined') {
+
Object.defineProperty(this, "importPackage", {
configurable: true, enumerable: false, writable: true,
value: (function() {
@@ -91,6 +96,8 @@ Object.defineProperty(this, "importPackage", {
})()
});
+}
+
// Object.prototype.__defineGetter__
Object.defineProperty(Object.prototype, "__defineGetter__", {
configurable: true, enumerable: false, writable: true,
@@ -344,13 +351,16 @@ Object.defineProperty(String.prototype, "sup", {
// Rhino: global.importClass
Object.defineProperty(this, "importClass", {
configurable: true, enumerable: false, writable: true,
- value: function(clazz) {
- if (Java.isType(clazz)) {
- var className = Java.typeName(clazz);
- var simpleName = className.substring(className.lastIndexOf('.') + 1);
- this[simpleName] = clazz;
- } else {
- throw new TypeError(clazz + " is not a Java class");
+ value: function() {
+ for (var arg in arguments) {
+ var clazz = arguments[arg];
+ if (Java.isType(clazz)) {
+ var className = Java.typeName(clazz);
+ var simpleName = className.substring(className.lastIndexOf('.') + 1);
+ this[simpleName] = clazz;
+ } else {
+ throw new TypeError(clazz + " is not a Java class");
+ }
}
}
});