Description of the Script API running on JVM, jvmscriptapi description
Basic API description
Other languages can be executed on jvm. A script engine is required to execute other languages. JDK provides related APIs.
This API is suitable for any language that can run on the JVM.
· ScriptEngine is a script execution engine used to execute specified scripts. Based on several eval rewriting forms, you can know that it can be used to execute a script in the string form, or read the script from the file stream and then execute it.
· Bindings is actually an implementation class of java. util. Map. In the Script API, bindings is used to store data that can be used for Script execution.
· ScriptContext: The execution Context of the script. From the class diagram above, we can see that the Context is divided into two types: globalScope and engin.pdf. Some data is used when the script is executed using ScriptEngine, the data may be stored in globalScope or enginscope. The data in globalScope can be used by all ScriptEngine running on the JVM, and enginelist applies to a certain ScriptEngine.
· ScriptEngineFactory is a ScriptEngine factory used to create a ScriptEngine object. Generally, we do not directly use it, but use ScriptEngineManager.
· ScriptEngineManager manages all Script APIs. You can use it to create a ScriptEngine object in three ways ). GlobalScope is also maintained.
Function call APIInvocable Interface
The interface provides four methods,
InvokeFunction is used to call the methods below the global object.
InvokedMethod is used to call a method of an object in the Script.
The following example calls the Javascript global function:
The following example shows how to call a custom object in JavaScript:
For java interfaces, we can also use the Script language to write the implementation classes of Java interfaces.
This is rarely used.
What does JVM mean by APIs in Java?
JVM is a virtual machine. You can understand SUN as an independent machine that can execute JAVA programs without programmers thinking about the specific hardware.
Application Programming Interface (AP) is a number of predefined functions to provide applications and developers with the ability to access a group of routines based on a software or hardware, without accessing the source code or understanding the details of the internal working mechanism. Specifically, APIs are some programs and instructions developed by SUN. Generally, Apis only refer to reference documents in a narrow sense.
Where is the Java Script API?
Sent