changeset 270:ac14a1fb0cab

8009141: Avoid netscape.javascript.JSObject in nashorn code Reviewed-by: lagergren, hannesw
author sundar
date Thu, 16 May 2013 14:52:48 +0530
parents 19e9cd9c7010
children 4c67a692ef97
files src/jdk/nashorn/api/scripting/JSObject.java src/jdk/nashorn/api/scripting/ScriptObjectMirror.java src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java src/netscape/javascript/JSObject.java test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java
diffstat 5 files changed, 88 insertions(+), 104 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk/nashorn/api/scripting/JSObject.java	Thu May 16 14:52:48 2013 +0530
@@ -0,0 +1,87 @@
+/*
+ * 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+package jdk.nashorn.api.scripting;
+
+/**
+ * netscape.javascript.JSObject-like interface for nashorn script objects.
+ */
+public abstract class JSObject {
+    /**
+     * Call a JavaScript method
+     *
+     * @param methodName name of method
+     * @param args arguments to method
+     * @return result of call
+     */
+    public abstract Object call(String methodName, Object args[]);
+
+    /**
+     * Evaluate a JavaScript expression
+     *
+     * @param s JavaScript expression to evaluate
+     * @return evaluation result
+     */
+    public abstract Object eval(String s);
+
+    /**
+     * Retrieves a named member of a JavaScript object.
+     *
+     * @param name of member
+     * @return member
+     */
+    public abstract Object getMember(String name);
+
+    /**
+     * Retrieves an indexed member of a JavaScript object.
+     *
+     * @param index index of member slot
+     * @return member
+     */
+    public abstract Object getSlot(int index);
+
+    /**
+     * Remove a named member from a JavaScript object
+     *
+     * @param name name of member
+     */
+    public abstract void removeMember(String name);
+
+    /**
+     * Set a named member in a JavaScript object
+     *
+     * @param name  name of member
+     * @param value value of member
+     */
+    public abstract void setMember(String name, Object value);
+
+    /**
+     * Set an indexed member in a JavaScript object
+     *
+     * @param index index of member slot
+     * @param value value of member
+     */
+    public abstract void setSlot(int index, Object value);
+}
--- a/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java	Wed May 15 20:21:59 2013 +0200
+++ b/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java	Thu May 16 14:52:48 2013 +0530
@@ -42,7 +42,6 @@
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
-import netscape.javascript.JSObject;
 
 /**
  * Mirror object that wraps a given ScriptObject instance. User can
--- a/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java	Wed May 15 20:21:59 2013 +0200
+++ b/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java	Thu May 16 14:52:48 2013 +0530
@@ -38,7 +38,7 @@
 import jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker;
 import jdk.internal.dynalink.support.CallSiteDescriptorFactory;
 import jdk.nashorn.internal.runtime.JSType;
-import netscape.javascript.JSObject;
+import jdk.nashorn.api.scripting.JSObject;
 
 /**
  * A Dynalink linker to handle web browser built-in JS (DOM etc.) objects as well
--- a/src/netscape/javascript/JSObject.java	Wed May 15 20:21:59 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-/*
- * 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.
- */
-
-package netscape.javascript;
-
-import java.applet.Applet;
-
-/**
- * Stub for JSObject to get compilation going.
- */
-public abstract class JSObject {
-
-    /**
-     * Get the window for an {@link Applet}. Not supported
-     * by Nashorn
-     *
-     * @param a applet
-     * @return the window instance
-     */
-    public static JSObject getWindow(final Applet a) {
-        throw new UnsupportedOperationException("getWindow");
-    }
-
-    /**
-     * Call a JavaScript method
-     *
-     * @param methodName name of method
-     * @param args arguments to method
-     * @return result of call
-     */
-    public abstract Object call(String methodName, Object args[]);
-
-    /**
-     * Evaluate a JavaScript expression
-     *
-     * @param s JavaScript expression to evaluate
-     * @return evaluation result
-     */
-    public abstract Object eval(String s);
-
-    /**
-     * Retrieves a named member of a JavaScript object.
-     *
-     * @param name of member
-     * @return member
-     */
-    public abstract Object getMember(String name);
-
-    /**
-     * Retrieves an indexed member of a JavaScript object.
-     *
-     * @param index index of member slot
-     * @return member
-     */
-    public abstract Object getSlot(int index);
-
-    /**
-     * Remove a named member from a JavaScript object
-     *
-     * @param name name of member
-     */
-    public abstract void removeMember(String name);
-
-    /**
-     * Set a named member in a JavaScript object
-     *
-     * @param name  name of member
-     * @param value value of member
-     */
-    public abstract void setMember(String name, Object value);
-
-    /**
-     * Set an indexed member in a JavaScript object
-     *
-     * @param index index of member slot
-     * @param value value of member
-     */
-    public abstract void setSlot(int index, Object value);
-}
--- a/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java	Wed May 15 20:21:59 2013 +0200
+++ b/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java	Thu May 16 14:52:48 2013 +0530
@@ -47,7 +47,6 @@
 import javax.script.ScriptEngineManager;
 import javax.script.ScriptException;
 import javax.script.SimpleScriptContext;
-import netscape.javascript.JSObject;
 import org.testng.Assert;
 import org.testng.annotations.Test;