public static IRScope loadScriptFromFile(Ruby runtime, InputStream inStream, File resourcePath, String resourceName, boolean isAbsolute) { String name = getFilenameFromPathAndName(resourcePath, resourceName, isAbsolute); try { Class clazz = loadCompiledScriptFromClass(runtime, inStream); try { Method method = clazz.getMethod("loadIR", Ruby.class, String.class); return (IRScope)method.invoke(null, runtime, name); } catch (Exception e) { if (runtime.getDebug().isTrue()) { e.printStackTrace(); } throw runtime.newLoadError(name + " is not compiled Ruby; use java_import to load normal classes"); } } catch (IOException e) { throw runtime.newIOErrorFromException(e); } catch (LinkageError le) { if (runtime.getDebug().isTrue()) { le.printStackTrace(); } throw runtime.newLoadError("Linkage error loading compiled script; you may need to recompile '" + name + "': " + le); } finally { try { inStream.close(); } catch (IOException ioe) { throw runtime.newIOErrorFromException(ioe); } } }
public static IRScope loadScriptFromFile(Ruby runtime, InputStream inStream, File resourcePath, String resourceName, boolean isAbsolute) { String name = getFilenameFromPathAndName(resourcePath, resourceName, isAbsolute); try { Class clazz = loadCompiledScriptFromClass(runtime, inStream); try { Method method = clazz.getMethod("loadIR", Ruby.class, String.class); return (IRScope)method.invoke(null, runtime, name); } catch (Exception e) { if (runtime.getDebug().isTrue()) { e.printStackTrace(); } throw runtime.newLoadError(name + " is not compiled Ruby; use java_import to load normal classes"); } } catch (IOException e) { throw runtime.newIOErrorFromException(e); } catch (LinkageError le) { if (runtime.getDebug().isTrue()) { le.printStackTrace(); } throw runtime.newLoadError("Linkage error loading compiled script; you may need to recompile '" + name + "': " + le); } finally { try { inStream.close(); } catch (IOException ioe) { throw runtime.newIOErrorFromException(ioe); } } }
public void load(Ruby runtime, boolean wrap) { InputStream in = null; try { in = resource.getInputStream(); String name = resource.getName(); if (runtime.getInstanceConfig().getCompileMode().shouldPrecompileAll()) { runtime.compileAndLoadFile(name, in, wrap); } else { name = CompiledScriptLoader.getFilenameFromPathAndName(resource.getPath(), name, resource.isAbsolute()); runtime.loadFile(name, new LoadServiceResourceInputStream(in), wrap); } } catch (IOException e) { throw runtime.newIOErrorFromException(e); } finally { try { in.close(); } catch (Exception ex) {} } }
public void load(Ruby runtime, boolean wrap) { InputStream in = null; try { in = resource.getInputStream(); String name = resource.getName(); if (runtime.getInstanceConfig().getCompileMode().shouldPrecompileAll()) { runtime.compileAndLoadFile(name, in, wrap); } else { name = CompiledScriptLoader.getFilenameFromPathAndName(resource.getPath(), name, resource.isAbsolute()); runtime.loadFile(name, new LoadServiceResourceInputStream(in), wrap); } } catch (IOException e) { throw runtime.newIOErrorFromException(e); } finally { try { in.close(); } catch (Exception ex) {} } }