Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
Rhino JavaScript Java Library Source Code
Rhino JavaScript Java Library is an open-source implementation of JavaScript
written entirely in Java.
Rhino JavaScript Java Library Source Code files are provided in binary package (rhino-1.7.14.zip).
You can also browse the source code below:
✍: FYIcenter.com
⏎ org/mozilla/javascript/UnhandledRejectionTracker.java
package org.mozilla.javascript;
import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;
/**
* This class is responsible for handling tracking of unhandled Promise rejections. These come up
* when a Promise is either rejected or an exception is thrown and there is no "catch" handler set
* up. There is one of these tracker objects for each Context class.
*
* <p>Different frameworks will choose different ways to handle unhandled rejections. As a result,
* Rhino does nothing by default.
*
* <p>However, if "trackUnhandledPromiseRejections" is called on the Context object, then Rhino will
* track them in this object. It is the responsibility of the product embedding Rhino to
* periodically check for unhandled rejections in this class and either remove them or terminate the
* script and allow the context and its tracker to be garbage- collected.
*
* <p>Note that if "trackUnhandledPromiseRejections" is set, and rejections are not handled, then
* Promise objects will accumulate in this object and cause a memory leak.
*/
public class UnhandledRejectionTracker {
private boolean enabled = false;
private static final IdentityHashMap<NativePromise, NativePromise> unhandled =
new IdentityHashMap<>(0);
/**
* Iterate through all the rejected promises that have not yet been handled. As each promise is
* handled by this method, it is removed from this tracker and will not appear again. This is
* useful for delivering unhandled promise notifications to users one time via a callback.
*/
public void process(Consumer<Object> handler) {
Iterator<NativePromise> it = unhandled.values().iterator();
while (it.hasNext()) {
try {
handler.accept(it.next().getResult());
} finally {
// Always remove even if handler throws
it.remove();
}
}
}
/**
* Return a collection of all of the results of any unhandled rejected promises. This does not
* remove unhandled promises from the collection, but reports the current state. It is useful
* for command-line tools.
*
* @return a read-only collection of promise results. To clear them, call "process".
*/
public List<Object> enumerate() {
ArrayList<Object> ret = new ArrayList<>();
for (NativePromise result : unhandled.values()) {
ret.add(result.getResult());
}
return ret;
}
void enable(boolean enabled) {
this.enabled = enabled;
}
void promiseRejected(NativePromise p) {
if (enabled) {
unhandled.put(p, p);
}
}
void promiseHandled(NativePromise p) {
if (enabled) {
unhandled.remove(p);
}
}
}
⏎ org/mozilla/javascript/UnhandledRejectionTracker.java
Or download all of them as a single archive file:
File name: rhino-1.7.14-sources.jar File size: 1029165 bytes Release date: 2022-01-06 Download
⇒ Example code to Test rhino-runtime-1.7.14.jar
⇐ Download Rhino JavaScript Binary Package
2022-05-03, ≈209🔥, 1💬
Popular Posts:
Smack is an Open Source XMPP (Jabber) client library for instant messaging and presence. A pure Java...
JDK 11 java.security.jgss.jmod is the JMOD file for JDK 11 Security JGSS (Java Generic Security Serv...
JDK 17 java.sql.rowset.jmod is the JMOD file for JDK 17 SQL Rowset module. JDK 17 SQL Rowset module ...
maven-settings-builder-3 .8.6.jaris the JAR file for Apache Maven 3.8.6 Settings Builder module. Apa...
JLayer is a library that decodes/plays/converts MPEG 1/2/2.5 Layer 1/2/3 (i.e. MP3) in real time for...