nashorn/docs/source/RunnableImplObject.java
changeset 27361 86c4ddb4797b
parent 16212 363737d0d757
--- a/nashorn/docs/source/RunnableImplObject.java	Mon Nov 03 09:49:52 2014 +0100
+++ b/nashorn/docs/source/RunnableImplObject.java	Mon Nov 03 11:47:41 2014 +0100
@@ -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();
     }