-
Notifications
You must be signed in to change notification settings - Fork 892
Preparation for liveconnect separation #1983
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
base: master
Are you sure you want to change the base?
Conversation
rhino-tools/src/main/java/org/mozilla/javascript/tools/shell/Global.java
Dismissed
Show dismissed
Hide dismissed
Thanks -- I'll look at the various bits as they get implemented. I think this is an important evolution, as it makes the core of Rhino more compact and less vulnerable to exploits. We spent some time naming modules when we created the module structure, and I think it's important that the main module continue to be named "rhino" and not "rhino-core". The new module could be named "rhino-liveconnect," or "rhino-reflection" or "rhino-java-integration", I'm curious to hear other suggestions! |
1, | ||
Shell::help, | ||
ScriptableObject.PERMANENT | ScriptableObject.DONTENUM, | ||
ScriptableObject.DONTENUM); |
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.
missing quit
?
|
||
shell.defineProperty( |
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.
Is it possible to make a bulk registeration? Like so:
var properties = Map.<String, SomeFunction>of(
"print", Shell::print,
"quit", Shell::quit,
"version", Shell::version,
"load", Shell::load,
"help", Shell::help
);
for (var entry : properties.entrySet()) {
// define property, but how to determine the "length"?
}
It should be easier to read and maintain
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.
please see https://github.com/mozilla/rhino/pull/1993/files
If static import is used, it would match in one line.
but maybe it makes sense to replace
defineProperty(this, "defineClass", 1, Global::defineClass, DONTENUM, DONTENUM | READONLY)
by
defineFunctionProperty(this, "defineClass", 1, Global::defineClass)
}; | ||
defineFunctionProperties(names, Global.class, ScriptableObject.DONTENUM); | ||
|
||
defineProperty( |
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.
Same as Shell
, bulk registration would be nice
package org.mozilla.javascript; | ||
|
||
/** Classes, that implement this interface are treated as equal, when <code>o1.equals(o2)</code> */ | ||
public interface JavaEquals {} |
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.
how about adding a common SpecialEquality
interface for JavaEquals
and StatelessEquals
:
interface SpecialEquality {
boolean rhino$equals(Object o);
interface JavaEquals extends SpecialEquality {
default boolean rhino$equals(Object o) {
return this.equals(o);
}
}
}
Then in the future, we can handle objects with new special equality without having to modify EqualObjectGraphs
code (by adding interface implementation)
@@ -280,22 +281,27 @@ public static ScriptableObject initStandardObjects( | |||
|
|||
// These depend on the legacy initialization behavior of the lazy loading mechanism | |||
new LazilyLoadedCtor( | |||
s, "Packages", "org.mozilla.javascript.NativeJavaTopPackage", sealed, true); | |||
s, "Packages", "org.mozilla.javascript.lc.java.NativeJavaTopPackage", sealed, true); |
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.
Can we move them to LcBridge.instance.init(...)
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.
yes, I'll put that on my to-do list
Hello,
I've once again tried to identify the classes required for LiveConnect and move them into their own package.
This PR is intended to convey the rough plan. I assume it won't be merged in this form.
However, I would like to update it from time to time to document the current progress.
What's this actually about:
In my vision, Rhino should be divided into a core part (e.g.,
rhino
) and a part that enables interactions with other Java classes (e.g.,rhino-liveconnect
).rhino-core
should be as free from reflection as possible (which is already largely possible thanks to the good work done recently in the Lambda area) - all these classes are moved to thelc.java
package now (Maybe the name will change)The advantages I expect from this:
rhino-core
rhino
andrhino-liveconnect
allows for a leaner versionDisadvantage
As described above, I will try to split the PR into several smaller PRs. e.g
BTW: This looks promising now. Test262 will run without LiveConnect classes