changeset 4655:109e514e5f85

RT-32284: Move JSObject and JSException to graphics module to enable builds on OpenJDK
author rbair
date Mon, 12 Aug 2013 14:27:11 -0700
parents a91372ca4da9
children a1fe539edc60
files build.gradle modules/graphics/src/main/java/netscape/javascript/JSException.java modules/graphics/src/main/java/netscape/javascript/JSObject.java modules/web/src/main/java/netscape/javascript/JSException.java modules/web/src/main/java/netscape/javascript/JSObject.java
diffstat 5 files changed, 330 insertions(+), 337 deletions(-) [+]
line wrap: on
line diff
--- a/build.gradle	Mon Aug 12 15:25:07 2013 -0400
+++ b/build.gradle	Mon Aug 12 14:27:11 2013 -0700
@@ -922,11 +922,6 @@
                     artifact "[artifact].[ext]"
                 }
             }
-            // We have this repo for getting the plugin.jar from the existing JRE
-            flatDir {
-                dir "$STUB_RUNTIME/lib/"
-                dir "$JDK_HOME/jre/lib/"
-            }
         }
     }
 
@@ -1040,7 +1035,6 @@
 
     dependencies {
         compile project(":base"), BUILD_SRC
-        compile name: "plugin"
         compile name: SWT_FILE_NAME
         stubCompile group: "junit", name: "junit", version: "4.8.2",
         project(":base").sourceSets.test.output, sourceSets.main.output
@@ -1298,7 +1292,6 @@
             copy {
                 into libsDir
                 from f.getParentFile()
-                include "**/plugin.jar"
                 include "**/antlr-3.1.3.jar"
                 include "**/stringtemplate-3.2.jar"
                 include "**/antlr-runtime-3.1.3.jar"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/netscape/javascript/JSException.java	Mon Aug 12 14:27:11 2013 -0700
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+package netscape.javascript;
+
+
+/**
+ * <p> Thrown when an exception is raised in the JavaScript engine.
+ * </p>
+ *
+ * <p> Much of the functionality in this class is deprecated as it is
+ * not portable between web browsers. The only functionality that
+ * should be relied upon is the throwing of this exception and calls
+ * to <CODE>printStackTrace()</CODE>. </p>
+ */
+public class JSException extends RuntimeException {
+
+    // Exception type supported by JavaScript 1.4 in Navigator 5.0.
+    //
+    /** @deprecated  Not portable between web browsers. */
+    public static final int EXCEPTION_TYPE_EMPTY = -1;
+    /** @deprecated  Not portable between web browsers. */
+    public static final int EXCEPTION_TYPE_VOID = 0;
+    /** @deprecated  Not portable between web browsers. */
+    public static final int EXCEPTION_TYPE_OBJECT = 1;
+    /** @deprecated  Not portable between web browsers. */
+    public static final int EXCEPTION_TYPE_FUNCTION = 2;
+    /** @deprecated  Not portable between web browsers. */
+    public static final int EXCEPTION_TYPE_STRING = 3;
+    /** @deprecated  Not portable between web browsers. */
+    public static final int EXCEPTION_TYPE_NUMBER = 4;
+    /** @deprecated  Not portable between web browsers. */
+    public static final int EXCEPTION_TYPE_BOOLEAN = 5;
+    /** @deprecated  Not portable between web browsers. */
+    public static final int EXCEPTION_TYPE_ERROR = 6;
+
+    /**
+     * <p> Constructs a JSException object.
+     * </p>
+     */
+    public JSException() {
+        this(null);
+    }
+
+    /**
+     * <p> Construct a JSException object with a detail message.
+     * </p>
+     *
+     * @param s The detail message
+     */
+     public JSException(String s)  {
+        this(s, null, -1, null, -1);
+    }
+
+
+    /**
+     * <p> Construct a JSException object. This constructor is
+     * deprecated as it involves non-portable functionality. </p>
+     *
+     * @param s The detail message.
+     * @param filename The URL of the file where the error occurred, if possible.
+     * @param lineno The line number if the file, if possible.
+     * @param source The string containing the JavaScript code being evaluated.
+     * @param tokenIndex The index into the source string where the error occurred.
+     * @deprecated  Not portable between web browsers.
+     */
+    public JSException(String s, String filename, int lineno, String source,
+                       int tokenIndex)  {
+        super(s);
+        this.message = s;
+        this.filename = filename;
+        this.lineno = lineno;
+        this.source = source;
+        this.tokenIndex = tokenIndex;
+        this.wrappedExceptionType = EXCEPTION_TYPE_EMPTY;
+    }
+
+    /**
+     * <p> Construct a JSException object. This constructor is
+     * deprecated as it involves non-portable functionality. </p>
+     *
+     * @param wrappedExceptionType Type of the wrapped JavaScript exception.
+     * @param wrappedException JavaScript exception wrapper.
+     * @deprecated  Not portable between web browsers.
+     */
+    public JSException(int wrappedExceptionType, Object wrappedException) {
+        this();
+        this.wrappedExceptionType = wrappedExceptionType;
+        this.wrappedException = wrappedException;
+    }
+
+    /**
+     * <p> The detail message. </p>
+     * @deprecated  Not portable between web browsers.
+     */
+    protected String message = null;
+
+    /**
+     * <p> The URL of the file where the error occurred, if possible. </p>
+     * @deprecated  Not portable between web browsers.
+     */
+    protected String filename = null;
+
+    /**
+     * <p> The line number if the file, if possible. </p>
+     * @deprecated  Not portable between web browsers.
+     */
+    protected int lineno = -1;
+
+    /**
+     * <p> The string containing the JavaScript code being evaluated. </p>
+     * @deprecated  Not portable between web browsers.
+     */
+    protected String source = null;
+
+    /**
+     * <p> The index into the source string where the error occurred. </p>
+     * @deprecated  Not portable between web browsers.
+     */
+    protected int tokenIndex = -1;
+
+    /**
+     * <p> Type of the wrapped JavaScript exception. </p>
+     * @deprecated  Not portable between web browsers.
+     */
+    private int wrappedExceptionType = -1;
+
+    /**
+     * <p> JavaScript exception wrapper. </p>
+     * @deprecated  Not portable between web browsers.
+     */
+    private Object wrappedException = null;
+
+    /**
+     * <P> getWrappedExceptionType returns the int mapping of the type
+     * of the wrappedException Object. This method is deprecated as it
+     * involves non-portable functionality.  </P>
+     *
+     * @return int JavaScript exception type.
+     * @deprecated  Not portable between web browsers.
+     */
+    public int getWrappedExceptionType() {
+        return wrappedExceptionType;
+    }
+
+    /**
+     * <P> Returns the wrapped JavaScript exception. This method is
+     * deprecated as it involves non-portable functionality.  </P>
+     *
+     * @return Object JavaScript exception wrapper.
+     * @deprecated  Not portable between web browsers.
+     */
+    public Object getWrappedException() {
+        return wrappedException;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/netscape/javascript/JSObject.java	Mon Aug 12 14:27:11 2013 -0700
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+package netscape.javascript;
+
+
+// FIXME: need URL on java.sun.com for new LiveConnect spec
+
+/**
+ * <P> Allows Java code to manipulate JavaScript objects. </P>
+ *
+ * <P> When a JavaScript object is passed or returned to Java code, it
+ * is wrapped in an instance of <CODE>JSObject</CODE>. When a
+ * <CODE>JSObject</CODE> instance is passed to the JavaScript engine,
+ * it is unwrapped back to its original JavaScript object. The
+ * <CODE>JSObject</CODE> class provides a way to invoke JavaScript
+ * methods and examine JavaScript properties. </P>
+ *
+ * <P> Any data returned from the JavaScript engine to Java is
+ * converted to Java data types. Certain data passed to the JavaScript
+ * engine is converted to JavaScript data types. See the section on <A
+ * HREF="http://jdk6.java.net/plugin2/liveconnect/index.html#JAVA_JS_CONVERSIONS">
+ * Data Type Conversions</A> in the <A
+ * HREF="http://jdk6.java.net/plugin2/liveconnect">LiveConnect Specification</A>
+ * for details on how values are converted. </P>
+ *
+ */
+public abstract class JSObject {
+
+    /**
+     * Constructs a new JSObject. Users should not call this method
+     * nor subclass JSObject.
+     */
+    protected JSObject()  {
+    }
+
+    /**
+     * <p> Calls a JavaScript method. Equivalent to
+     * "this.methodName(args[0], args[1], ...)" in JavaScript.
+     * </p>
+     *
+     * @param methodName The name of the JavaScript method to be invoked.
+     * @param args An array of Java object to be passed as arguments to the method.
+     * @return Result of the method.
+     */
+    public abstract Object call(String methodName, Object... args) throws JSException;
+
+    /**
+     * <p> Evaluates a JavaScript expression. The expression is a string of
+     * JavaScript source code which will be evaluated in the context given by
+     * "this".
+     * </p>
+     *
+     * @param s The JavaScript expression.
+     * @return Result of the JavaScript evaluation.
+     */
+    public abstract Object eval(String s) throws JSException;
+
+    /**
+     * <p> Retrieves a named member of a JavaScript object. Equivalent to
+     * "this.name" in JavaScript.
+     * </p>
+     *
+     * @param name The name of the JavaScript property to be accessed.
+     * @return The value of the propery.
+     */
+    public abstract Object getMember(String name) throws JSException;
+
+    /**
+     * <p> Sets a named member of a JavaScript object. Equivalent to
+     * "this.name = value" in JavaScript.
+     * </p>
+     *
+     * @param name The name of the JavaScript property to be accessed.
+     * @param value The value of the propery.
+     */
+    public abstract void setMember(String name, Object value) throws JSException;
+
+    /**
+     * <p> Removes a named member of a JavaScript object. Equivalent
+     * to "delete this.name" in JavaScript.
+     * </p>
+     *
+     * @param name The name of the JavaScript property to be removed.
+     */
+    public abstract void removeMember(String name) throws JSException;
+
+    /**
+     * <p> Retrieves an indexed member of a JavaScript object. Equivalent to
+     * "this[index]" in JavaScript.
+     * </p>
+     *
+     * @param index The index of the array to be accessed.
+     * @return The value of the indexed member.
+     */
+    public abstract Object getSlot(int index) throws JSException;
+
+    /**
+     * <p> Sets an indexed member of a JavaScript object. Equivalent to
+     * "this[index] = value" in JavaScript.
+     * </p>
+     *
+     * @param index The index of the array to be accessed.
+     */
+    public abstract void setSlot(int index, Object value) throws JSException;
+
+    /* *
+     * <p> Returns a JSObject for the window containing the given applet.
+     * </p>
+     *
+     * @param applet The applet.
+     * @return JSObject for the window containing the given applet.
+     * /
+    public static JSObject getWindow(Applet applet) throws JSException {
+
+        try
+        {
+            if (applet != null)
+            {
+
+                String obj = (String) applet.getParameter("MAYSCRIPT");
+
+                // Comment out MAYSCRIPT check because Internet Explorer doesn't support
+                // it.
+//              if (obj != null && (obj.equals("") || (new Boolean(obj).booleanValue() == true)))
+                {
+                    // MAYSCRIPT is enabled
+
+                    AppletContext c = applet.getAppletContext();
+
+                    // The applet context must implement the sun.plugin.javascript.JSContext
+                    // in order for us to get the handle that can be used when evaluating
+                    // JavaScript expression.
+                    //
+                    JSObject ret = null;
+
+                    if (c instanceof sun.plugin.javascript.JSContext)
+                    {
+                        JSContext j = (JSContext) c;
+                        ret = j.getJSObject();
+                    }
+
+                    if (ret != null) {
+                        return ret;
+                    }
+                }
+            } else {
+                // new code for CustomProgress to get the JSObject w/o applet
+                AppContext ac = ToolkitStore.get().getAppContext();
+                if (ac != null) {
+                    Object context = ac.get(sun.plugin2.applet.Plugin2Manager.APPCONTEXT_PLUGIN2HOST_KEY);
+                    if (context != null && (context instanceof JSContext)) {
+                        JSContext jsc = (JSContext) context;
+                        JSObject ret = jsc.getOneWayJSObject();
+                        if (ret != null) {
+                           return ret;
+                        }
+                    }
+                }
+            }
+        }
+        catch (Throwable e)
+        {
+            throw (JSException) new JSException(JSException.EXCEPTION_TYPE_ERROR, e).initCause(e);
+        }
+
+        throw new JSException();
+    }
+    */
+}
--- a/modules/web/src/main/java/netscape/javascript/JSException.java	Mon Aug 12 15:25:07 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,158 +0,0 @@
-/*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
- * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
- */
-
-package netscape.javascript;
-
-
-/**
- * <p> Thrown when an exception is raised in the JavaScript engine.
- * </p>
- *
- * <p> Much of the functionality in this class is deprecated as it is
- * not portable between web browsers. The only functionality that
- * should be relied upon is the throwing of this exception and calls
- * to <CODE>printStackTrace()</CODE>. </p>
- */
-public class JSException extends RuntimeException {
-
-    // Exception type supported by JavaScript 1.4 in Navigator 5.0.
-    //
-    /** @deprecated  Not portable between web browsers. */
-    public static final int EXCEPTION_TYPE_EMPTY = -1;
-    /** @deprecated  Not portable between web browsers. */
-    public static final int EXCEPTION_TYPE_VOID = 0;
-    /** @deprecated  Not portable between web browsers. */
-    public static final int EXCEPTION_TYPE_OBJECT = 1;
-    /** @deprecated  Not portable between web browsers. */
-    public static final int EXCEPTION_TYPE_FUNCTION = 2;
-    /** @deprecated  Not portable between web browsers. */
-    public static final int EXCEPTION_TYPE_STRING = 3;
-    /** @deprecated  Not portable between web browsers. */
-    public static final int EXCEPTION_TYPE_NUMBER = 4;
-    /** @deprecated  Not portable between web browsers. */
-    public static final int EXCEPTION_TYPE_BOOLEAN = 5;
-    /** @deprecated  Not portable between web browsers. */
-    public static final int EXCEPTION_TYPE_ERROR = 6;
-
-    /**
-     * <p> Constructs a JSException object.
-     * </p>
-     */
-    public JSException() {
-        this(null);
-    }
-
-    /**
-     * <p> Construct a JSException object with a detail message.
-     * </p>
-     *
-     * @param s The detail message
-     */
-     public JSException(String s)  {
-        this(s, null, -1, null, -1);
-    }
-
-
-    /**
-     * <p> Construct a JSException object. This constructor is
-     * deprecated as it involves non-portable functionality. </p>
-     *
-     * @param s The detail message.
-     * @param filename The URL of the file where the error occurred, if possible.
-     * @param lineno The line number if the file, if possible.
-     * @param source The string containing the JavaScript code being evaluated.
-     * @param tokenIndex The index into the source string where the error occurred.
-     * @deprecated  Not portable between web browsers.
-     */
-    public JSException(String s, String filename, int lineno, String source,
-                       int tokenIndex)  {
-        super(s);
-        this.message = s;
-        this.filename = filename;
-        this.lineno = lineno;
-        this.source = source;
-        this.tokenIndex = tokenIndex;
-        this.wrappedExceptionType = EXCEPTION_TYPE_EMPTY;
-    }
-
-    /**
-     * <p> Construct a JSException object. This constructor is
-     * deprecated as it involves non-portable functionality. </p>
-     *
-     * @param wrappedExceptionType Type of the wrapped JavaScript exception.
-     * @param wrappedException JavaScript exception wrapper.
-     * @deprecated  Not portable between web browsers.
-     */
-    public JSException(int wrappedExceptionType, Object wrappedException) {
-        this();
-        this.wrappedExceptionType = wrappedExceptionType;
-        this.wrappedException = wrappedException;
-    }
-
-    /**
-     * <p> The detail message. </p>
-     * @deprecated  Not portable between web browsers.
-     */
-    protected String message = null;
-
-    /**
-     * <p> The URL of the file where the error occurred, if possible. </p>
-     * @deprecated  Not portable between web browsers.
-     */
-    protected String filename = null;
-
-    /**
-     * <p> The line number if the file, if possible. </p>
-     * @deprecated  Not portable between web browsers.
-     */
-    protected int lineno = -1;
-
-    /**
-     * <p> The string containing the JavaScript code being evaluated. </p>
-     * @deprecated  Not portable between web browsers.
-     */
-    protected String source = null;
-
-    /**
-     * <p> The index into the source string where the error occurred. </p>
-     * @deprecated  Not portable between web browsers.
-     */
-    protected int tokenIndex = -1;
-
-    /**
-     * <p> Type of the wrapped JavaScript exception. </p>
-     * @deprecated  Not portable between web browsers.
-     */
-    private int wrappedExceptionType = -1;
-
-    /**
-     * <p> JavaScript exception wrapper. </p>
-     * @deprecated  Not portable between web browsers.
-     */
-    private Object wrappedException = null;
-
-    /**
-     * <P> getWrappedExceptionType returns the int mapping of the type
-     * of the wrappedException Object. This method is deprecated as it
-     * involves non-portable functionality.  </P>
-     *
-     * @return int JavaScript exception type.
-     * @deprecated  Not portable between web browsers.
-     */
-    public int getWrappedExceptionType() {
-        return wrappedExceptionType;
-    }
-
-    /**
-     * <P> Returns the wrapped JavaScript exception. This method is
-     * deprecated as it involves non-portable functionality.  </P>
-     *
-     * @return Object JavaScript exception wrapper.
-     * @deprecated  Not portable between web browsers.
-     */
-    public Object getWrappedException() {
-        return wrappedException;
-    }
-}
--- a/modules/web/src/main/java/netscape/javascript/JSObject.java	Mon Aug 12 15:25:07 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
- * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
- */
-
-package netscape.javascript;
-
-
-// FIXME: need URL on java.sun.com for new LiveConnect spec
-
-/**
- * <P> Allows Java code to manipulate JavaScript objects. </P>
- *
- * <P> When a JavaScript object is passed or returned to Java code, it
- * is wrapped in an instance of <CODE>JSObject</CODE>. When a
- * <CODE>JSObject</CODE> instance is passed to the JavaScript engine,
- * it is unwrapped back to its original JavaScript object. The
- * <CODE>JSObject</CODE> class provides a way to invoke JavaScript
- * methods and examine JavaScript properties. </P>
- *
- * <P> Any data returned from the JavaScript engine to Java is
- * converted to Java data types. Certain data passed to the JavaScript
- * engine is converted to JavaScript data types. See the section on <A
- * HREF="http://jdk6.java.net/plugin2/liveconnect/index.html#JAVA_JS_CONVERSIONS">
- * Data Type Conversions</A> in the <A
- * HREF="http://jdk6.java.net/plugin2/liveconnect">LiveConnect Specification</A>
- * for details on how values are converted. </P>
- *
- */
-public abstract class JSObject {
-
-    /**
-     * Constructs a new JSObject. Users should not call this method
-     * nor subclass JSObject.
-     */
-    protected JSObject()  {
-    }
-
-    /**
-     * <p> Calls a JavaScript method. Equivalent to
-     * "this.methodName(args[0], args[1], ...)" in JavaScript.
-     * </p>
-     *
-     * @param methodName The name of the JavaScript method to be invoked.
-     * @param args An array of Java object to be passed as arguments to the method.
-     * @return Result of the method.
-     */
-    public abstract Object call(String methodName, Object... args) throws JSException;
-
-    /**
-     * <p> Evaluates a JavaScript expression. The expression is a string of
-     * JavaScript source code which will be evaluated in the context given by
-     * "this".
-     * </p>
-     *
-     * @param s The JavaScript expression.
-     * @return Result of the JavaScript evaluation.
-     */
-    public abstract Object eval(String s) throws JSException;
-
-    /**
-     * <p> Retrieves a named member of a JavaScript object. Equivalent to
-     * "this.name" in JavaScript.
-     * </p>
-     *
-     * @param name The name of the JavaScript property to be accessed.
-     * @return The value of the propery.
-     */
-    public abstract Object getMember(String name) throws JSException;
-
-    /**
-     * <p> Sets a named member of a JavaScript object. Equivalent to
-     * "this.name = value" in JavaScript.
-     * </p>
-     *
-     * @param name The name of the JavaScript property to be accessed.
-     * @param value The value of the propery.
-     */
-    public abstract void setMember(String name, Object value) throws JSException;
-
-    /**
-     * <p> Removes a named member of a JavaScript object. Equivalent
-     * to "delete this.name" in JavaScript.
-     * </p>
-     *
-     * @param name The name of the JavaScript property to be removed.
-     */
-    public abstract void removeMember(String name) throws JSException;
-
-    /**
-     * <p> Retrieves an indexed member of a JavaScript object. Equivalent to
-     * "this[index]" in JavaScript.
-     * </p>
-     *
-     * @param index The index of the array to be accessed.
-     * @return The value of the indexed member.
-     */
-    public abstract Object getSlot(int index) throws JSException;
-
-    /**
-     * <p> Sets an indexed member of a JavaScript object. Equivalent to
-     * "this[index] = value" in JavaScript.
-     * </p>
-     *
-     * @param index The index of the array to be accessed.
-     */
-    public abstract void setSlot(int index, Object value) throws JSException;
-
-    /* *
-     * <p> Returns a JSObject for the window containing the given applet.
-     * </p>
-     *
-     * @param applet The applet.
-     * @return JSObject for the window containing the given applet.
-     * /
-    public static JSObject getWindow(Applet applet) throws JSException {
-
-        try
-        {
-            if (applet != null)
-            {
-
-                String obj = (String) applet.getParameter("MAYSCRIPT");
-
-                // Comment out MAYSCRIPT check because Internet Explorer doesn't support
-                // it.
-//              if (obj != null && (obj.equals("") || (new Boolean(obj).booleanValue() == true)))
-                {
-                    // MAYSCRIPT is enabled
-
-                    AppletContext c = applet.getAppletContext();
-
-                    // The applet context must implement the sun.plugin.javascript.JSContext
-                    // in order for us to get the handle that can be used when evaluating
-                    // JavaScript expression.
-                    //
-                    JSObject ret = null;
-
-                    if (c instanceof sun.plugin.javascript.JSContext)
-                    {
-                        JSContext j = (JSContext) c;
-                        ret = j.getJSObject();
-                    }
-
-                    if (ret != null) {
-                        return ret;
-                    }
-                }
-            } else {
-                // new code for CustomProgress to get the JSObject w/o applet
-                AppContext ac = ToolkitStore.get().getAppContext();
-                if (ac != null) {
-                    Object context = ac.get(sun.plugin2.applet.Plugin2Manager.APPCONTEXT_PLUGIN2HOST_KEY);
-                    if (context != null && (context instanceof JSContext)) {
-                        JSContext jsc = (JSContext) context;
-                        JSObject ret = jsc.getOneWayJSObject();
-                        if (ret != null) {
-                           return ret;
-                        }
-                    }
-                }
-            }
-        }
-        catch (Throwable e)
-        {
-            throw (JSException) new JSException(JSException.EXCEPTION_TYPE_ERROR, e).initCause(e);
-        }
-
-        throw new JSException();
-    }
-    */
-}