Package org.jruby.embed
Class ScriptingContainer
java.lang.Object
org.jruby.embed.ScriptingContainer
- All Implemented Interfaces:
EmbedRubyInstanceConfigAdapter
- Direct Known Subclasses:
IsolatedScriptingContainer
,OSGiScriptingContainer
ScriptingContainer provides various methods and resources that are useful
for embedding Ruby in Java. Using this class, users can run Ruby scripts from
Java programs easily. Also, users can use methods defined or implemented by Ruby.
ScriptingContainer allows users to set various configuration parameters.
Some of them are per-container properties, while others are per-evaluation attributes.
For example, a local context scope, local variable behavior, load paths are
per-container properties. Please see
PropertyName
and AttributeName
for more details. Be aware that the per-container properties should be set prior to
get Ruby runtime being instantiated; otherwise, default values are applied to.
ScriptingContainer delays Ruby runtime initialization as much as possible to
improve startup time. When values are put into the ScriptingContainer, or runScriptlet
method gets run the runtime is created internally. However, the default, singleton
local context scope behave slightly different. If a Ruby runtime has been already
instantiated by another ScriptingContainer, application, etc, the same runtime
will be re-used.
Below are examples.
The first Example is a very simple Hello World. After initializing a ScriptingContainer,
a Ruby script, puts "Hello World!", runs and produces "Hello World!."
Example 1:
ScriptingContainer container = new ScriptingContainer();
container.runScriptlet("puts \"Hello World!\"");
Produces:
Hello World!
The second example shows how to share variables between Java and Ruby.
In this example, a local variable "x"
is shared. To make this happen,
a local variable behavior should be transient or persistent.
As for JSR223 JRuby engine, set these types using a System property,
org.jruby.embed.localvariable.behavior.
If the local variable behavior is one of transient or persistent,
Ruby's local, instance, global variables and constants are available to share
between Java and Ruby. (A class variable sharing does not work on current version)
Thus, "x"
in Java is also "x"
in Ruby.
Example 2:
ScriptingContainer container = new ScriptingContainer();
container.put("x", 12345);
container.runScriptlet("puts x.to_s(2)");
Produces:
11000000111001
The third examples shows how to keep local variables across multiple evaluations.
This feature simulates BSF engine for JRuby. In terms of Ruby semantics,
local variables should not survive after the evaluation has completed. Thus,
this behavior is optional, and users need to specify LocalVariableBehavior.PERSISTENT
when the container is instantiated.
Example 3:
ScriptingContainer container = new ScriptingContainer(LocalVariableBehavior.PERSISTENT);
container.runScriptlet("p=9.0");
container.runScriptlet("q = Math.sqrt p");
container.runScriptlet("puts \"square root of #{p} is #{q}\"");
System.out.println("Ruby used values: p = " + container.get("p") + ", q = " + container.get("q"));
Produces:
square root of 9.0 is 3.0
Ruby used values: p = 9.0, q = 3.0
Also, ScriptingContainer provides better i18n support. For example,
Unicode Escape Sequence can be included in Ruby scripts.
In addition, ScriptingContainer supports a parse-once-eval-many-times feature, invoking methods defined by Ruby, and getting an instance of a specified interface that has been implemented by Ruby.
Example 4:
ScriptingContainer container = new ScriptingContainer();
String script =
"def message\n" +
"\"message: #{@message}\"\n" +
"end\n" +
"message";
container.put("@message", "What's up?");
JavaEmbedUtils.EvalUnit unit = container.parse(script);
IRubyObject msg = unit.run(); // a RubyString instance
System.out.println(JavaEmbedUtils.rubyToJava(msg));
container.put("@message", "Fabulous!");
msg = unit.run();
System.out.println(JavaEmbedUtils.rubyToJava(msg));
container.put("@message", "That's the way you are.");
msg = unit.run();
System.out.println(JavaEmbedUtils.rubyToJava(msg));
Produces:
message: What's up?
message: Fabulous!
message: That's the way you are.
See more details at project's- Author:
- Yoko Harada <[email protected]>
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a ScriptingContainer with a default values.Constructs a ScriptingContainer with a specified local context type.ScriptingContainer
(LocalContextScope scope, LocalVariableBehavior behavior) Constructs a ScriptingContainer with a specified local context type and variable behavior.ScriptingContainer
(LocalContextScope scope, LocalVariableBehavior behavior, boolean lazy) Constructs a ScriptingContainer with a specified local context scope, local variable behavior and laziness.ScriptingContainer
(LocalContextScope scope, LocalVariableBehavior behavior, boolean lazy, boolean wrapExceptions) ScriptingContainer
(LocalVariableBehavior behavior) Constructs a ScriptingContainer with a specified local variable behavior. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addClassLoader
(ClassLoader classLoader) add the given classLoader to the LOAD_PATH and GEM_PATHvoid
addGemPath
(ClassLoader classloader) Deprecated.protected void
addGemPath
(String uri) void
addLoadPath
(ClassLoader classloader) Deprecated.protected void
addLoadPath
(String uri) Deprecated.<T> T
callMethod
(Object receiver, String methodName, Class<T> returnType) Executes a method defined in Ruby script.<T> T
callMethod
(Object receiver, String methodName, Class<T> returnType, EmbedEvalUnit unit) Executes a method defined in Ruby script.callMethod
(Object receiver, String methodName, Object... args) Executes a method defined in Ruby script.<T> T
callMethod
(Object receiver, String methodName, Object[] args, Class<T> returnType) Executes a method defined in Ruby script.<T> T
callMethod
(Object receiver, String methodName, Object[] args, Class<T> returnType, EmbedEvalUnit unit) Executes a method defined in Ruby script.<T> T
Executes a method defined in Ruby script.<T> T
callMethod
(Object receiver, String methodName, Object[] args, Block block, Class<T> returnType, EmbedEvalUnit unit) Executes a method defined in Ruby script.<T> T
callMethod
(Object receiver, String methodName, Object singleArg, Class<T> returnType) Executes a method defined in Ruby script.callMethod
(Object receiver, String methodName, Block block, Object... args) Executes a method defined in Ruby script.<T> T
<T> T
void
clear()
Removes all of the mappings from this map.void
finalize()
Ensure this ScriptingContainer instance is terminated when nobody holds any references to it (and GC wants to reclaim it).Returns a value of a specified key in a specified receiver or null if a variable map doesn't have a mapping for the key in a given receiver.Returns a value of the specified key in a top level of runtime or null if this map doesn't have a mapping for the key.String[]
getArgv()
Returns a list of argument.getAttribute
(Object key) Returns an attribute value associated with the specified key in a attribute map.Returns a attribute map in one ofLocalContextScope
.Returns a class loader object that is currently used.boolean
Retrieve the self-first classloader setting.Returns a compile mode currently chosen, which is one of CompileMode.JIT, CompileMode.FORCE, CompileMode.OFF.Returns a current directory.Returns a map of environment variables.getErr()
Deprecated.As of JRuby 1.5.0, Replaced by getError()getError()
Returns an error stream assigned to STDERR and $stderr.Returns an error writer set in an attribute map.Returns a JRuby home directory.getIn()
Deprecated.As of JRuby 1.5.0, replaced by getInput().getInput()
Returns an input stream assigned to STDIN and $stdin.<T> T
getInstance
(Object receiver, Class<T> clazz) Returns an instance of a requested interface type.int
Returns the value of n, which means that jitted methods are logged in every n methods.int
Returns a value of a max class cache size.int
Returns a value of a max size of the bytecode generated by compiler.int
Returns a value of the threshold that determines whether jitted methods' call reached to the limit or not.getKCode()
Returns a value of KCode currently used.Returns a list of load paths for Ruby scripts/libraries.Returns a LoadServiceCreator currently used.getOut()
Deprecated.As of JRuby 1.5.0, replaced by getOutput().Returns an output stream assigned to STDOUT and $stdout.Returns a Profile currently used.Returns currently configured ProfileOutput object, which determines where the output of profiling operations will be sent.Returns a ProfilingMode currently used.String[]
getProperty
(String key) Returns an array of values associated to a key.Returns a provider instance ofLocalContextProvider
.Returns a reader set in an attribute map.Returns a record separator.Deprecated.As of JRuby 1.5.0.Returns a script filename to run.Returns version information about JRuby and Ruby supported by this platform.Returns a variable map in one ofLocalContextScope
.Returns a writer set in an attribute map.boolean
Get whether native code is enabled for this config.boolean
Tests whether the Object Space is enabled or not.boolean
Tests whether Ruby runs in a process or not.Returns an instance ofEmbedRubyObjectAdapter
for embedders to invoke methods defined by Ruby.Returns an instance ofEmbedRubyRuntimeAdapter
for embedders to parse scripts.parse
(InputStream istream, String filename, int... lines) Parses a script given by a input stream and return an object which can be run().Parses a script given by a reader and return an object which can be run().Parses a script and return an object which can be run().Parses a script read from a specified path and return an object which can be run().Associates the specified value with the specified key in a variable map.Associates the specified value with the specified key in a variable map.Removes the specified Ruby variable with the specified variable name in a variable map and given receiver.Removes the specified Ruby variable with the specified variable name from a variable map and runtime top level.removeAttribute
(Object key) Removes the specified value with the specified key in a attribute map.void
void
<T> T
runRubyMethod
(Class<T> returnType, Object receiver, String methodName, Object... args) Executes a method defined in Ruby script.<T> T
Executes a method defined in Ruby script.runScriptlet
(InputStream istream, String filename) Evaluates a script read from a input stream under the current scope (perhaps the top-level scope) and returns a result only if a script returns a value.runScriptlet
(Reader reader, String filename) Evaluates a script read from a reader under the current scope (perhaps the top-level scope) and returns a result only if a script returns a value.runScriptlet
(String script) Evaluates a script under the current scope (perhaps the top-level scope) and returns a result only if a script returns a value.runScriptlet
(PathType type, String filename) Reads a script file from specified path and evaluates it under the current scope (perhaps the top-level scope) and returns a result only if a script returns a value.void
Changes values of the arguments' list.setAttribute
(Object key, Object value) Associates the specified value with the specified key in a attribute map.void
setClassLoader
(ClassLoader loader) Changes a class loader to a given loader.void
setClassloaderDelegate
(boolean classloaderDelegate) Force dynamically-loaded Java classes to load first from the classloader provided by JRuby before searching parent classloaders.void
Changes a compile mode to a given mode, which should be one of CompileMode.JIT, CompileMode.FORCE, CompileMode.OFF.void
setCurrentDirectory
(String directory) Changes a current directory to a given directory.void
setEnvironment
(Map environment) Changes an environment variables' map.void
setError
(PrintStream pstream) Changes STDERR and $stderr to a given print stream.void
Changes STDERR and $stderr to a given writer.void
setErrorWriter
(Writer errorWriter) Replaces a standard error by a specified writer.void
setHomeDirectory
(String home) Changes a JRuby home directory to a directory of a given name.void
setInput
(InputStream istream) Changes STDIN and $stdin to a given input stream.void
Changes STDIN and $stdin to a given reader.void
setJitLogEvery
(int logEvery) Changes a value of n, so that jitted methods are logged in every n methods.void
setJitMax
(int max) Changes a value of a max class cache size.void
setJitMaxSize
(int maxSize) Changes a value of a max size of the bytecode generated by compiler.void
setJitThreshold
(int threshold) Changes a value of the threshold that determines whether jitted methods' call reached to the limit or not.void
Changes a value of KCode to a given value.void
setLoadPaths
(List<String> paths) Changes a list of load paths Ruby scripts/libraries.void
Changes a LoadServiceCreator to a given one.void
setNativeEnabled
(boolean b) Set whether native code is enabled for this config.void
setObjectSpaceEnabled
(boolean enable) Changes the value to determine whether the Object Space is enabled or not.void
setOutput
(PrintStream pstream) Changes STDOUT and $stdout to a given output stream.void
Changes STDOUT and $stdout to a given writer.void
setProfile
(Profile profile) Changes a Profile to a given one.void
Deprecated.Use setProfilingMode insteadvoid
Changes ProfileOutput to given one.void
Changes a ProfilingMode to a given one.void
Replaces a standard input by a specified readervoid
setRecordSeparator
(String separator) Changes a record separator to a given value.void
setRunRubyInProcess
(boolean inprocess) Changes the value to determine whether Ruby runs in a process or not.void
setScriptFilename
(String filename) Changes a script filename to run.void
Replaces a standard output by a specified writer.void
Cleanly shut down this ScriptingContainer and any JRuby resources it holds.
-
Constructor Details
-
ScriptingContainer
public ScriptingContainer()Constructs a ScriptingContainer with a default values. -
ScriptingContainer
Constructs a ScriptingContainer with a specified local context type.- Parameters:
scope
- a local context type.
-
ScriptingContainer
Constructs a ScriptingContainer with a specified local variable behavior.- Parameters:
behavior
- a local variable behavior
-
ScriptingContainer
Constructs a ScriptingContainer with a specified local context type and variable behavior.- Parameters:
scope
- a local context typebehavior
- a local variable behavior
-
ScriptingContainer
Constructs a ScriptingContainer with a specified local context scope, local variable behavior and laziness.- Parameters:
scope
- is one of a local context scope defined byLocalContextScope
behavior
- is one of a local variable behavior defined byLocalVariableBehavior
lazy
- is a switch to do lazy retrieval of variables/constants from Ruby runtime. Default is true. When this value is true, ScriptingContainer tries to get as many variables/constants as possible from Ruby runtime.
-
ScriptingContainer
public ScriptingContainer(LocalContextScope scope, LocalVariableBehavior behavior, boolean lazy, boolean wrapExceptions)
-
-
Method Details
-
getLoadPaths
Returns a list of load paths for Ruby scripts/libraries. If no paths is given, the list is created from java.class.path System property.- Specified by:
getLoadPaths
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- a list of load paths.
- Since:
- JRuby 1.5.0.
-
setLoadPaths
Changes a list of load paths Ruby scripts/libraries. The default value is an empty array. If no paths is given, the list is created from java.class.path System property. This value can be set by org.jruby.embed.class.path System property, also. Call this method before you use put/get, runScriptlet, and parse methods so that the given paths will be used.- Specified by:
setLoadPaths
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
paths
- a new list of load paths.- Since:
- JRuby 1.5.0.
-
getInput
Returns an input stream assigned to STDIN and $stdin.- Specified by:
getInput
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- input stream of STDIN and $stdin
- Since:
- JRuby 1.5.0.
-
setInput
Changes STDIN and $stdin to a given input stream. The default standard input is java.lang.System.in. Call this method before you use put/get, runScriptlet, and parse methods so that the given input stream will be used.- Specified by:
setInput
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
istream
- an input stream to be set- Since:
- JRuby 1.5.0.
-
setInput
Changes STDIN and $stdin to a given reader. No reader is set by default. Call this method before you use put/get, runScriptlet, and parse methods so that the given reader will be used.- Specified by:
setInput
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
reader
- a reader to be set- Since:
- JRuby 1.5.0.
-
getOutput
Returns an output stream assigned to STDOUT and $stdout.- Specified by:
getOutput
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- an output stream of STDOUT and $stdout
- Since:
- JRuby 1.5.0.
-
setOutput
Changes STDOUT and $stdout to a given output stream. The default standard output is java.lang.System.out. Call this method before you use put/get, runScriptlet, and parse methods so that the given output stream will be used.- Specified by:
setOutput
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
pstream
- an output stream to be set- Since:
- JRuby 1.5.0.
-
setOutput
Changes STDOUT and $stdout to a given writer. No writer is set by default. Call this method before you use put/get, runScriptlet, and parse methods so that the given writer will be used.- Specified by:
setOutput
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
writer
- a writer to be set- Since:
- JRuby 1.5.0.
-
getError
Returns an error stream assigned to STDERR and $stderr.- Specified by:
getError
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- output stream for error stream
- Since:
- JRuby 1.5.0.
-
setError
Changes STDERR and $stderr to a given print stream. The default standard error is java.lang.System.err. Call this method before you use put/get, runScriptlet, and parse methods so that the given print stream will be used.- Specified by:
setError
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
pstream
- a print stream to be set- Since:
- JRuby 1.5.0.
-
setError
Changes STDERR and $stderr to a given writer. No writer is set by default. Call this method before you use put/get, runScriptlet, and parse methods so that the given writer will be used.- Specified by:
setError
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
writer
- a writer to be set- Since:
- JRuby 1.5.0.
-
getCompileMode
Returns a compile mode currently chosen, which is one of CompileMode.JIT, CompileMode.FORCE, CompileMode.OFF. The default mode is CompileMode.JIT. Also, CompileMode.OFF is chosen when a security restriction is set.- Specified by:
getCompileMode
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- a compile mode.
- Since:
- JRuby 1.5.0.
-
setCompileMode
Changes a compile mode to a given mode, which should be one of CompileMode.JIT, CompileMode.FORCE, CompileMode.OFF. Call this method before you use put/get, runScriptlet, and parse methods so that the given mode will be used.- Specified by:
setCompileMode
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
mode
- compile mode- Since:
- JRuby 1.5.0.
-
isRunRubyInProcess
public boolean isRunRubyInProcess()Tests whether Ruby runs in a process or not.- Specified by:
isRunRubyInProcess
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- true if Ruby is configured to run in a process, otherwise, false.
- Since:
- JRuby 1.5.0.
-
setRunRubyInProcess
public void setRunRubyInProcess(boolean inprocess) Changes the value to determine whether Ruby runs in a process or not. The default value is true. Call this method before you use put/get, runScriptlet, and parse methods so that the given condition will be set.- Specified by:
setRunRubyInProcess
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
inprocess
- true when Ruby is set to run in the process, or false not to run in the process.- Since:
- JRuby 1.5.0.
-
isObjectSpaceEnabled
public boolean isObjectSpaceEnabled()Tests whether the Object Space is enabled or not.- Specified by:
isObjectSpaceEnabled
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- true if the Object Space is able to use, otherwise, false.
- Since:
- JRuby 1.5.0.
-
setObjectSpaceEnabled
public void setObjectSpaceEnabled(boolean enable) Changes the value to determine whether the Object Space is enabled or not. The default value is false. Call this method before you use put/get, runScriptlet, and parse methods so that the given condition will be used.- Specified by:
setObjectSpaceEnabled
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
enable
- true to enable the Object Space, or false to disable.- Since:
- JRuby 1.5.0. This value can be set by jruby.objectspace.enabled system property.
-
getEnvironment
Returns a map of environment variables.- Specified by:
getEnvironment
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- a map that has environment variables' key-value pairs.
- Since:
- JRuby 1.5.0.
-
setEnvironment
Changes an environment variables' map. Call this method before you use put/get, runScriptlet, and parse methods so that initial configurations will work.- Specified by:
setEnvironment
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
environment
- a new map of environment variables.- Since:
- JRuby 1.5.0.
-
getCurrentDirectory
Returns a current directory. The default current directory is identical to a value of "user.dir" system property if no security restriction is set. If the "user.dir" directory is protected by the security restriction, the default value is "/".- Specified by:
getCurrentDirectory
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- a current directory.
- Since:
- JRuby 1.5.0.
-
setCurrentDirectory
Changes a current directory to a given directory. The current directory can be changed anytime.- Specified by:
setCurrentDirectory
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
directory
- a new directory to be set.- Since:
- JRuby 1.5.0.
-
getHomeDirectory
Returns a JRuby home directory. The default JRuby home is the value of JRUBY_HOME environment variable, or "jruby.home" system property when no security restriction is set to those directories. If none of JRUBY_HOME or jruby.home is set and jruby-complete.jar is used, the default JRuby home is "/META-INF/jruby.home" in the jar archive. Otherwise, "java.io.tmpdir" system property is the default value.- Specified by:
getHomeDirectory
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- a JRuby home directory.
- Since:
- JRuby 1.5.0.
-
setHomeDirectory
Changes a JRuby home directory to a directory of a given name. Call this method before you use put/get, runScriptlet, and parse methods so that the given directory will be used.- Specified by:
setHomeDirectory
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
home
- a name of new JRuby home directory.- Since:
- JRuby 1.5.0.
-
getClassLoader
Returns a class loader object that is currently used. This loader loads Ruby files and libraries.- Specified by:
getClassLoader
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- a class loader object that is currently used.
- Since:
- JRuby 1.5.0.
-
setClassLoader
Changes a class loader to a given loader. Call this method before you use put/get, runScriptlet, and parse methods so that the given class loader will be used.- Specified by:
setClassLoader
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
loader
- a new class loader to be set.- Since:
- JRuby 1.5.0.
-
getProfile
Returns a Profile currently used. The default value is Profile.DEFAULT, which has the same behavior to Profile.ALL. Profile allows you to define a restricted subset of code to be loaded during the runtime initialization. When you use JRuby in restricted environment such as Google App Engine, Profile is a helpful option.- Specified by:
getProfile
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- a current profiler.
- Since:
- JRuby 1.5.0.
-
setProfile
Changes a Profile to a given one. The default value is Profile.DEFAULT, which has the same behavior to Profile.ALL. Call this method before you use put/get, runScriptlet, and parse methods so that initial configurations will work. Profile allows you to define a restricted subset of code to be loaded during the runtime initialization. When you use JRuby in restricted environment such as Google App Engine, Profile is a helpful option. For example, Profile.NO_FILE_CLASS doesn't load File class.- Specified by:
setProfile
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
profile
- a new profiler to be set.- Since:
- JRuby 1.5.0.
-
getProfileOutput
Returns currently configured ProfileOutput object, which determines where the output of profiling operations will be sent. (e.g., a file specified by --profile.out).- Returns:
- current profiling output location.
- Since:
- JRuby 1.7.15
-
setProfileOutput
Changes ProfileOutput to given one. The default value is a ProfileOutput instance that writes to stderr. Similar to passing `--profile.out` from the command line- Parameters:
out
- a new ProfileOutput object, to which profiling data should be written- Since:
- JRuby 1.7.15
-
getProfilingMode
Returns a ProfilingMode currently used. The default value is ProfilingMode.OFF.- Returns:
- a current profiling mode.
- Since:
- JRuby 1.6.6.
-
setProfile
Deprecated.Use setProfilingMode insteadChanges a ProfilingMode to a given one. The default value is Profiling.OFF. Call this method before you use put/get, runScriptlet, and parse methods so that initial configurations will work. ProfilingMode allows you to change profiling style. Profiling.OFF - default. profiling off. Profiling.API - activates Ruby profiler API. equivalent to --profile.api command line option Profiling.FLAT - synonym for --profile command line option equivalent to --profile.flat command line option Profiling.GRAPH - runs with instrumented (timed) profiling, graph format. equivalent to --profile.graph command line option.- Parameters:
mode
- a new profiling mode to be set.- Since:
- JRuby 1.6.6.
-
setProfilingMode
Changes a ProfilingMode to a given one. The default value is Profiling.OFF. Call this method before you use put/get, runScriptlet, and parse methods so that initial configurations will work. ProfilingMode allows you to change profiling style. Profiling.OFF - default. profiling off. Profiling.API - activates Ruby profiler API. equivalent to --profile.api command line option Profiling.FLAT - synonym for --profile command line option equivalent to --profile.flat command line option Profiling.GRAPH - runs with instrumented (timed) profiling, graph format. equivalent to --profile.graph command line option.- Parameters:
mode
- a new profiling mode to be set.- Since:
- JRuby 1.7.15
-
getLoadServiceCreator
Returns a LoadServiceCreator currently used.- Specified by:
getLoadServiceCreator
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- a current LoadServiceCreator.
- Since:
- JRuby 1.5.0.
-
setLoadServiceCreator
Changes a LoadServiceCreator to a given one. Call this method before you use put/get, runScriptlet, and parse methods so that initial configurations will work.- Specified by:
setLoadServiceCreator
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
creator
- a new LoadServiceCreator- Since:
- JRuby 1.5.0.
-
getArgv
Returns a list of argument.- Specified by:
getArgv
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- an arguments' list.
- Since:
- JRuby 1.5.0.
-
setArgv
Changes values of the arguments' list.- Specified by:
setArgv
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
argv
- a new arguments' list.- Since:
- JRuby 1.5.0.
-
getScriptFilename
Returns a script filename to run. The default value is "<script>".- Specified by:
getScriptFilename
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- a script filename.
- Since:
- JRuby 1.5.0.
-
setScriptFilename
Changes a script filename to run. The default value is "<script>". Call this before you use put/get, runScriptlet, and parse methods so that initial configurations will work.- Specified by:
setScriptFilename
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
filename
- a new script filename.- Since:
- JRuby 1.5.0.
-
getRecordSeparator
Returns a record separator. The default value is "\n".- Specified by:
getRecordSeparator
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- a record separator.
- Since:
- JRuby 1.5.0.
-
setRecordSeparator
Changes a record separator to a given value. If "0" is given, the record separator goes to "\n\n", "777" goes to "ï¿¿", otherwise, an octal value of the given number. Call this before you use put/get, runScriptlet, and parse methods so that initial configurations will work.- Specified by:
setRecordSeparator
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
separator
- a new record separator value, "0" or "777"- Since:
- JRuby 1.5.0.
-
getKCode
Returns a value of KCode currently used. The default value is KCode.NONE.- Specified by:
getKCode
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- a KCode value.
- Since:
- JRuby 1.5.0.
-
setKCode
Changes a value of KCode to a given value. The value should be one of KCode.NONE, KCode.UTF8, KCode.SJIS, or KCode.EUC. The default value is KCode.NONE. Call this method before you use put/get, runScriptlet, and parse methods so that the given value will be used.- Specified by:
setKCode
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
kcode
- a new KCode value.- Since:
- JRuby 1.5.0.
-
setNativeEnabled
public void setNativeEnabled(boolean b) Set whether native code is enabled for this config. Disabling it also disables C extensions (@see RubyInstanceConfig#setCextEnabled).- Parameters:
b
- new value indicating whether native code is enabled- See Also:
-
isNativeEnabled
public boolean isNativeEnabled()Get whether native code is enabled for this config.- Returns:
- true if native code is enabled; false otherwise.
- See Also:
-
getJitLogEvery
public int getJitLogEvery()Returns the value of n, which means that jitted methods are logged in every n methods. The default value is 0.- Specified by:
getJitLogEvery
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- a value that determines how often jitted methods are logged.
- Since:
- JRuby 1.5.0.
-
setJitLogEvery
public void setJitLogEvery(int logEvery) Changes a value of n, so that jitted methods are logged in every n methods. The default value is 0. This value can be set by the jruby.jit.logEvery System property. Call this method before you use put/get, runScriptlet, and parse methods so that the configurations will work.- Specified by:
setJitLogEvery
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
logEvery
- a new number of methods.- Since:
- JRuby 1.5.0.
-
getJitThreshold
public int getJitThreshold()Returns a value of the threshold that determines whether jitted methods' call reached to the limit or not. The default value is -1 when security restriction is applied, or 50 when no security restriction exists.- Specified by:
getJitThreshold
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- a value of the threshold.
- Since:
- JRuby 1.5.0.
-
setJitThreshold
public void setJitThreshold(int threshold) Changes a value of the threshold that determines whether jitted methods' call reached to the limit or not. The default value is -1 when security restriction is applied, or 50 when no security restriction exists. This value can be set by jruby.jit.threshold System property. Call this method before you use put/get, runScriptlet, and parse methods so that the configurations will work.- Specified by:
setJitThreshold
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
threshold
- a new value of the threshold.- Since:
- JRuby 1.5.0.
-
getJitMax
public int getJitMax()Returns a value of a max class cache size. The default value is 0 when security restriction is applied, or 4096 when no security restriction exists.- Specified by:
getJitMax
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- a value of a max class cache size.
- Since:
- JRuby 1.5.0.
-
setJitMax
public void setJitMax(int max) Changes a value of a max class cache size. The default value is 0 when security restriction is applied, or 4096 when no security restriction exists. This value can be set by jruby.jit.max System property. Call this method before you use put/get, runScriptlet, and parse methods so that the configurations will work.- Specified by:
setJitMax
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
max
- a new value of a max class cache size.- Since:
- JRuby 1.5.0.
-
getJitMaxSize
public int getJitMaxSize()Returns a value of a max size of the bytecode generated by compiler. The default value is -1 when security restriction is applied, or 10000 when no security restriction exists.- Specified by:
getJitMaxSize
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- a value of a max size of the bytecode.
- Since:
- JRuby 1.5.0.
-
setJitMaxSize
public void setJitMaxSize(int maxSize) Changes a value of a max size of the bytecode generated by compiler. The default value is -1 when security restriction is applied, or 10000 when no security restriction exists. This value can be set by jruby.jit.maxsize System property. Call this method before you use put/get, runScriptlet, and parse methods so that the configurations will work.- Specified by:
setJitMaxSize
in interfaceEmbedRubyInstanceConfigAdapter
- Parameters:
maxSize
- a new value of a max size of the bytecode.- Since:
- JRuby 1.5.0.
-
getSupportedRubyVersion
Returns version information about JRuby and Ruby supported by this platform.- Specified by:
getSupportedRubyVersion
in interfaceEmbedRubyInstanceConfigAdapter
- Returns:
- version information.
-
getProperty
Returns an array of values associated to a key.- Parameters:
key
- is a key in a property file- Returns:
- values associated to the key
-
getProvider
Returns a provider instance ofLocalContextProvider
. When users want to configure Ruby runtime, they can do by setting class loading paths,RubyInstanceConfig
to the provider before they get Ruby runtime.- Returns:
- a provider of
LocalContextProvider
-
getRuntime
Deprecated.As of JRuby 1.5.0. Use getProvider().getRuntime() method instead.Returns a Ruby runtime in one ofLocalContextScope
.- Returns:
- Ruby runtime of a specified local context
-
getVarMap
Returns a variable map in one ofLocalContextScope
. Variables in this map is used to share between Java and Ruby. Map keys are Ruby's variable names, thus they must be valid Ruby names.- Returns:
- a variable map specific to the current thread
-
getAttributeMap
Returns a attribute map in one ofLocalContextScope
. Attributes in this map accept any key value pair, types of which are java.lang.Object. Ruby scripts do not look up this map.- Returns:
- an attribute map specific to the current thread
-
getAttribute
Returns an attribute value associated with the specified key in a attribute map. This is a short cut method of ScriptingContainer#getAttributeMap().get(key).- Parameters:
key
- is the attribute key- Returns:
- value is a value associated to the specified key
-
setAttribute
Associates the specified value with the specified key in a attribute map. If the map previously contained a mapping for the key, the old value is replaced. This is a short cut method of ScriptingContainer#getAttributeMap().put(key, value).- Parameters:
key
- is a key that the specified value is to be associated withvalue
- is a value to be associated with the specified key- Returns:
- the previous value associated with key, or null if there was no mapping for key.
-
removeAttribute
Removes the specified value with the specified key in a attribute map. If the map previously contained a mapping for the key, the old value is returned. This is a short cut method of ScriptingContainer#getAttributeMap().remove(key).- Parameters:
key
- is a key that the specified value is to be removed from- Returns:
- the previous value associated with key, or null if there was no mapping for key.
-
get
Returns a value of the specified key in a top level of runtime or null if this map doesn't have a mapping for the key. The key must be a valid Ruby variable or constant name.- Parameters:
key
- is a key whose associated value is to be returned- Returns:
- a value to which the specified key is mapped, or null if this map contains no mapping for the key
-
get
Returns a value of a specified key in a specified receiver or null if a variable map doesn't have a mapping for the key in a given receiver. The key must be a valid Ruby variable or constant name. A global variable doesn't depend on the receiver.- Parameters:
receiver
- a receiver to get the value fromkey
- is a key whose associated value is to be returned- Returns:
- a value to which the specified key is mapped, or null if this map contains no mapping for the key
-
put
Associates the specified value with the specified key in a variable map. This key-value pair is injected to a top level of runtime during evaluation. If the map previously contained a mapping for the key, the old value is replaced. The key must be a valid Ruby variable or constant name. It will be a top level variable or constant.- Parameters:
key
- is a key that the specified value is to be associated withvalue
- is a value to be associated with the specified key- Returns:
- a previous value associated with a key, or null if there was no mapping for this key.
-
put
Associates the specified value with the specified key in a variable map. This key-value pair is injected to a given receiver during evaluation. If the map previously contained a mapping for the key, the old value is replaced. The key must be a valid Ruby variable or constant name. A given receiver limits the scope of a variable or constant. However, a global variable is accessible globally always.- Parameters:
receiver
- a receiver to put the value inkey
- is a key that the specified value is to be associated withvalue
- is a value to be associated with the specified key- Returns:
- a previous value associated with a key, or null if there was no mapping for this key.
-
remove
Removes the specified Ruby variable with the specified variable name from a variable map and runtime top level. If the map previously contained a mapping for the key, the old value is returned. The key must be a valid Ruby variable name.- Parameters:
key
- is a key that the specified value is to be associated with- Returns:
- a previous value associated with a key, or null if there was no mapping for this key.
-
remove
Removes the specified Ruby variable with the specified variable name in a variable map and given receiver. If the map previously contained a mapping for the key, the old value is returned. The key must be a valid Ruby variable name. This is a short cut method of ScriptingContainer#getVarMap().remove(key).- Parameters:
receiver
- a receiver to remove the value fromkey
- is a key that the specified value is to be associated with- Returns:
- a previous value associated with a key, or null if there was no mapping for this key.
-
clear
public void clear()Removes all of the mappings from this map. The map will be empty after this call returns. Ruby variables are also removed from Ruby instance. However, Ruby instance keep having global variable names with null value. This is a short cut method of ScriptingContainer#getVarMap().clear(). -
parse
Parses a script and return an object which can be run(). This allows the script to be parsed once and evaluated many times.- Parameters:
script
- is a Ruby script to be parsedlines
- 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.- Returns:
- an object which can be run
-
parse
Parses a script given by a reader and return an object which can be run(). This allows the script to be parsed once and evaluated many times.- Parameters:
reader
- is used to read a script fromfilename
- is used as in information, for example, appears in a stack trace of an exceptionlines
- 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.- Returns:
- an object which can be run
-
parse
Parses a script read from a specified path and return an object which can be run(). This allows the script to be parsed once and evaluated many times.- Parameters:
type
- is one of the typesPathType
definesfilename
- is used as in information, for example, appears in a stack trace of an exceptionlines
- 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.- Returns:
- an object which can be run
-
parse
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.- Parameters:
istream
- is an input stream to get a script fromfilename
- filename is used as in information, for example, appears in a stack trace of an exceptionlines
- 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.- Returns:
- an object which can be run
-
runScriptlet
Evaluates a script under the current scope (perhaps the top-level scope) and returns a result only if a script returns a value. Right after the parsing, the script is evaluated once.- Parameters:
script
- is a Ruby script to get run- Returns:
- an evaluated result converted to a Java object
-
runScriptlet
Evaluates a script read from a reader under the current scope (perhaps the top-level scope) and returns a result only if a script returns a value. Right after the parsing, the script is evaluated once.- Parameters:
reader
- is used to read a script fromfilename
- is used as in information, for example, appears in a stack trace of an exception- Returns:
- an evaluated result converted to a Java object
-
runScriptlet
Evaluates a script read from a input stream under the current scope (perhaps the top-level scope) and returns a result only if a script returns a value. Right after the parsing, the script is evaluated once.- Parameters:
istream
- is used to input a script fromfilename
- is used as in information, for example, appears in a stack trace of an exception- Returns:
- an evaluated result converted to a Java object
-
runScriptlet
Reads a script file from specified path and evaluates it under the current scope (perhaps the top-level scope) and returns a result only if a script returns a value. Right after the parsing, the script is evaluated once.- Parameters:
type
- is one of the typesPathType
definesfilename
- is used to read the script from and an information- Returns:
- an evaluated result converted to a Java object
-
newRuntimeAdapter
Returns an instance ofEmbedRubyRuntimeAdapter
for embedders to parse scripts.- Returns:
- an instance of
EmbedRubyRuntimeAdapter
.
-
newObjectAdapter
Returns an instance ofEmbedRubyObjectAdapter
for embedders to invoke methods defined by Ruby. The script must be evaluated prior to a method call. In most cases, users don't need to use this method. ScriptingContainer's callMethods are the shortcut and work in the same way.Example # calendar.rb require 'date' class Calendar def initialize;@today = DateTime.now;end def next_year;@today.year + 1;end end Calendar.new ScriptingContainer container = new ScriptingContainer(); String filename = "ruby/calendar.rb"; Object receiver = instance.runScriptlet(PathType.CLASSPATH, filename); EmbedRubyObjectAdapter adapter = instance.newObjectAdapter(); Integer result = (Integer) adapter.callMethod(receiver, "next_year", Integer.class); System.out.println("next year: " + result); System.out.println(instance.get("@today")); Outputs: next year: 2010 2009-05-19T17:46:44-04:00
- Returns:
- an instance of
EmbedRubyObjectAdapter
-
callMethod
Executes a method defined in Ruby script. This method is used when a Ruby method does not have any argument.- Parameters:
receiver
- is an instance that will receive this method call. Ruby's self object will be used if no appropriate receiver is given.methodName
- is a method name to be calledargs
- is an array of method arguments- Returns:
- an instance of requested Java type
-
callMethod
Executes a method defined in Ruby script. This method is used when a Ruby method does not have any argument.- Parameters:
receiver
- is an instance that will receive this method call Ruby's self object will be used if no appropriate receiver is given.methodName
- is a method name to be calledblock
- is a block to be executed in this methodargs
- is an array of method arguments- Returns:
- an instance of requested Java type
-
callMethod
Executes a method defined in Ruby script. This method is used when a Ruby method does not have any argument.- Parameters:
receiver
- is an instance that will receive this method call. Ruby's self object will be used if no appropriate receiver is given.methodName
- is a method name to be calledreturnType
- is the type we want it to convert to- Returns:
- an instance of requested Java type
-
callMethod
Executes a method defined in Ruby script. This method is used when a Ruby method have only one argument.- Parameters:
receiver
- is an instance that will receive this method call. Ruby's self object will be used if no appropriate receiver is given.methodName
- is a method name to be calledsingleArg
- is an method argumentreturnType
- returnType is the type we want it to convert to- Returns:
- an instance of requested Java type
-
callMethod
Executes a method defined in Ruby script. This method is used when a Ruby method have multiple arguments.- Parameters:
receiver
- is an instance that will receive this method call. Ruby's self object will be used if no appropriate receiver is given.methodName
- is a method name to be calledargs
- is an array of method argumentsreturnType
- is the type we want it to convert to- Returns:
- an instance of requested Java type
-
callMethod
public <T> T callMethod(Object receiver, String methodName, Object[] args, Block block, Class<T> returnType) Executes a method defined in Ruby script. This method is used when a Ruby method have multiple arguments, one of which is a block.- Parameters:
receiver
- is an instance that will receive this method call. Ruby's self object will be used if no appropriate receiver is given.methodName
- is a method name to be calledargs
- is an array of method arguments except a blockblock
- is a block to be executed in this methodreturnType
- is the type we want it to convert to- Returns:
- an instance of requested Java type
-
callMethod
public <T> T callMethod(Object receiver, String methodName, Class<T> returnType, EmbedEvalUnit unit) Executes a method defined in Ruby script. This method is used when a Ruby method does not have any argument, and users want to inject Ruby's local variables' values from Java.- Parameters:
receiver
- is an instance that will receive this method call. Ruby's self object will be used if no appropriate receiver is given.methodName
- is a method name to be calledreturnType
- is the type we want it to convert tounit
- is parsed unit- Returns:
- an instance of requested Java type
-
callMethod
public <T> T callMethod(Object receiver, String methodName, Object[] args, Class<T> returnType, EmbedEvalUnit unit) Executes a method defined in Ruby script. This method is used when a Ruby method have multiple arguments, and users want to inject Ruby's local variables' values from Java.- Parameters:
receiver
- is an instance that will receive this method call. Ruby's self object will be used if no appropriate receiver is given.methodName
- is a method name to be calledargs
- is an array of method argumentsreturnType
- is the type we want it to convert tounit
- is parsed unit- Returns:
- an instance of requested Java type
-
callMethod
public <T> T callMethod(Object receiver, String methodName, Object[] args, Block block, Class<T> returnType, EmbedEvalUnit unit) Executes a method defined in Ruby script. This method is used when a Ruby method have multiple arguments, one of which is a block, and users want to inject Ruby's local variables' values from Java.- Parameters:
receiver
- is an instance that will receive this method call. Ruby's self object will be used if no appropriate receiver is given.methodName
- is a method name to be calledargs
- is an array of method arguments except a blockblock
- is a block to be executed in this methodreturnType
- is the type we want it to convert tounit
- is parsed unit- Returns:
- is the type we want it to convert to
-
callSuper
- Parameters:
receiver
- is an instance that will receive this method call. Ruby's self object will be used if no appropriate receiver is given.args
- is an array of method argumentsreturnType
- is the type we want it to convert to- Returns:
- is the type we want it to convert to
-
callSuper
- Parameters:
receiver
- is an instance that will receive this method call. Ruby's self object will be used if no appropriate receiver is given.args
- is an array of method arguments except a blockblock
- is a block to be executed in this methodreturnType
- is the type we want it to convert to- Returns:
- is the type we want it to convert to
-
runRubyMethod
Executes a method defined in Ruby script. This method is used when a Ruby method does not have any argument.- Parameters:
returnType
- is the type we want it to convert toreceiver
- is an instance that will receive this method call. The receiver can be null or other Java objects as well as RubyObject. The null will be converted to RubyNil. Java objects will be wrapped in RubyObject.methodName
- is a method name to be calledargs
- is an array of method arguments- Returns:
- an instance of requested Java type
-
runRubyMethod
public <T> T runRubyMethod(Class<T> returnType, Object receiver, String methodName, Block block, Object... args) Executes a method defined in Ruby script. This method is used when a Ruby method does not have any argument.- Parameters:
returnType
- is the type we want it to convert toreceiver
- is an instance that will receive this method call. The receiver can be null or other Java objects as well as RubyObject. The null will be converted to RubyNil. Java objects will be wrapped in RubyObject.methodName
- is a method name to be calledblock
- is an optional Block object. Send null for no block.args
- is an array of method arguments- Returns:
- an instance of requested Java type
-
getInstance
Returns an instance of a requested interface type. An implementation of the requested interface is done by a Ruby script, which has been evaluated before getting the instance. In most cases, users don't need to use this method. ScriptingContainer's runScriptlet method returns an instance of the interface type that is implemented by Ruby.Example Interface //QuadraticFormula.java package org.jruby.embed; import java.util.List; public interface QuadraticFormula { List solve(int a, int b, int c) throws Exception; } Implementation #quadratic_formula.rb def solve(a, b, c) v = b ** 2 - 4 * a * c if v < 0: raise RangeError end s0 = ((-1)*b - Math.sqrt(v))/(2*a) s1 = ((-1)*b + Math.sqrt(v))/(2*a) return s0, s1 end Usage ScriptingContainer container = new ScriptingContainer(); String filename = "ruby/quadratic_formula_class.rb"; Object receiver = container.runScriptlet(PathType.CLASSPATH, filename); QuadraticFormula qf = container.getInstance(receiver, QuadraticFormula.class); try { List<Double> solutions = qf.solve(1, -2, -13); printSolutions(solutions); solutions = qf.solve(1, -2, 13); for (double s : solutions) { System.out.print(s + ", "); } } catch (Exception e) { e.printStackTrace(); } Output -2.7416573867739413, 4.741657386773941,
- Parameters:
receiver
- is an instance that implements the interfaceclazz
- is a requested interface- Returns:
- an instance of a requested interface type
-
setReader
Replaces a standard input by a specified reader- Parameters:
reader
- is a reader to be set
-
getReader
Returns a reader set in an attribute map.- Returns:
- a reader in an attribute map
-
getIn
Deprecated.As of JRuby 1.5.0, replaced by getInput().Returns an input stream that Ruby runtime has. The stream is set when Ruby runtime is initialized.- Returns:
- an input stream that Ruby runtime has.
-
setWriter
Replaces a standard output by a specified writer.- Parameters:
writer
- is a writer to be set
-
resetWriter
public void resetWriter() -
getWriter
Returns a writer set in an attribute map.- Returns:
- a writer in a attribute map
-
getOut
Deprecated.As of JRuby 1.5.0, replaced by getOutput().Returns an output stream that Ruby runtime has. The stream is set when Ruby runtime is initialized.- Returns:
- an output stream that Ruby runtime has
-
setErrorWriter
Replaces a standard error by a specified writer.- Parameters:
errorWriter
- is a writer to be set
-
resetErrorWriter
public void resetErrorWriter() -
getErrorWriter
Returns an error writer set in an attribute map.- Returns:
- an error writer in a attribute map
-
getErr
Deprecated.As of JRuby 1.5.0, Replaced by getError()Returns an error output stream that Ruby runtime has. The stream is set when Ruby runtime is initialized.- Returns:
- an error output stream that Ruby runtime has
-
terminate
public void terminate()Cleanly shut down this ScriptingContainer and any JRuby resources it holds. All ScriptingContainer instances should be terminated when you are done with them, rather then leaving them for GC to finalize.- Since:
- JRuby 1.5.0
-
finalize
Ensure this ScriptingContainer instance is terminated when nobody holds any references to it (and GC wants to reclaim it). Note thatLocalContextScope.SINGLETON
containers will not terminate on GC. -
setClassloaderDelegate
public void setClassloaderDelegate(boolean classloaderDelegate) Force dynamically-loaded Java classes to load first from the classloader provided by JRuby before searching parent classloaders. This can be used to isolated dependency in different runtimes from each other and from parent classloaders. The default behavior is to defer to parent classloaders if they can provide the requested classes. Note that if different versions of a library are loaded by both a parent classloader and the JRuby classloader, those classess would be incompatible with each other and with other library objects from the opposing classloader.- Parameters:
classloaderDelegate
- set whether prefer the JRuby classloader to delegate first to the parent classloader when dynamically loading classes- Since:
- JRuby 9.0.0.0
-
getClassloaderDelegate
public boolean getClassloaderDelegate()Retrieve the self-first classloader setting.- See Also:
-
addClassLoader
add the given classLoader to the LOAD_PATH and GEM_PATH- Parameters:
classLoader
-
-
addLoadPath
Deprecated.add the given classloader to the LOAD_PATH- Parameters:
classloader
-
-
addLoadPath
Deprecated. -
addGemPath
Deprecated.add the given classloader to the GEM_PATH- Parameters:
classloader
-
-
addGemPath
-