8152950: BasicLauncherTest.java fails due to type error

Better handle js engine initialization error

Reviewed-by: jbachorik
This commit is contained in:
Dmitry Samersoff 2016-05-27 19:31:17 +03:00
parent e5e41a2375
commit 0cf2e90d17

View File

@ -1712,7 +1712,8 @@ public class CommandProcessor {
// called after debuggee attach // called after debuggee attach
private void postAttach() { private void postAttach() {
// create JavaScript engine and start it // create JavaScript engine and start it
jsengine = new JSJavaScriptEngine() { try {
jsengine = new JSJavaScriptEngine() {
private ObjectReader reader = new ObjectReader(); private ObjectReader reader = new ObjectReader();
private JSJavaFactory factory = new JSJavaFactoryImpl(); private JSJavaFactory factory = new JSJavaFactoryImpl();
public ObjectReader getObjectReader() { public ObjectReader getObjectReader() {
@ -1735,17 +1736,24 @@ public class CommandProcessor {
return err; return err;
} }
}; };
try { try {
jsengine.defineFunction(this, jsengine.defineFunction(this,
this.getClass().getMethod("registerCommand", this.getClass().getMethod("registerCommand",
new Class[] { new Class[] {
String.class, String.class, String.class String.class, String.class, String.class
})); }));
} catch (NoSuchMethodException exp) { } catch (NoSuchMethodException exp) {
// should not happen, see below...!! // should not happen, see below...!!
exp.printStackTrace(); exp.printStackTrace();
}
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);
}
} }
jsengine.start();
} }
public void registerCommand(String cmd, String usage, final String func) { public void registerCommand(String cmd, String usage, final String func) {