-
Notifications
You must be signed in to change notification settings - Fork 464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8337280: Include jdk.jsobject module with JavaFX #1529
Open
kevinrushforth
wants to merge
11
commits into
openjdk:master
Choose a base branch
from
kevinrushforth:8337280-jsobject
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+334
−19
Open
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1abb538
8337280: Include jdk.jsobject module with JavaFX
kevinrushforth 83ce053
Update to pick up latest version from jdk master
kevinrushforth 1891887
Merge branch 'master' into 8337280-jsobject
kevinrushforth 33355b4
Update copyright years
kevinrushforth d37e3af
Merge branch 'master' into 8337280-jsobject
kevinrushforth d5c5bd5
Merge branch 'master' into 8337280-jsobject
kevinrushforth 182fb1f
Merge branch 'master' into 8337280-jsobject
kevinrushforth bb9a3b6
Update copyright year in settings.gradle
kevinrushforth 6cec839
Merge branch 'master' into 8337280-jsobject
kevinrushforth 2c00deb
Use --upgrade-module-path when compiling or running tests on JDK 24 o…
kevinrushforth 6bfc99a
Merge branch 'master' into 8337280-jsobject
kevinrushforth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2016, 2024, 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. | ||
*/ | ||
|
||
/** | ||
* Defines the API for the JavaScript Object. | ||
* | ||
* @moduleGraph | ||
* @since 9 | ||
*/ | ||
module jdk.jsobject { | ||
exports netscape.javascript; | ||
} |
61 changes: 61 additions & 0 deletions
61
modules/jdk.jsobject/src/main/java/netscape/javascript/JSException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (c) 2006, 2024, 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; | ||
|
||
/** | ||
* Thrown when an exception is raised in the JavaScript engine. This is merely | ||
* a marker class to indicate an exception relating to the JavaScript | ||
* interface. | ||
* @since 1.5 | ||
*/ | ||
public class JSException extends RuntimeException { | ||
private static final long serialVersionUID = 2778103758223661489L; | ||
|
||
/** | ||
* Constructs a new JavaScript exception with null as it's detail message. | ||
*/ | ||
public JSException() { | ||
super(); | ||
} | ||
|
||
/** | ||
* Construct a new JavaScript exception with the specified detail message. | ||
* | ||
* @param s The detail message | ||
*/ | ||
public JSException(String s) { | ||
super(s); | ||
} | ||
|
||
/** | ||
* Construct a new JavaScript exception with the specified cause. | ||
* | ||
* @param t Throwable cause | ||
*/ | ||
public JSException(Throwable t) { | ||
super(t); | ||
} | ||
} |
139 changes: 139 additions & 0 deletions
139
modules/jdk.jsobject/src/main/java/netscape/javascript/JSObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
/* | ||
* Copyright (c) 2006, 2024, 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; | ||
|
||
/** | ||
* <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}. When a | ||
* {@code JSObject} instance is passed to the JavaScript engine, | ||
* it is unwrapped back to its original JavaScript object. The | ||
* {@code JSObject} 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. | ||
* </p> | ||
* @since 1.5 | ||
*/ | ||
public abstract class JSObject { | ||
|
||
static { | ||
System.err.println("KCR: JavaFX version of jdk.jsobject loaded"); | ||
} | ||
|
||
/** | ||
* Constructs a new JSObject. Users should neither call this method nor | ||
* subclass JSObject. | ||
*/ | ||
protected JSObject() { | ||
} | ||
|
||
/** | ||
* Calls a JavaScript method. Equivalent to | ||
* "this.methodName(args[0], args[1], ...)" in JavaScript. | ||
* | ||
* @param methodName The name of the JavaScript method to be invoked. | ||
* @param args the Java objects passed as arguments to the method. | ||
* @return Result of the method. | ||
* @throws JSException when an error is reported from the browser or | ||
* JavaScript engine. | ||
*/ | ||
public abstract Object call(String methodName, Object... args) throws JSException; | ||
|
||
/** | ||
* Evaluates a JavaScript expression. The expression is a string of | ||
* JavaScript source code which will be evaluated in the context given by | ||
* "this". | ||
* | ||
* @param s The JavaScript expression. | ||
* @return Result of the JavaScript evaluation. | ||
* @throws JSException when an error is reported from the browser or | ||
* JavaScript engine. | ||
*/ | ||
public abstract Object eval(String s) throws JSException; | ||
|
||
/** | ||
* Retrieves a named member of a JavaScript object. Equivalent to | ||
* "this.name" in JavaScript. | ||
* | ||
* @param name The name of the JavaScript property to be accessed. | ||
* @return The value of the property. | ||
* @throws JSException when an error is reported from the browser or | ||
* JavaScript engine. | ||
*/ | ||
public abstract Object getMember(String name) throws JSException; | ||
|
||
/** | ||
* Sets a named member of a JavaScript object. Equivalent to | ||
* "this.name = value" in JavaScript. | ||
* | ||
* @param name The name of the JavaScript property to be accessed. | ||
* @param value The value of the property. | ||
* @throws JSException when an error is reported from the browser or | ||
* JavaScript engine. | ||
*/ | ||
public abstract void setMember(String name, Object value) throws JSException; | ||
|
||
/** | ||
* Removes a named member of a JavaScript object. Equivalent | ||
* to "delete this.name" in JavaScript. | ||
* | ||
* @param name The name of the JavaScript property to be removed. | ||
* @throws JSException when an error is reported from the browser or | ||
* JavaScript engine. | ||
*/ | ||
public abstract void removeMember(String name) throws JSException; | ||
|
||
/** | ||
* Retrieves an indexed member of a JavaScript object. Equivalent to | ||
* "this[index]" in JavaScript. | ||
* | ||
* @param index The index of the array to be accessed. | ||
* @return The value of the indexed member. | ||
* @throws JSException when an error is reported from the browser or | ||
* JavaScript engine. | ||
*/ | ||
public abstract Object getSlot(int index) throws JSException; | ||
|
||
/** | ||
* Sets an indexed member of a JavaScript object. Equivalent to | ||
* "this[index] = value" in JavaScript. | ||
* | ||
* @param index The index of the array to be accessed. | ||
* @param value The value to set | ||
* @throws JSException when an error is reported from the browser or | ||
* JavaScript engine. | ||
*/ | ||
public abstract void setSlot(int index, Object value) throws JSException; | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
modules/jdk.jsobject/src/main/java/netscape/javascript/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2008, 2024, 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. | ||
*/ | ||
|
||
/** | ||
* <p> | ||
* Provides Java code the ability to access the JavaScript engine and the | ||
* HTML DOM in the web browser. | ||
* </p> | ||
* | ||
* <p> | ||
* The classes in this package were initially specified by Netscape, and are the | ||
* de facto standard mechanism for calling JavaScript from the Java runtime. | ||
* </p> | ||
* | ||
* @since 1.5 | ||
*/ | ||
|
||
package netscape.javascript; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The update to copyright year has been reverted by commit 33355b4. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't remember why I did that, but I'll redo the change to 2024. Thanks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This debug print statement is there to make it easy to see if the JavaFX version of this class is being loaded. I'll leave it during testing and review, but I'll remove it before the final review.