aboutsummaryrefslogtreecommitdiff
path: root/docs/source
diff options
context:
space:
mode:
authorlagergren <none@none>2014-11-03 11:47:41 +0100
committerlagergren <none@none>2014-11-03 11:47:41 +0100
commite4325507fd3bf9d3d27d485388bbb23e24c44e51 (patch)
treea86f170ee765afe55266506b1d0e7df3f9d19e45 /docs/source
parenta2983b148c3190d7732e527a2951566c55e5bccc (diff)
downloadnashorn-e4325507fd3bf9d3d27d485388bbb23e24c44e51.tar.gz
8060204: Fix warnings in Joni and tests
Reviewed-by: hannesw, sundar, attila
Diffstat (limited to 'docs/source')
-rw-r--r--docs/source/EvalFile.java10
-rw-r--r--docs/source/EvalScript.java10
-rw-r--r--docs/source/InvokeScriptFunction.java15
-rw-r--r--docs/source/InvokeScriptMethod.java17
-rw-r--r--docs/source/MultiScopes.java17
-rw-r--r--docs/source/RunnableImpl.java19
-rw-r--r--docs/source/RunnableImplObject.java21
-rw-r--r--docs/source/ScriptVars.java14
8 files changed, 73 insertions, 50 deletions
diff --git a/docs/source/EvalFile.java b/docs/source/EvalFile.java
index 6bb4e381..b12e91bb 100644
--- a/docs/source/EvalFile.java
+++ b/docs/source/EvalFile.java
@@ -29,14 +29,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import javax.script.*;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+@SuppressWarnings("javadoc")
public class EvalFile {
- public static void main(String[] args) throws Exception {
+ public static void main(final String[] args) throws Exception {
// create a script engine manager
- ScriptEngineManager factory = new ScriptEngineManager();
+ final ScriptEngineManager factory = new ScriptEngineManager();
// create JavaScript engine
- ScriptEngine engine = factory.getEngineByName("nashorn");
+ final ScriptEngine engine = factory.getEngineByName("nashorn");
// evaluate JavaScript code from given file - specified by first argument
engine.eval(new java.io.FileReader(args[0]));
}
diff --git a/docs/source/EvalScript.java b/docs/source/EvalScript.java
index 7fcbe1cd..49f581de 100644
--- a/docs/source/EvalScript.java
+++ b/docs/source/EvalScript.java
@@ -29,14 +29,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import javax.script.*;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+@SuppressWarnings("javadoc")
public class EvalScript {
- public static void main(String[] args) throws Exception {
+ public static void main(final String[] args) throws Exception {
// create a script engine manager
- ScriptEngineManager factory = new ScriptEngineManager();
+ final ScriptEngineManager factory = new ScriptEngineManager();
// create a JavaScript engine
- ScriptEngine engine = factory.getEngineByName("nashorn");
+ final ScriptEngine engine = factory.getEngineByName("nashorn");
// evaluate JavaScript code from String
engine.eval("print('Hello, World')");
}
diff --git a/docs/source/InvokeScriptFunction.java b/docs/source/InvokeScriptFunction.java
index 26de36c4..5ce1cae0 100644
--- a/docs/source/InvokeScriptFunction.java
+++ b/docs/source/InvokeScriptFunction.java
@@ -29,22 +29,25 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import javax.script.*;
+import javax.script.Invocable;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+@SuppressWarnings("javadoc")
public class InvokeScriptFunction {
- public static void main(String[] args) throws Exception {
- ScriptEngineManager manager = new ScriptEngineManager();
- ScriptEngine engine = manager.getEngineByName("nashorn");
+ public static void main(final String[] args) throws Exception {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ final ScriptEngine engine = manager.getEngineByName("nashorn");
// JavaScript code in a String
- String script = "function hello(name) { print('Hello, ' + name); }";
+ final String script = "function hello(name) { print('Hello, ' + name); }";
// evaluate script
engine.eval(script);
// javax.script.Invocable is an optional interface.
// Check whether your script engine implements or not!
// Note that the JavaScript engine implements Invocable interface.
- Invocable inv = (Invocable) engine;
+ final Invocable inv = (Invocable) engine;
// invoke the global function named "hello"
inv.invokeFunction("hello", "Scripting!!" );
diff --git a/docs/source/InvokeScriptMethod.java b/docs/source/InvokeScriptMethod.java
index a3f5ece7..d3cc788d 100644
--- a/docs/source/InvokeScriptMethod.java
+++ b/docs/source/InvokeScriptMethod.java
@@ -29,26 +29,29 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import javax.script.*;
+import javax.script.Invocable;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+@SuppressWarnings("javadoc")
public class InvokeScriptMethod {
- public static void main(String[] args) throws Exception {
- ScriptEngineManager manager = new ScriptEngineManager();
- ScriptEngine engine = manager.getEngineByName("nashorn");
+ public static void main(final String[] args) throws Exception {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ final ScriptEngine engine = manager.getEngineByName("nashorn");
// JavaScript code in a String. This code defines a script object 'obj'
// with one method called 'hello'.
- String script = "var obj = new Object(); obj.hello = function(name) { print('Hello, ' + name); }";
+ final String script = "var obj = new Object(); obj.hello = function(name) { print('Hello, ' + name); }";
// evaluate script
engine.eval(script);
// javax.script.Invocable is an optional interface.
// Check whether your script engine implements or not!
// Note that the JavaScript engine implements Invocable interface.
- Invocable inv = (Invocable) engine;
+ final Invocable inv = (Invocable) engine;
// get script object on which we want to call the method
- Object obj = engine.get("obj");
+ final Object obj = engine.get("obj");
// invoke the method named "hello" on the script object "obj"
inv.invokeMethod(obj, "hello", "Script Method !!" );
diff --git a/docs/source/MultiScopes.java b/docs/source/MultiScopes.java
index 6c4fa2a2..ff4f65b4 100644
--- a/docs/source/MultiScopes.java
+++ b/docs/source/MultiScopes.java
@@ -29,12 +29,17 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import javax.script.*;
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.SimpleScriptContext;
+@SuppressWarnings("javadoc")
public class MultiScopes {
- public static void main(String[] args) throws Exception {
- ScriptEngineManager manager = new ScriptEngineManager();
- ScriptEngine engine = manager.getEngineByName("nashorn");
+ public static void main(final String[] args) throws Exception {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ final ScriptEngine engine = manager.getEngineByName("nashorn");
engine.put("x", "hello");
// print global variable "x"
@@ -42,9 +47,9 @@ public class MultiScopes {
// the above line prints "hello"
// Now, pass a different script context
- ScriptContext newContext = new SimpleScriptContext();
+ final ScriptContext newContext = new SimpleScriptContext();
newContext.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE);
- Bindings engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE);
+ final Bindings engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE);
// add new variable "x" to the new engineScope
engineScope.put("x", "world");
diff --git a/docs/source/RunnableImpl.java b/docs/source/RunnableImpl.java
index 1d858d40..2b5113b1 100644
--- a/docs/source/RunnableImpl.java
+++ b/docs/source/RunnableImpl.java
@@ -29,28 +29,31 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import javax.script.*;
+import javax.script.Invocable;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+@SuppressWarnings("javadoc")
public class RunnableImpl {
- public static void main(String[] args) throws Exception {
- ScriptEngineManager manager = new ScriptEngineManager();
- ScriptEngine engine = manager.getEngineByName("nashorn");
+ public static void main(final String[] args) throws Exception {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ final ScriptEngine engine = manager.getEngineByName("nashorn");
// JavaScript code in a String
- String script = "function run() { print('run called'); }";
+ final String script = "function run() { print('run called'); }";
// evaluate script
engine.eval(script);
- Invocable inv = (Invocable) engine;
+ final Invocable inv = (Invocable) engine;
// get Runnable interface object from engine. This interface methods
// are implemented by script functions with the matching name.
- Runnable r = inv.getInterface(Runnable.class);
+ final Runnable r = inv.getInterface(Runnable.class);
// start a new thread that runs the script implemented
// runnable interface
- Thread th = new Thread(r);
+ final Thread th = new Thread(r);
th.start();
th.join();
}
diff --git a/docs/source/RunnableImplObject.java b/docs/source/RunnableImplObject.java
index 877f8c15..0d5f5032 100644
--- a/docs/source/RunnableImplObject.java
+++ b/docs/source/RunnableImplObject.java
@@ -29,31 +29,34 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import javax.script.*;
+import javax.script.Invocable;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+@SuppressWarnings("javadoc")
public class RunnableImplObject {
- public static void main(String[] args) throws Exception {
- ScriptEngineManager manager = new ScriptEngineManager();
- ScriptEngine engine = manager.getEngineByName("nashorn");
+ public static void main(final String[] args) throws Exception {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ final ScriptEngine engine = manager.getEngineByName("nashorn");
// JavaScript code in a String
- String script = "var obj = new Object(); obj.run = function() { print('run method called'); }";
+ final String script = "var obj = new Object(); obj.run = function() { print('run method called'); }";
// evaluate script
engine.eval(script);
// get script object on which we want to implement the interface with
- Object obj = engine.get("obj");
+ final Object obj = engine.get("obj");
- Invocable inv = (Invocable) engine;
+ final Invocable inv = (Invocable) engine;
// get Runnable interface object from engine. This interface methods
// are implemented by script methods of object 'obj'
- Runnable r = inv.getInterface(obj, Runnable.class);
+ final Runnable r = inv.getInterface(obj, Runnable.class);
// start a new thread that runs the script implemented
// runnable interface
- Thread th = new Thread(r);
+ final Thread th = new Thread(r);
th.start();
th.join();
}
diff --git a/docs/source/ScriptVars.java b/docs/source/ScriptVars.java
index 7e16cfca..c697431d 100644
--- a/docs/source/ScriptVars.java
+++ b/docs/source/ScriptVars.java
@@ -29,15 +29,17 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import javax.script.*;
-import java.io.*;
+import java.io.File;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+@SuppressWarnings("javadoc")
public class ScriptVars {
- public static void main(String[] args) throws Exception {
- ScriptEngineManager manager = new ScriptEngineManager();
- ScriptEngine engine = manager.getEngineByName("nashorn");
+ public static void main(final String[] args) throws Exception {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ final ScriptEngine engine = manager.getEngineByName("nashorn");
- File f = new File("test.txt");
+ final File f = new File("test.txt");
// expose File object as variable to script
engine.put("file", f);