/** * Parses a script given by a input stream and return an object which can be run(). * This allows the script to be parsed once and evaluated many times. * * @param bundle is where the script is located * @param path is the entry in the bundle. * @param lines are linenumbers to display for parse errors and backtraces. * This field is optional. Only the first argument is used for parsing. * When no line number is specified, 0 is applied to. * @return an object which can be run */ public EmbedEvalUnit parse(Bundle bundle, String path, int... lines) throws IOException { URL url = bundle.getEntry(path); InputStream istream = null; try { istream = new BufferedInputStream(url.openStream()); return super.parse(istream, getFilename(bundle, path)); } catch (IOException ioe) { throw new EvalFailedException(ioe); } finally { if (istream != null) try { istream.close(); } catch (IOException ioe) {}; } }
@Test public void testThrowRuntimeExceptionStringArg() throws Exception { try { script(new GroovyLang(), "throwable/Throwable", "throwRuntimeExceptionStringArg").run(); fail(); } catch (RuntimeException e) { assertEquals("foobar", e.getMessage()); } try { script(new JavaScriptLang(), "throwable/Throwable", "throwRuntimeExceptionStringArg").run(); fail(); } catch (ScriptException e) { assertTrue(e.getMessage().contains("foobar")); } try { script(new RubyLang(), "throwable/Throwable", "throwRuntimeExceptionStringArg").run(); fail(); } catch (EvalFailedException e) { assertTrue(e.getMessage().contains("foobar")); } try { script(new ScalaLang(), "throwable/Throwable", "throwRuntimeExceptionStringArg").run(); fail(); } catch (RuntimeException e) { assertTrue(e.getMessage().contains("foobar")); } }
/** * Parses a script given by a input stream and return an object which can be run(). * This allows the script to be parsed once and evaluated many times. * * @param bundle is where the script is located * @param path is the entry in the bundle. * @param lines are linenumbers to display for parse errors and backtraces. * This field is optional. Only the first argument is used for parsing. * When no line number is specified, 0 is applied to. * @return an object which can be run */ public EmbedEvalUnit parse(Bundle bundle, String path, int... lines) throws IOException { URL url = bundle.getEntry(path); InputStream istream = null; try { istream = new BufferedInputStream(url.openStream()); return super.parse(istream, getFilename(bundle, path)); } catch (IOException ioe) { throw new EvalFailedException(ioe); } finally { if (istream != null) try { istream.close(); } catch (IOException ioe) {}; } }
/** * Parses a script given by a input stream and return an object which can be run(). * This allows the script to be parsed once and evaluated many times. * * @param bundle is where the script is located * @param path is the entry in the bundle. * @param lines are linenumbers to display for parse errors and backtraces. * This field is optional. Only the first argument is used for parsing. * When no line number is specified, 0 is applied to. * @return an object which can be run */ public EmbedEvalUnit parse(Bundle bundle, String path, int... lines) throws IOException { URL url = bundle.getEntry(path); InputStream istream = null; try { istream = new BufferedInputStream(url.openStream()); return super.parse(istream, getFilename(bundle, path)); } catch (IOException ioe) { throw new EvalFailedException(ioe); } finally { if (istream != null) try { istream.close(); } catch (IOException ioe) {}; } }
/** * Parses a script given by a input stream and return an object which can be run(). * This allows the script to be parsed once and evaluated many times. * * @param bundle is where the script is located * @param path is the entry in the bundle. * @param lines are linenumbers to display for parse errors and backtraces. * This field is optional. Only the first argument is used for parsing. * When no line number is specified, 0 is applied to. * @return an object which can be run */ public EmbedEvalUnit parse(Bundle bundle, String path, int... lines) throws IOException { URL url = bundle.getEntry(path); InputStream istream = null; try { istream = new BufferedInputStream(url.openStream()); return super.parse(istream, getFilename(bundle, path)); } catch (IOException ioe) { throw new EvalFailedException(ioe); } finally { if (istream != null) try { istream.close(); } catch (IOException ioe) {}; } }
/** * @param bundle The bundle where the script is located. Lazily added to the * loader of the OSGiScriptingContainer. (require bundle:/... is implicitly done here) * @param path The entry in the bundle * @return */ public Object runScriptlet(Bundle bundle, String path) { URL url = bundle.getEntry(path); if (url == null) { throw new IllegalArgumentException("Unable to find the entry '" + path + "' in the bundle " + bundle.getSymbolicName()); } addToClassPath(bundle); InputStream istream = null; try { istream = new BufferedInputStream(url.openStream()); return this.runScriptlet(istream, getFilename(bundle, path)); } catch (IOException ioe) { throw new EvalFailedException(ioe); } finally { if (istream != null) try { istream.close(); } catch (IOException ioe) {}; } }
/** * @param bundle The bundle where the script is located. Lazily added to the * loader of the OSGiScriptingContainer. (require bundle:/... is implicitly done here) * @param path The entry in the bundle * @return */ public Object runScriptlet(Bundle bundle, String path) { URL url = bundle.getEntry(path); if (url == null) { throw new IllegalArgumentException("Unable to find the entry '" + path + "' in the bundle " + bundle.getSymbolicName()); } addToClassPath(bundle); InputStream istream = null; try { istream = new BufferedInputStream(url.openStream()); return this.runScriptlet(istream, getFilename(bundle, path)); } catch (IOException ioe) { throw new EvalFailedException(ioe); } finally { if (istream != null) try { istream.close(); } catch (IOException ioe) {}; } }
/** * @param bundle The bundle where the script is located. Lazily added to the * loader of the OSGiScriptingContainer. (require bundle:/... is implicitly done here) * @param path The entry in the bundle * @return */ public Object runScriptlet(Bundle bundle, String path) { URL url = bundle.getEntry(path); if (url == null) { throw new IllegalArgumentException("Unable to find the entry '" + path + "' in the bundle " + bundle.getSymbolicName()); } addToClassPath(bundle); InputStream istream = null; try { istream = new BufferedInputStream(url.openStream()); return this.runScriptlet(istream, getFilename(bundle, path)); } catch (IOException ioe) { throw new EvalFailedException(ioe); } finally { if (istream != null) try { istream.close(); } catch (IOException ioe) {}; } }
/** * @param bundle The bundle where the script is located. Lazily added to the * loader of the OSGiScriptingContainer. (require bundle:/... is implicitly done here) * @param path The entry in the bundle * @return */ public Object runScriptlet(Bundle bundle, String path) { URL url = bundle.getEntry(path); if (url == null) { throw new IllegalArgumentException("Unable to find the entry '" + path + "' in the bundle " + bundle.getSymbolicName()); } addToClassPath(bundle); InputStream istream = null; try { istream = new BufferedInputStream(url.openStream()); return this.runScriptlet(istream, getFilename(bundle, path)); } catch (IOException ioe) { throw new EvalFailedException(ioe); } finally { if (istream != null) try { istream.close(); } catch (IOException ioe) {}; } }
throw new EvalFailedException(e.getMessage(), e); throw new EvalFailedException(e);
throw new EvalFailedException(e.getMessage(), e); throw new EvalFailedException(e);
throw new EvalFailedException(e.getMessage(), e); } catch (StackOverflowError soe) { throw runtime.newSystemStackError("stack level too deep", soe); } catch (Throwable e) { throw new EvalFailedException(e); } finally { if (sharing_variables) {
throw new EvalFailedException(e.getMessage(), e); } catch (StackOverflowError soe) { throw runtime.newSystemStackError("stack level too deep", soe); } catch (Throwable e) { throw new EvalFailedException(e); } finally { if (sharing_variables) {