changeset 11355:c3edf3d8f233

8152950: BasicLauncherTest.java fails due to type error Summary: Better handle js engine initialization error Reviewed-by: jbachorik
author dsamersoff
date Fri, 27 May 2016 19:31:17 +0300
parents a82343dd37c3
children 63c2576a3eb3
files src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java	Fri May 27 05:49:24 2016 -0700
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java	Fri May 27 19:31:17 2016 +0300
@@ -1712,7 +1712,8 @@
     // called after debuggee attach
     private void postAttach() {
         // create JavaScript engine and start it
-        jsengine = new JSJavaScriptEngine() {
+        try {
+            jsengine = new JSJavaScriptEngine() {
                         private ObjectReader reader = new ObjectReader();
                         private JSJavaFactory factory = new JSJavaFactoryImpl();
                         public ObjectReader getObjectReader() {
@@ -1735,17 +1736,24 @@
                             return err;
                         }
                    };
-        try {
-            jsengine.defineFunction(this,
+            try {
+                jsengine.defineFunction(this,
                      this.getClass().getMethod("registerCommand",
                                 new Class[] {
                                      String.class, String.class, String.class
                                 }));
-        } catch (NoSuchMethodException exp) {
-            // should not happen, see below...!!
-            exp.printStackTrace();
+            } catch (NoSuchMethodException exp) {
+                  // should not happen, see below...!!
+                  exp.printStackTrace();
+            }
+            jsengine.start();
         }
-        jsengine.start();
+        catch (Exception ex) {
+            System.out.println("Warning! JS Engine can't start, some commands will not be available.");
+            if (verboseExceptions) {
+                ex.printStackTrace(out);
+            }
+        }
     }
 
     public void registerCommand(String cmd, String usage, final String func) {