Package org.jruby
Class Ruby
java.lang.Object
org.jruby.Ruby
- All Implemented Interfaces:
Constantizable
The Ruby object represents the top-level of a JRuby "instance" in a given VM.
JRuby supports spawning multiple instances in the same JVM. Generally, objects
created under these instances are tied to a given runtime, for such details
as identity and type, because multiple Ruby instances means there are
multiple instances of each class. This means that in multi-runtime mode
(or really, multi-VM mode, where each JRuby instance is a ruby "VM"), objects
generally can't be transported across runtimes without marshaling.
This class roots everything that makes the JRuby runtime function, and
provides a number of utility methods for constructing global types and
accessing global runtime structures.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static interface
static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final int
final ClassValue
<TypePopulator> final JavaSites
static final String
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addBoundMethod
(String className, String methodName, String rubyName) void
addBoundMethods
(int tuplesIndex, String... classNamesAndTuples) void
addBoundMethods
(String className, String... tuples) void
addEventHook
(EventHook hook) Deprecated.void
addFinalizer
(Finalizable finalizer) void
addInternalFinalizer
(Finalizable finalizer) void
addModule
(RubyModule module) A collection of all natural Module instances in the system.void
addToObjectSpace
(boolean useObjectSpace, IRubyObject object) int
int
void
callEventHooks
(ThreadContext context, RubyEvent event, String file, int line, String name, IRubyObject type) Deprecated.static void
Clear the global runtime.void
compileAndLoadFile
(String filename, InputStream in, boolean wrap) constant()
defineClass
(String name, RubyClass superClass, ObjectAllocator allocator) Deprecated.defineClass
(String name, RubyClass superClass, ObjectAllocator allocator, CallSite[] callSites) Deprecated.defineClassUnder
(String name, RubyClass superClass, ObjectAllocator allocator, RubyModule parent) Deprecated.defineClassUnder
(String id, RubyClass superClass, ObjectAllocator allocator, RubyModule parent, CallSite[] callSites) Deprecated.defineClassUnder
(ThreadContext context, String id, RubyClass superClass, ObjectAllocator allocator, RubyModule parent, CallSite[] callSites) A variation of defineClassUnder that allows passing in an array of supplementary call sites to improve dynamic invocation.void
void
defineGlobalConstant
(String name, IRubyObject value) Deprecated.defineModule
(String name) Deprecated.defineModuleBootstrap
(String name) This is only for defining kernel.defineModuleUnder
(String name, RubyModule parent) Deprecated.defineModuleUnder
(ThreadContext context, String name, RubyModule parent) Define a new module with the given name under the given module or class namespace.void
defineReadonlyVariable
(String name, IRubyObject value, GlobalVariable.Scope scope) defines a readonly global variablevoid
defineVariable
(GlobalVariable variable, GlobalVariable.Scope scope) Defines a global variablevoid
eachModule
(Consumer<RubyModule> func) Walk all natural Module instances in the system.evalScriptlet
(String script) Evaluates a script under the current scope (perhaps the top-level scope) and returns the result (generally the last value calculated).evalScriptlet
(String script, DynamicScope scope) Evaluates a script under the current scope (perhaps the top-level scope) and returns the result (generally the last value calculated).executeScript
(String script, String filename) Parse and execute the specified script This differs from the other methods in that it accepts a string-based script and parses and runs it as though it were loaded at a command-line.fastGetClass
(String internedName) Deprecated.fastNewSymbol
(String internedName) Faster thannewSymbol(String)
if you already have an interned name String.fetchGlobalConstant
(String name) Deprecated.freezeAndDedupString
(RubyString string) Given a Ruby string, cache a deduplicated FString version of it, or find an existing copy already prepared.freezeAndDedupString
(ByteList bytes) Given a ByteList, cache a deduplicated FString version of it, or find an existing copy already prepared.getArray()
int
Get the current backtrace count.Get the base Class#new method.Deprecated.UseAccess.integerClass(ThreadContext)
instead.getCachedStrptimePattern
(String pattern) Get the Caches management object.int
Get the current backtrace count.getChain()
Deprecated.getClassFromPath
(String path) getClassFromPath
(String path, RubyClass undefinedExceptionClass, boolean flexibleSearch) Find module from a string (e.g.static ClassLoader
getConstantInvalidator
(String constantName) int
getData()
getDebug()
Get the default java.nio.charset.Charset for the current default internal encoding.org.jcodings.Encoding
Return the default internal encoding, if set, or UTF-8 by default.org.jcodings.Encoding
org.jcodings.Encoding
org.jcodings.Encoding
This is an internal encoding if actually specified via default_internal= or passed in via -E.getDefinedMessage
(DefinedMessage definedMessage) getDir()
getDummy()
getENV()
getErr()
getErrno()
getErrno
(int n) getEtc()
Deprecated.int
Get the current exception count.getFalse()
Returns the "false" instance from the instance pool.getFatal()
getFFI()
getFiber()
getFile()
getFloat()
getGC()
static Ruby
Get the global runtime.getHash()
long
long
Get the global object used to synchronize class-hierarchy modifications like cache invalidation, subclass sets, and included hierarchy sets.getIn()
getIO()
getKCode()
Returns the loadService.getMath()
Deprecated.getMutex()
jnr.posix.POSIX
Get the native POSIX associated with this runtime.long
Get a new serial number for a new DynamicMethod instanceint
Get a new generation number for a module or class.getNil()
Returns the "nil" singleton instance.Get the "nullToNil" method handle filter for this runtime.Return the original stderr with which this runtime was initialized.getOut()
Deprecated.jnr.posix.POSIX
getPosix()
getProc()
getQueue()
getRange()
Deprecated.Get the core class RuntimeCache instance, for doing dynamic calls from core class methods.int
Get the runtime-global selector poollong
static Ruby
Get the thread-local runtime for the current thread, or null if unset.getThreadStatus
(RubyThread.Status status) getTime()
Getter for property rubyTopSelf.getTrue()
Returns the "true" instance from the instance pool.Get the current enabled warning categories.int
Get the current backtrace count.boolean
Deprecated.void
Increment the count of backtraces generated by code in this runtime.void
Increment the count of backtraces generated by code in this runtime.void
Increment the count of exceptions generated by code in this runtime.void
Increment the count of backtraces generated for warnings in this runtime.boolean
boolean
boolean
boolean
isClassDefined
(String name) Deprecated.boolean
boolean
isDebug()
boolean
isDefaultMethodMissing
(DynamicMethod method) boolean
boolean
Deprecated.static boolean
Tests whether globalRuntime has been instantiated or not.boolean
isInspecting
(Object obj) boolean
boolean
static boolean
boolean
boolean
<C extends Enum<C> & jnr.constants.Constant>
voidloadConstantSet
(RubyModule module, Class<C> enumClass) Deprecated.UseRubyModule.defineConstantsFrom(ThreadContext, Class)
instead.void
loadConstantSet
(RubyModule module, String constantSetName) Deprecated.void
loadExtension
(String extName, BasicLibraryService extension, boolean wrap) Load the given BasicLibraryService instance, wrapping it in Ruby framing to ensure it is isolated from any parent scope.void
loadFile
(String scriptName, InputStream in, boolean wrap) void
void
loadScript
(Script script) void
loadScript
(Script script, boolean wrap) newArgumentError
(int got, int expected) Deprecated.UseError.argumentError(ThreadContext, int, int)
instead.newArgumentError
(int got, int min, int max) newArgumentError
(String message) newArgumentError
(String name, int got, int expected) Deprecated.newArgumentError
(String name, int got, int min, int max) Deprecated.newArray()
Deprecated.newArray
(int size) Deprecated.newArray
(List<IRubyObject> list) Deprecated.newArray
(IRubyObject object) Deprecated.newArray
(IRubyObject... objects) Deprecated.newArray
(IRubyObject car, IRubyObject cdr) Deprecated.Deprecated.newArrayNoCopy
(IRubyObject... objects) Deprecated.newArrayNoCopyLight
(IRubyObject... objects) Deprecated.newBinding
(Binding binding) newBlockPassProc
(Block.Type type, Block block) newBoolean
(boolean value) newBufferAccessError
(String message) newBufferAllocationError
(String message) newBufferInvalidatedError
(String message) newBufferLockedError
(String message) newBufferMaskError
(String message) newConcurrencyError
(String message) newConverterNotFoundError
(String message) newDeduplicatedString
(String string) Deprecated.newEncodingCompatibilityError
(String message) newEncodingError
(String message) newEOFError
(String message) newErrnoEACCESError
(String message) Deprecated.newErrnoEADDRFromBindException
(BindException be, String contextMessage) newErrnoEADDRINUSEError
(String message) newErrnoEADDRNOTAVAILError
(String message) newErrnoEAFNOSUPPORTError
(String message) newErrnoEAGAINError
(String message) newErrnoEAGAINReadableError
(String message) newErrnoEAGAINWritableError
(String message) newErrnoEBADFError
(String message) newErrnoECONNREFUSEDError
(String message) newErrnoEDOMError
(String message) newErrnoEEXISTError
(String message) newErrnoEHOSTUNREACHError
(String message) newErrnoEINPROGRESSError
(String message) newErrnoEINPROGRESSWritableError
(String message) newErrnoEINVALError
(String message) newErrnoEISCONNError
(String message) newErrnoEISDirError
(String message) newErrnoENOENTError
(String message) newErrnoENOTCONNError
(String message) newErrnoENOTDIRError
(String message) newErrnoENOTEMPTYError
(String message) newErrnoENOTSOCKError
(String message) newErrnoEOPNOTSUPPError
(String message) newErrnoEPERMError
(String name) newErrnoESPIPEError
(String message) newErrnoEXDEVError
(String message) newErrnoFromBindException
(BindException be, String contextMessage) newErrnoFromErrno
(jnr.constants.platform.Errno errno, String message) newErrnoFromInt
(int errno) newErrnoFromInt
(int errno, String message) newErrnoFromInt
(int errno, String methodName, String message) newFiberError
(String message) newFileStat
(FileDescriptor descriptor) newFileStat
(String filename, boolean lstat) newFixnum
(int value) newFixnum
(long value) newFixnum
(jnr.constants.Constant value) newFloat
(double value) newFloatDomainError
(String message) newFrozenError
(String objectType) Deprecated.newFrozenError
(String objectType, boolean runtimeError) Deprecated.newFrozenError
(String objectType, IRubyObject receiver) newFrozenError
(RubyModule type) Deprecated.newFrozenError
(IRubyObject receiver) newFrozenError
(IRubyObject receiver, String message) Deprecated.newIllegalSequence
(String message) Deprecated.newIndexError
(String message) static Ruby
Returns a new instance of the JRuby runtime configured with defaults.static Ruby
newInstance
(InputStream in, PrintStream out, PrintStream err) Returns a new instance of the JRuby runtime configured with the given input, output and error streams and otherwise default configuration (except where specified system properties alter defaults).static Ruby
newInstance
(RubyInstanceConfig config) Returns a new instance of the JRuby runtime configured as specified.newInterruptedRegexpError
(String message) newInvalidByteSequenceError
(String message) newInvalidEncoding
(String message) Deprecated.newIOError
(String message) Prepare a throwable IOError with the given message.Java does not give us enough information for specific error conditions so we are reduced to divining them through string matches...newKeyError
(String message, IRubyObject recv, IRubyObject key) newLoadError
(String message) newLoadError
(String message, String path) newLocalJumpError
(RubyLocalJumpError.Reason reason, IRubyObject exitValue, String message) newMathDomainError
(String message) newNameError
(String message, String name) Deprecated.newNameError
(String message, String name, Throwable origException) Deprecated.newNameError
(String message, String name, Throwable exception, boolean printWhenVerbose) Construct a NameError with the given pre-formatted message, name, and optional original exception.newNameError
(String message, IRubyObject name) Deprecated.newNameError
(String message, IRubyObject recv, String name) Construct a NameError that formats its message with an sprintf format string.newNameError
(String message, IRubyObject recv, String name, boolean privateCall) Construct a NameError that formats its message with an sprintf format string and has private_call? set to given.newNameError
(String message, IRubyObject name, Throwable exception, boolean printWhenVerbose) newNameError
(String message, IRubyObject recv, IRubyObject name) newNameError
(String message, IRubyObject recv, IRubyObject name, boolean privateCall) Construct a NameError that formats its message with an sprintf format string.newNoMethodError
(String message, String name, IRubyObject args) Construct a NoMethodError with a pre-formatted message.newNoMethodError
(String message, IRubyObject recv, String name, RubyArray args) newNoMethodError
(String message, IRubyObject recv, String name, RubyArray args, boolean privateCall) Construct a NoMethodError that formats its message with an sprintf format string.newNotImplementedError
(String message) newProc
(Block.Type type, Block block) newRaiseException
(RubyClass exceptionClass, String message) Construct a new RaiseException wrapping a new Ruby exception object appropriate to the given exception class.newRangeError
(String message) newRational
(long num, long den) newRationalReduced
(long num, long den) newRegexpError
(String message) newRuntimeError
(String message) newSecurityError
(String message) newStandardError
(String message) newStopIteration
(IRubyObject result, String message) Generate a StopIteration exception.Create a new Symbol or lookup a symbol from an ISO_8859_1 "id" String.newSyntaxError
(String message) newSyntaxError
(String message, String path) newSystemCallError
(String message) newSystemExit
(int status) newSystemExit
(int status, String message) newSystemStackError
(String message) newSystemStackError
(String message, StackOverflowError error) newThreadError
(String message) newTime
(long milliseconds) newTypeError
(String message) Deprecated.newTypeError
(IRubyObject receivedObject, String expectedType) Deprecated.newTypeError
(IRubyObject receivedObject, RubyClass expectedType) Deprecated.newTypeError
(IRubyObject receivedObject, RubyModule expectedType) Deprecated.newUndefinedConversionError
(String message) parse
(ByteList content, String file, DynamicScope scope, int lineNumber, boolean extraPositionInformation) Deprecated.parseEval
(String source, String file, DynamicScope scope, int lineNumber) Deprecated.parseEval
(ByteList source, String file, DynamicScope scope, int lineNumber) Deprecated.parseFile
(InputStream in, String file, DynamicScope scope) Deprecated.parseFile
(InputStream in, String file, DynamicScope scope, int lineNumber) Deprecated.parseFile
(String file, InputStream in, DynamicScope scope) Deprecated.parseFile
(String file, InputStream in, DynamicScope scope, int lineNumber) Deprecated.parseFileFromMain
(InputStream in, String file, DynamicScope scope) Deprecated.parseFileFromMain
(String file, InputStream in, DynamicScope scope) Deprecated.parseFromMain
(InputStream inputStream, String filename) Deprecated.parseFromMain
(String fileName, InputStream in) parseInline
(InputStream in, String file, DynamicScope scope) Deprecated.void
printError
(Throwable ex) Prints an exception to System.err.void
Prints a Ruby exception with backtrace to the configured stderr stream.void
printErrorString
(byte[] msg) Prints a string directly to the stderr channel, if default, or via dynamic dispatch otherwise.void
printErrorString
(String msg) Prints a string directly to the stderr channel, if default, or via dynamic dispatch otherwise.void
printProfileData
(ProfileCollection profileData) TDOD remove the synchronized.void
pushEndBlock
(RubyProc proc) It is possible for looping or repeated execution to encounter the same END block multiple times.pushExitBlock
(RubyProc proc) Push block onto exit stack.void
Add an exit function to be run on runtime exit.void
pushPostExitFunction
(Ruby.ExitFunction postExit) Add a post-termination exit function that should be run to shut down JRuby internal services.void
registerInspecting
(Object obj) void
void
By defaulttearDown(boolean)
does not release the class-loader's resources as threads might be still running accessing the classes/packages even after the runtime has been torn down.void
removeAllCallEventHooksFor
(ThreadContext context) Deprecated.void
removeEventHook
(EventHook hook) Deprecated.void
removeFinalizer
(Finalizable finalizer) void
removeInternalFinalizer
(Finalizable finalizer) void
runFromMain
(InputStream inputStream, String filename) Run the script contained in the specified input stream, using the specified filename as the name of the script being executed.runInterpreter
(Node scriptNode) runInterpreter
(ParseResult parseResult) runInterpreter
(ThreadContext context, Node rootNode, IRubyObject self) runInterpreter
(ThreadContext context, ParseResult parseResult, IRubyObject self) runInterpreterBody
(Node scriptNode) This is used for the "gets" loop, and we bypass 'load' to use an already-prepared, already-pushed scope for the script body.runNormally
(Node scriptNode) Deprecated.runNormally
(Node scriptNode, boolean wrap) Deprecated.runNormally
(Node scriptNode, IRubyObject self, boolean wrap) Deprecated.runNormally
(ParseResult scriptNode, IRubyObject self, boolean wrap) runScript
(Script script, IRubyObject self, boolean wrap) runScriptBody
(Script script) This is used for the "gets" loop, and we bypass 'load' to use an already-prepared, already-pushed scope for the script body.runWithGetsLoop
(ParseResult scriptNode, boolean printing, boolean processLineEnds, boolean split) Run the given script with a "while gets; end" loop wrapped around it.void
setAbortOnException
(boolean abortOnException) void
setArgsFile
(IRubyObject argsFile) void
setBaseNewMethod
(DynamicMethod baseNewMethod) Set the base Class#new method.void
setChdirThread
(RubyThread thread) void
void
setCurrentLine
(int line) void
setDateError
(RubyClass dateError) void
setDebug
(boolean debug) Sets the $DEBUG flagvoid
setDebug
(IRubyObject debug) Setter for property isDebug.void
setDefaultExternalEncoding
(org.jcodings.Encoding defaultExternalEncoding) void
setDefaultFilesystemEncoding
(org.jcodings.Encoding defaultFilesystemEncoding) void
setDefaultInternalEncoding
(org.jcodings.Encoding defaultInternalEncoding) void
setDefaultMethodMissing
(DynamicMethod method, DynamicMethod moduleMethod) void
setDefaultRandom
(RubyRandom random) void
setDoNotReverseLookupEnabled
(boolean b) void
Deprecated.void
setEtc
(RubyModule etcModule) void
void
setGlobalAbortOnExceptionEnabled
(boolean enable) Deprecated.void
setGroupStruct
(RubyClass groupStruct) void
setJRubyHome
(String home) void
void
setLocation
(RubyClass location) void
setNormalMethodMissing
(DynamicMethod method) void
setObjectSpaceEnabled
(boolean objectSpaceEnabled) void
setPasswdStruct
(RubyClass passwdStruct) void
setPrivateMethodMissing
(DynamicMethod method) void
void
setRecordSeparatorVar
(GlobalVariable recordSeparatorVar) void
setRegexpTimeoutError
(RubyClass error) void
setReportOnException
(boolean enable) void
setReportOnException
(IRubyObject enable) void
void
void
setRubyTimeout
(IRubyObject timeout) static void
setSecurityRestricted
(boolean restricted) void
setSuperMethodMissing
(DynamicMethod method) static void
setThreadLocalRuntime
(Ruby ruby) Set the thread-local runtime to the given runtime.void
setTopLevelBinding
(RubyBinding rubyBinding) void
setTraceFunction
(RubyProc traceFunction) Deprecated.void
setTraceFunction
(TraceEventManager.CallTraceFuncHook hook, RubyProc traceFunction) Deprecated.org.jcodings.Encoding
setupSourceEncoding
(org.jcodings.Encoding defaultEncoding) setupWrappedToplevel
(IRubyObject self, StaticScope top) void
void
setVerbose
(Boolean verbose) Sets the $VERBOSE levelvoid
setVerbose
(IRubyObject verbose) Sets the runtime verbosity ($VERBOSE global which usually gets set to nil/false or true).void
setWarningsEnabled
(boolean warningsEnabled) Setter that enables/disabled warnings (without changing verbose mode).void
tearDown()
Make sure Kernel#at_exit procs getService invoked on runtime shutdown.void
tearDown
(boolean systemExit) tryCompile
(Node node) Deprecated.tryCompile
(ParseResult result) Try to compile the code associated with the given Node, returning an instance of the successfully-compiled Script or null if the script could not be compiled.void
void
Convenience method for java integrators who may need to switch the notion of "global" runtime.boolean
If the user explicitly disabled warnings using:setWarningsEnabled(boolean)
return false.
-
Field Details
-
NIL_PREFILLED_ARRAY_SIZE
public static final int NIL_PREFILLED_ARRAY_SIZE- See Also:
-
ERRNO_BACKTRACE_MESSAGE
- See Also:
-
STOPIERATION_BACKTRACE_MESSAGE
- See Also:
-
POPULATORS
-
sites
-
-
Method Details
-
registerMBeans
public void registerMBeans() -
newInstance
Returns a new instance of the JRuby runtime configured with defaults.- Returns:
- the JRuby runtime
- See Also:
-
newInstance
Returns a new instance of the JRuby runtime configured as specified.- Parameters:
config
- The instance configuration- Returns:
- The JRuby runtime
- See Also:
-
newInstance
Returns a new instance of the JRuby runtime configured with the given input, output and error streams and otherwise default configuration (except where specified system properties alter defaults).- Parameters:
in
- the custom input streamout
- the custom output streamerr
- the custom error stream- Returns:
- the JRuby runtime
- See Also:
-
isGlobalRuntimeReady
public static boolean isGlobalRuntimeReady()Tests whether globalRuntime has been instantiated or not. This method is used by singleton model of org.jruby.embed.ScriptingContainer to decide what RubyInstanceConfig should be used. When a global runtime is not there, RubyInstanceConfig of AbstractContextProvider will be used to enact configurations set by a user. When a global runtime is already instantiated, RubyInstanceConfig of the global runtime should be used in ScriptingContaiener.- Returns:
- true if a global runtime is instantiated, false for other.
-
getGlobalRuntime
Get the global runtime.- Returns:
- the global runtime
-
useAsGlobalRuntime
public void useAsGlobalRuntime()Convenience method for java integrators who may need to switch the notion of "global" runtime. UseJRuby.runtime.use_as_global_runtime
from Ruby code to activate the current runtime as the global one. -
clearGlobalRuntime
public static void clearGlobalRuntime()Clear the global runtime. -
getThreadLocalRuntime
Get the thread-local runtime for the current thread, or null if unset.- Returns:
- the thread-local runtime, or null if unset
-
setThreadLocalRuntime
Set the thread-local runtime to the given runtime. Note that static threadlocals like this one can leak resources across (for example) application redeploys. If you use this, it is your responsibility to clean it up appropriately.- Parameters:
ruby
- the new runtime for thread-local
-
evalScriptlet
Evaluates a script under the current scope (perhaps the top-level scope) and returns the result (generally the last value calculated). This version goes straight into the interpreter, bypassing compilation and runtime preparation typical to normal script runs.- Parameters:
script
- The scriptlet to run- Returns:
- The result of the eval
-
evalScriptlet
Evaluates a script under the current scope (perhaps the top-level scope) and returns the result (generally the last value calculated). This version goes straight into the interpreter, bypassing compilation and runtime preparation typical to normal script runs. This version accepts a scope to use, so you can eval many times against the same scope.- Parameters:
script
- The scriptlet to runscope
- The scope to execute against (ManyVarsDynamicScope is recommended, so it can grow as needed)- Returns:
- The result of the eval
-
executeScript
Parse and execute the specified script This differs from the other methods in that it accepts a string-based script and parses and runs it as though it were loaded at a command-line. This is the preferred way to start up a new script when calling directly into the Ruby object (which is generally *dis*couraged. Note: This is used by compiler/java_class.rb- Parameters:
script
- The contents of the script to run as a normal, root script- Returns:
- The last value of the script
-
runFromMain
Run the script contained in the specified input stream, using the specified filename as the name of the script being executed. The stream will be read fully before being parsed and executed. The given filename will be used for the ruby $PROGRAM_NAME and $0 global variables in this runtime. This method is intended to be called once per runtime, generally from Main or from main-like top-level entry points. As part of executing the script loaded from the input stream, various RubyInstanceConfig properties will be used to determine whether to compile the script before execution or run with various wrappers (for looping, printing, and so on, see jruby -help).- Parameters:
inputStream
- The InputStream from which to read the script contentsfilename
- The filename to use when parsing, and for $PROGRAM_NAME and $0 ruby global variables.
-
parseFromMain
Deprecated.Parse the script contained in the given input stream, using the given filename as the name of the script, and return the root Node. This is used to verify that the script syntax is valid, for jruby -c. The current scope (generally the top-level scope) is used as the parent scope for parsing.- Parameters:
inputStream
- The input stream from which to read the scriptfilename
- The filename to use for parsing- Returns:
- The root node of the parsed script
-
parseFromMain
-
runWithGetsLoop
public IRubyObject runWithGetsLoop(ParseResult scriptNode, boolean printing, boolean processLineEnds, boolean split) Run the given script with a "while gets; end" loop wrapped around it. This is primarily used for the -n command-line flag, to allow writing a short script that processes input lines using the specified code.- Parameters:
scriptNode
- The root node of the script to executeprinting
- Whether $_ should be printed after each loop (as in the -p command-line flag)processLineEnds
- Whether line endings should be processed by setting $\ to $/ andchop!
ing every line readsplit
- Whether to split each line read usingString#split
bytecode before executing.- Returns:
- The result of executing the specified script
-
runNormally
Deprecated.Run the specified script without any of the loop-processing wrapper code.- Parameters:
scriptNode
- The root node of the script to be executed bytecode before executionwrap
- whether to wrap the execution in an anonymous module- Returns:
- The result of executing the script
-
runNormally
Deprecated. -
runNormally
-
runNormally
Deprecated.Run the specified script without any of the loop-processing wrapper code.- Parameters:
scriptNode
- The root node of the script to be executed bytecode before execution- Returns:
- The result of executing the script
-
tryCompile
Deprecated. -
tryCompile
Try to compile the code associated with the given Node, returning an instance of the successfully-compiled Script or null if the script could not be compiled.- Parameters:
result
- The result to attempt to compiled- Returns:
- an instance of the successfully-compiled Script, or null.
-
runScript
-
runScript
-
runScript
-
runScriptBody
This is used for the "gets" loop, and we bypass 'load' to use an already-prepared, already-pushed scope for the script body. -
runInterpreter
-
runInterpreter
-
runInterpreter
-
runInterpreter
-
runInterpreterBody
This is used for the "gets" loop, and we bypass 'load' to use an already-prepared, already-pushed scope for the script body. -
getParser
Deprecated. -
getBeanManager
-
getJITCompiler
-
getInlineStats
-
getCaches
Get the Caches management object.- Returns:
- the current runtime's Caches management object
-
allocSymbolId
public int allocSymbolId() -
allocModuleId
public int allocModuleId() -
addModule
A collection of all natural Module instances in the system. Instances of Module, which are themselves modules, do not have ancestors and can't be traversed by walking down from BasicObject. We track them separately here for purposes of ObjectSpace.each_object.- Parameters:
module
- the true module to add to the allModules collection
-
eachModule
Walk all natural Module instances in the system. This will only include direct instances of Module, not instances of Class.- Parameters:
func
- the consumer to call for each module
-
getModule
Deprecated. -
getClass
Deprecated.Retrieve the class with the given name from the Object namespace.- Parameters:
name
- The name of the class- Returns:
- The class
-
fastGetClass
Deprecated.Retrieve the class with the given name from the Object namespace. The module name must be an interned string, but this method will be faster than the non-interned version.- Parameters:
internedName
- the name of the class; must be an interned String!- Returns:
-
defineClass
@Deprecated(since="10.0") public RubyClass defineClass(String name, RubyClass superClass, ObjectAllocator allocator, CallSite[] callSites) Deprecated.A variation of defineClass that allows passing in an array of supplementary call sites for improving dynamic invocation performance.- Parameters:
name
- The name for the new classsuperClass
- The super class for the new classallocator
- An ObjectAllocator instance that can construct instances of the new class.- Returns:
- The new class
-
defineClass
@Deprecated(since="10.0") public RubyClass defineClass(String name, RubyClass superClass, ObjectAllocator allocator) Deprecated. -
defineClassUnder
@Deprecated(since="10.0") public RubyClass defineClassUnder(String name, RubyClass superClass, ObjectAllocator allocator, RubyModule parent) Deprecated.Define a new class with the given name under the given module or class namespace. Roughly equivalent to rb_define_class_under in MRI. If the name specified is already bound, its value will be returned if: * It is a class * No new superclass is being defined- Parameters:
name
- The name for the new classsuperClass
- The super class for the new classallocator
- An ObjectAllocator instance that can construct instances of the new class.parent
- The namespace under which to define the new class- Returns:
- The new class
-
defineClassUnder
@Deprecated(since="10.0") public RubyClass defineClassUnder(String id, RubyClass superClass, ObjectAllocator allocator, RubyModule parent, CallSite[] callSites) Deprecated. -
defineClassUnder
public RubyClass defineClassUnder(ThreadContext context, String id, RubyClass superClass, ObjectAllocator allocator, RubyModule parent, CallSite[] callSites) A variation of defineClassUnder that allows passing in an array of supplementary call sites to improve dynamic invocation. This is an internal API. Please useRubyModule.defineClassUnder(ThreadContext, String, RubyClass, ObjectAllocator)
instead.- Parameters:
context
- the current thread contextid
- The name for the new class as an ISO-8859_1 String (id-value)superClass
- The super class for the new classallocator
- An ObjectAllocator instance that can construct instances of the new class.parent
- The namespace under which to define the new classcallSites
- The array of call sites to add- Returns:
- The new class
-
defineModule
Deprecated.Define a new module under the Object namespace. Roughly equivalent to rb_define_module in MRI.- Parameters:
name
- The name of the new module- Returns:
- The new module
-
defineModuleBootstrap
This is only for defining kernel. The reason we have this is so all other define methods can count on ThreadContext being available. These are defined before that point.- Parameters:
name
- The name for the new class- Returns:
- The new module
-
defineModuleUnder
Deprecated. -
defineModuleUnder
Define a new module with the given name under the given module or class namespace. Roughly equivalent to rb_define_module_under in MRI. This is an internal API. It is still used in early bootstrapping for setting up Kernel since Kernel needs to exist before the first ThreadContext is created.- Parameters:
name
- The name of the new moduleparent
- The class or module namespace under which to define the module- Returns:
- The new module
-
getOrCreateModule
Deprecated.From Object, retrieve the named module. If it doesn't exist a new module is created.- Parameters:
id
- The name of the module- Returns:
- The existing or new module
-
getKCode
-
setKCode
-
defineGlobalConstant
Deprecated.UseRubyModule.defineConstant(ThreadContext, String, IRubyObject)
with a reference to Object.rb_define_global_const Define a constant on the global namespace (i.e. Object) with the given name and value.- Parameters:
name
- the namevalue
- the value
-
fetchGlobalConstant
Deprecated.Fetch a constant from the global namespace (i.e. Object) with the given name.- Parameters:
name
- the name- Returns:
- the value
-
isClassDefined
Deprecated. -
loadJavaSupport
-
getNilPrefilledArray
-
getErrno
-
getIRManager
-
getTopSelf
Getter for property rubyTopSelf.- Returns:
- Value of property rubyTopSelf.
-
setCurrentDirectory
-
getCurrentDirectory
-
setCurrentLine
public void setCurrentLine(int line) -
getCurrentLine
public int getCurrentLine() -
setArgsFile
-
getArgsFile
-
getEtc
Deprecated. -
setEtc
-
getObject
-
getBasicObject
-
getModule
-
getRefinement
-
getClassClass
-
getKernel
-
getPrivateMethodMissing
-
setPrivateMethodMissing
-
getProtectedMethodMissing
-
setProtectedMethodMissing
-
getVariableMethodMissing
-
setVariableMethodMissing
-
getSuperMethodMissing
-
setSuperMethodMissing
-
getNormalMethodMissing
-
setNormalMethodMissing
-
getDefaultMethodMissing
-
isDefaultMethodMissing
-
setDefaultMethodMissing
-
getRespondToMethod
-
setRespondToMethod
-
getRespondToMissingMethod
-
setRespondToMissingMethod
-
getDummy
-
getComparable
-
getNumeric
-
getFloat
-
getInteger
-
getFixnum
-
getComplex
-
getRational
-
getEnumerable
-
getEnumerator
-
getYielder
-
getGenerator
-
getChain
-
getArithmeticSequence
-
getProducer
-
getFiber
-
getString
-
getEncoding
-
getConverter
-
getSymbol
-
getArray
-
getHash
-
getRange
-
getTrue
Returns the "true" instance from the instance pool.- Returns:
- The "true" instance.
-
getTrueString
-
getNilString
-
getNilInspectString
-
getFalse
Returns the "false" instance from the instance pool.- Returns:
- The "false" instance.
-
getFalseString
-
getNil
Returns the "nil" singleton instance.- Returns:
- "nil"
-
getSingleNilArray
-
getNilClass
-
getTrueClass
-
getFalseClass
-
getProc
-
getBinding
-
getMethod
-
getUnboundMethod
-
getMatchData
-
getRegexp
-
getTime
-
getMath
-
getMarshal
-
getBignum
Deprecated.UseAccess.integerClass(ThreadContext)
instead.- Returns:
-
getDateError
-
setDateError
-
getDir
-
getFile
-
getFileStat
-
getFileTest
-
getIO
-
getIOBuffer
-
getThread
-
getThreadGroup
-
getDefaultThreadGroup
-
getContinuation
-
getStructClass
-
getRandomClass
-
getTmsStruct
-
getPasswdStruct
-
setPasswdStruct
-
getGroupStruct
-
setGroupStruct
-
getGC
-
getObjectSpaceModule
-
getProcess
-
getProcStatus
-
getProcUID
-
getProcGID
-
getProcSysModule
-
getPrecision
-
getENV
-
getLocation
-
setLocation
-
getMutex
-
getConditionVariable
-
getQueue
-
getClosedQueueError
-
getSizedQueueClass
-
getWarning
-
getErrno
-
getException
-
getNameError
-
getNameErrorMessage
-
getNoMethodError
-
getSignalException
-
getRangeError
-
getSystemExit
-
getLocalJumpError
-
getNativeException
-
getSystemCallError
-
getKeyError
-
getFatal
-
getInterrupt
-
getTypeError
-
getNoMatchingPatternError
-
getArgumentError
-
getUncaughtThrowError
-
getIndexError
-
getStopIteration
-
getSyntaxError
-
getStandardError
-
getRuntimeError
-
getFrozenError
-
getIOError
-
getIOTimeoutError
-
getLoadError
-
getNotImplementedError
-
getSecurityError
-
getNoMemoryError
-
getRegexpError
-
getInterruptedRegexpError
-
getEOFError
-
getThreadError
-
getConcurrencyError
-
getSystemStackError
-
getZeroDivisionError
-
getFloatDomainError
-
getMathDomainError
-
getEncodingError
-
getEncodingCompatibilityError
-
getConverterNotFoundError
-
getFiberError
-
getUndefinedConversionError
-
getInvalidByteSequenceError
-
getBufferLockedError
-
getBufferAllocationError
-
getBufferAccessError
-
getBufferInvalidatedError
-
getBufferMaskError
-
getData
-
getDefaultRandom
-
setDefaultRandom
-
getVerbose
- Returns:
- $VERBOSE value
-
isVerbose
public boolean isVerbose()- Returns:
- $VERBOSE value as a Java primitive
-
warningsEnabled
public boolean warningsEnabled()If the user explicitly disabled warnings using:setWarningsEnabled(boolean)
return false. Otherwise fallback to a $VERBOSE value check (which is the default behavior).- Returns:
- whether warnings are enabled
-
setWarningsEnabled
public void setWarningsEnabled(boolean warningsEnabled) Setter that enables/disabled warnings (without changing verbose mode).- Parameters:
warningsEnabled
-- See Also:
-
setVerbose
Sets the runtime verbosity ($VERBOSE global which usually gets set to nil/false or true).Note: warnings get enabled whenever the verbose level is set to a value that is not nil.
- Parameters:
verbose
- the verbose ruby value
-
setVerbose
Sets the $VERBOSE level- Parameters:
verbose
- null, true and false are all valid- See Also:
-
getDebug
- Returns:
- $DEBUG value
-
isDebug
public boolean isDebug()- Returns:
- $DEBUG value as a boolean
-
setDebug
Setter for property isDebug.- Parameters:
debug
- the $DEBUG value
-
setDebug
public void setDebug(boolean debug) Sets the $DEBUG flag- Parameters:
debug
-
-
getWarningCategories
Get the current enabled warning categories.- Returns:
- a set of the currently-enabled warning categories
-
getJavaSupport
-
getObjectSpecializer
-
getClassLoader
-
getJRubyClassLoader
-
defineVariable
Defines a global variable -
defineReadonlyVariable
defines a readonly global variable -
parseFile
Deprecated. -
parseFile
Deprecated. -
parseFile
Deprecated. -
parseFile
@Deprecated public ParseResult parseFile(String file, InputStream in, DynamicScope scope, int lineNumber) Deprecated. -
parseFileFromMain
Deprecated. -
parseFileFromMain
Deprecated. -
parseInline
Deprecated. -
setupSourceEncoding
public org.jcodings.Encoding setupSourceEncoding(org.jcodings.Encoding defaultEncoding) -
parseEval
Deprecated. -
parseEval
@Deprecated public ParseResult parseEval(ByteList source, String file, DynamicScope scope, int lineNumber) Deprecated. -
parse
@Deprecated public Node parse(ByteList content, String file, DynamicScope scope, int lineNumber, boolean extraPositionInformation) Deprecated. -
getThreadService
-
getCurrentContext
-
getLoadService
Returns the loadService.- Returns:
- ILoadService
-
getDefaultInternalEncoding
public org.jcodings.Encoding getDefaultInternalEncoding()This is an internal encoding if actually specified via default_internal= or passed in via -E.- Returns:
- null or encoding
-
setDefaultInternalEncoding
public void setDefaultInternalEncoding(org.jcodings.Encoding defaultInternalEncoding) -
getDefaultExternalEncoding
public org.jcodings.Encoding getDefaultExternalEncoding() -
setDefaultExternalEncoding
public void setDefaultExternalEncoding(org.jcodings.Encoding defaultExternalEncoding) -
getDefaultFilesystemEncoding
public org.jcodings.Encoding getDefaultFilesystemEncoding() -
setDefaultFilesystemEncoding
public void setDefaultFilesystemEncoding(org.jcodings.Encoding defaultFilesystemEncoding) -
getDefaultCharset
Get the default java.nio.charset.Charset for the current default internal encoding. -
getDefaultEncoding
public org.jcodings.Encoding getDefaultEncoding()Return the default internal encoding, if set, or UTF-8 by default.- Returns:
- the default encoding used for new Ruby strings
-
getEncodingService
-
getWarnings
-
getStderr
-
getOriginalStderr
Return the original stderr with which this runtime was initialized. Used for fast-path comparisons when printing error info directly to stderr.- Returns:
- the original stderr with which this runtime was initialized
-
getErrorStream
-
getInputStream
-
getOutputStream
-
getClassFromPath
-
getClassFromPath
public RubyModule getClassFromPath(String path, RubyClass undefinedExceptionClass, boolean flexibleSearch) Find module from a string (e.g. Foo, Foo::Bar::Car).- Parameters:
path
- the path to be searched.undefinedExceptionClass
- exception type to be thrown when it cannot be found.flexibleSearch
- use getConstant vs getConstantAt (former will find inherited constants from parents and fire const_missing).- Returns:
- the module or null when flexible search is false and a constant cannot be found.
-
printError
Prints a Ruby exception with backtrace to the configured stderr stream. MRI: eval.c - error_print() -
printError
Prints an exception to System.err.- Parameters:
ex
-
-
printErrorString
Prints a string directly to the stderr channel, if default, or via dynamic dispatch otherwise.- Parameters:
msg
- the string to print
-
printErrorString
public void printErrorString(byte[] msg) Prints a string directly to the stderr channel, if default, or via dynamic dispatch otherwise.- Parameters:
msg
- the string to print
-
loadFile
-
loadScope
-
compileAndLoadFile
-
setupWrappedToplevel
-
loadScript
-
loadScript
-
loadExtension
Load the given BasicLibraryService instance, wrapping it in Ruby framing to ensure it is isolated from any parent scope.- Parameters:
extName
- The name of the extension, to go on the frame wrapping itextension
- The extension object to loadwrap
- Whether to use a new "self" for toplevel
-
addBoundMethod
-
addBoundMethods
-
addBoundMethods
-
getBoundMethods
-
getTraceEvents
-
getGlobalVariables
-
pushExitFunction
Add an exit function to be run on runtime exit. Functions are run in FILO order.- Parameters:
func
- the function to be run
-
pushExitBlock
Push block onto exit stack. When runtime environment exits these blocks will be evaluated.- Returns:
- the element that was pushed onto stack
-
pushPostExitFunction
Add a post-termination exit function that should be run to shut down JRuby internal services. This will be run toward the end of teardown, after all user code has finished executing (e.g. at_exit hooks and user-defined finalizers). The exit functions registered here are run in FILO order.- Parameters:
postExit
- theRuby.ExitFunction
to run after user exit hooks have completed
-
pushEndBlock
It is possible for looping or repeated execution to encounter the same END block multiple times. Rather than store extra runtime state we will just make sure it is not already registered. at_exit by contrast can push the same block many times (and should use pushExitBlock). -
addInternalFinalizer
-
addFinalizer
-
removeInternalFinalizer
-
removeFinalizer
-
tearDown
public void tearDown()Make sure Kernel#at_exit procs getService invoked on runtime shutdown. This method needs to be explicitly called to work properly. I thought about using finalize(), but that did not work and I am not sure the runtime will be at a state to run procs by the time Ruby is going away. This method can contain any other things that need to be cleaned up at shutdown. -
tearDown
public void tearDown(boolean systemExit) -
releaseClassLoader
public void releaseClassLoader()By defaulttearDown(boolean)
does not release the class-loader's resources as threads might be still running accessing the classes/packages even after the runtime has been torn down. This method exists to handle such cases, e.g. with embedded uses we always release the runtime loader but not otherwise - you should do that manually. -
printProfileData
TDOD remove the synchronized. Synchronization should be a implementation detail of the ProfilingService.- Parameters:
profileData
-
-
getProfilingService
- Returns:
- the, for this ruby instance, configured implementation of ProfilingService, or null
-
newEmptyArray
Deprecated. -
newArray
Deprecated. -
newArrayLight
Deprecated. -
newArray
Deprecated. -
newArray
Deprecated. -
newArray
Deprecated. -
newArrayNoCopy
Deprecated. -
newArrayNoCopyLight
Deprecated. -
newArray
Deprecated. -
newArray
Deprecated. -
getEmptyFrozenArray
-
getEmptyFrozenString
-
newBoolean
-
newFileStat
-
newFileStat
-
newFixnum
-
newFixnum
-
newFixnum
-
newFloat
-
newNumeric
-
newRational
-
newRationalReduced
-
newProc
-
newBlockPassProc
-
newBinding
-
newBinding
-
newString
-
newString
-
newDeduplicatedString
-
newString
-
newSymbol
Create a new Symbol or lookup a symbol from an ISO_8859_1 "id" String. This is more of an internal method where if you had, for example, a multi-byte string in UTF-8 then you would dump those bytes into a String with a charset of ISO_8859_1. These raw bytes are considered the "id" of the symbol. Our internal symbol table is based on ISO_8859_1 raw string values which can return back the properly encoded Symbol instance.- Parameters:
name
- raw bytes to store into the symbol table or use to lookup an existing symbol.- Returns:
- A Ruby Symbol representing the name/id.
-
newSymbol
-
newSymbol
-
fastNewSymbol
Faster thannewSymbol(String)
if you already have an interned name String. Don't intern your string just to call this version - the overhead of interning will more than wipe out any benefit from the faster lookup.- Parameters:
internedName
- the symbol name, must be interned! if in doubt, callnewSymbol(String)
instead.- Returns:
- the symbol for name
-
newTime
-
newRuntimeError
-
newArgumentError
-
newArgumentError
Deprecated.UseError.argumentError(ThreadContext, int, int)
instead.- Parameters:
got
-expected
-- Returns:
-
newArgumentError
-
newArgumentError
@Deprecated(since="10.0") public RaiseException newArgumentError(String name, int got, int expected) Deprecated. -
newArgumentError
@Deprecated(since="10.0") public RaiseException newArgumentError(String name, int got, int min, int max) Deprecated. -
newErrnoEBADFError
-
newErrnoEISCONNError
-
newErrnoEINPROGRESSError
-
newErrnoEINPROGRESSWritableError
-
newErrnoENOPROTOOPTError
-
newErrnoEPIPEError
-
newErrnoECONNABORTEDError
-
newErrnoECONNREFUSEDError
-
newErrnoECONNREFUSEDError
-
newErrnoECONNRESETError
-
newErrnoEADDRINUSEError
-
newErrnoEADDRINUSEError
-
newErrnoEHOSTUNREACHError
-
newErrnoEINVALError
-
newErrnoELOOPError
-
newErrnoEMFILEError
-
newErrnoENFILEError
-
newErrnoENOENTError
-
newErrnoEACCESError
-
newErrnoEAGAINError
-
newErrnoEAGAINReadableError
-
newErrnoEAGAINWritableError
-
newErrnoEISDirError
-
newErrnoEPERMError
-
newErrnoEISDirError
-
newErrnoESPIPEError
-
newErrnoEBADFError
-
newErrnoEINPROGRESSError
-
newErrnoEINPROGRESSWritableError
-
newErrnoEISCONNError
-
newErrnoEINVALError
-
newErrnoENOTDIRError
-
newErrnoENOTEMPTYError
-
newErrnoENOTSOCKError
-
newErrnoENOTCONNError
-
newErrnoENOTCONNError
-
newErrnoENOENTError
-
newErrnoEOPNOTSUPPError
-
newErrnoESPIPEError
-
newErrnoEEXISTError
-
newErrnoEDOMError
-
newErrnoEDOMError
-
newErrnoECHILDError
-
newErrnoEADDRNOTAVAILError
-
newErrnoESRCHError
-
newErrnoEWOULDBLOCKError
-
newErrnoEDESTADDRREQError
-
newErrnoENETUNREACHError
-
newErrnoEMSGSIZEError
-
newErrnoEXDEVError
-
newIndexError
-
newSecurityError
-
newSystemCallError
-
newKeyError
-
newErrnoEINTRError
-
newErrnoEAFNOSUPPORTError
-
newErrnoETIMEDOUTError
-
newErrnoFromLastPOSIXErrno
-
newErrnoFromInt
-
newErrnoFromInt
-
newErrnoFromErrno
-
newErrnoFromInt
-
newErrnoFromBindException
-
newErrnoEADDRFromBindException
-
newTypeError
Deprecated. -
newThreadError
-
newConcurrencyError
-
newSyntaxError
-
newSyntaxError
-
newRegexpError
-
newInterruptedRegexpError
-
newRangeError
-
newNotImplementedError
-
newInvalidEncoding
Deprecated. -
newIllegalSequence
Deprecated. -
newNameError
- See Also:
-
newNameError
public RaiseException newNameError(String message, IRubyObject recv, IRubyObject name, boolean privateCall) Construct a NameError that formats its message with an sprintf format string. The arguments given to sprintf are as follows: 0: the name that failed 1: the receiver object that failed 2: a ":" character for non-singleton recv, blank otherwise 3: the name of the a non-singleton recv's class, blank if recv is a singleton Passing a string with no format characters will warn in verbose mode and error in debug mode. See jruby/jruby#3934.- Parameters:
message
- an sprintf format string for the messagerecv
- the receiver objectname
- the name that failedprivateCall
- whether the failure was due to method visibility- Returns:
- a new NameError
-
newNameError
Construct a NameError that formats its message with an sprintf format string. This version just accepts a java.lang.String for the name.- See Also:
-
newNameError
public RaiseException newNameError(String message, IRubyObject recv, String name, boolean privateCall) Construct a NameError that formats its message with an sprintf format string and has private_call? set to given. This version just accepts a java.lang.String for the name.- See Also:
-
newNameError
public RaiseException newNameError(String message, String name, Throwable exception, boolean printWhenVerbose) Construct a NameError with the given pre-formatted message, name, and optional original exception. If the original exception is given, and either we are in verbose mode with printWhenVerbose set to true or we are in debug mode.- Parameters:
message
- the pre-formatted message for the NameErrorname
- the name that failedexception
- the original exception, or nullprintWhenVerbose
- whether to log this exception when verbose mode is enabled- Returns:
- a new NameError
-
newNameError
public RaiseException newNameError(String message, IRubyObject name, Throwable exception, boolean printWhenVerbose) -
newNameError
Deprecated.Construct a NameError with a pre-formatted message and name.- Parameters:
message
- the pre-formatted message for the errorname
- the name that failed- Returns:
- a new NameError
-
newNameError
Deprecated. -
newNameError
@Deprecated(since="10.0") public RaiseException newNameError(String message, String name, Throwable origException) Deprecated.Construct a NameError with an optional originating exception and a pre-formatted message. This is the same as callingnewNameError(String, String, Throwable, boolean)
with a null originating exception and false for verbose-mode logging.- Parameters:
message
- a formatted string message for the errorname
- the name that failedorigException
- the original exception, or null if none- Returns:
- a new NameError
-
newNoMethodError
public RaiseException newNoMethodError(String message, IRubyObject recv, String name, RubyArray args) - See Also:
-
newNoMethodError
public RaiseException newNoMethodError(String message, IRubyObject recv, String name, RubyArray args, boolean privateCall) Construct a NoMethodError that formats its message with an sprintf format string. This works likenewNameError(String, IRubyObject, IRubyObject)
but accepts a java.lang.String for name and a RubyArray of the original call arguments.- Returns:
- a new NoMethodError
- See Also:
-
newNoMethodError
Construct a NoMethodError with a pre-formatted message.- Parameters:
message
- the pre-formatted messagename
- the name that failedargs
- the original arguments to the call that failed- Returns:
- a new NoMethodError
-
newLocalJumpError
public RaiseException newLocalJumpError(RubyLocalJumpError.Reason reason, IRubyObject exitValue, String message) -
newLocalJumpErrorNoBlock
-
newRedoLocalJumpError
-
newLoadError
-
newLoadError
-
newFrozenError
-
newFrozenError
@Deprecated(since="10.0") public RaiseException newFrozenError(IRubyObject receiver, String message) Deprecated. -
newFrozenError
-
newSystemStackError
-
newSystemStackError
-
newSystemExit
-
newSystemExit
-
newIOError
Prepare a throwable IOError with the given message. This constructor should not be used to create a RubyException object to be raised on a different thread.- Parameters:
message
- the message for the new IOError- Returns:
- a fully-prepared IOError throwable
- See Also:
-
newStandardError
-
newIOErrorFromException
Java does not give us enough information for specific error conditions so we are reduced to divining them through string matches... TODO: Should ECONNABORTED get thrown earlier in the descriptor itself or is it ok to handle this late? TODO: Should we include this into Errno code somewhere do we can use this from other places as well? -
newTypeError
Deprecated. -
newTypeError
Deprecated. -
newTypeError
Deprecated. -
newEOFError
-
newEOFError
-
newZeroDivisionError
-
newFloatDomainError
-
newMathDomainError
-
newEncodingError
-
newEncodingCompatibilityError
-
newConverterNotFoundError
-
newFiberError
-
newUndefinedConversionError
-
newInvalidByteSequenceError
-
newBufferLockedError
-
newBufferAllocationError
-
newBufferAccessError
-
newBufferInvalidatedError
-
newBufferMaskError
-
newRaiseException
Construct a new RaiseException wrapping a new Ruby exception object appropriate to the given exception class. There are additional forms of this construction logic inRaiseException.from(org.jruby.Ruby, org.jruby.RubyClass, java.lang.String)
. This constructor should not be used to create a RubyException object to be raised on a different thread.- Parameters:
exceptionClass
- the exception class from which to construct the exception objectmessage
- a simple message for the exception- Returns:
- a new RaiseException wrapping a new Ruby exception
- See Also:
-
newStopIteration
Generate a StopIteration exception. This differs from the normal logic by avoiding the generation of a backtrace. StopIteration is used by Enumerator to end an external iteration, and so generating a full backtrace is usually unreasonable overhead. The flag -Xstop_iteration.backtrace=true or the property jruby.stop_iteration.backtrace=true forces all StopIteration exceptions to generate a backtrace.- Parameters:
message
- the message for the exception
-
newData
-
getSymbolTable
-
getObjectSpace
-
getIn
-
getOut
-
getErr
-
isAbortOnException
public boolean isAbortOnException() -
setAbortOnException
public void setAbortOnException(boolean abortOnException) -
isGlobalAbortOnExceptionEnabled
Deprecated. -
setGlobalAbortOnExceptionEnabled
Deprecated. -
getReportOnException
Deprecated. -
isReportOnException
public boolean isReportOnException() -
setReportOnException
-
setReportOnException
public void setReportOnException(boolean enable) -
isDoNotReverseLookupEnabled
public boolean isDoNotReverseLookupEnabled() -
setDoNotReverseLookupEnabled
public void setDoNotReverseLookupEnabled(boolean b) -
registerInspecting
-
isInspecting
-
unregisterInspecting
-
isObjectSpaceEnabled
public boolean isObjectSpaceEnabled() -
setObjectSpaceEnabled
public void setObjectSpaceEnabled(boolean objectSpaceEnabled) -
isSiphashEnabled
public boolean isSiphashEnabled() -
getStartTime
public long getStartTime() -
getProfile
-
getJRubyHome
-
setJRubyHome
-
getInstanceConfig
-
isSecurityRestricted
public static boolean isSecurityRestricted() -
setSecurityRestricted
public static void setSecurityRestricted(boolean restricted) -
getPosix
public jnr.posix.POSIX getPosix() -
getNativePosix
public jnr.posix.POSIX getNativePosix()Get the native POSIX associated with this runtime. If native is not supported, this will return null.- Returns:
- a native POSIX, or null if native is not supported
-
setRecordSeparatorVar
-
getRecordSeparatorVar
-
getExecutor
-
getFiberExecutor
-
getTimezoneCache
-
getConstantInvalidator
-
getCheckpointInvalidator
-
loadConstantSet
@Deprecated(since="10.0") public <C extends Enum<C> & jnr.constants.Constant> void loadConstantSet(RubyModule module, Class<C> enumClass) Deprecated.UseRubyModule.defineConstantsFrom(ThreadContext, Class)
instead.Define all constants from the given jnr-constants enum which are defined on the current platform.- Type Parameters:
C
- the enum type, which must implementConstant
.- Parameters:
module
- the module in which we want to define the constantsenumClass
- the enum class of the constants to define
-
loadConstantSet
Deprecated.Define all constants from the named jnr-constants set which are defined on the current platform.- Parameters:
module
- the module in which we want to define the constantsconstantSetName
- the name of the constant set from which to get the constants
-
getNextDynamicMethodSerial
public long getNextDynamicMethodSerial()Get a new serial number for a new DynamicMethod instance- Returns:
- a new serial number
-
getNextModuleGeneration
public int getNextModuleGeneration()Get a new generation number for a module or class.- Returns:
- a new generation number
-
getHierarchyLock
Get the global object used to synchronize class-hierarchy modifications like cache invalidation, subclass sets, and included hierarchy sets.- Returns:
- The object to use for locking when modifying the hierarchy
-
getSelectorPool
Get the runtime-global selector pool- Returns:
- a SelectorPool from which to getService Selector instances
-
getRuntimeCache
Get the core class RuntimeCache instance, for doing dynamic calls from core class methods. -
getCachedStrptimePattern
-
incrementExceptionCount
public void incrementExceptionCount()Increment the count of exceptions generated by code in this runtime. -
getExceptionCount
public int getExceptionCount()Get the current exception count.- Returns:
- he current exception count
-
incrementBacktraceCount
public void incrementBacktraceCount()Increment the count of backtraces generated by code in this runtime. -
getBacktraceCount
public int getBacktraceCount()Get the current backtrace count.- Returns:
- the current backtrace count
-
incrementWarningCount
public void incrementWarningCount()Increment the count of backtraces generated for warnings in this runtime. -
getWarningCount
public int getWarningCount()Get the current backtrace count.- Returns:
- the current backtrace count
-
incrementCallerCount
public void incrementCallerCount()Increment the count of backtraces generated by code in this runtime. -
getCallerCount
public int getCallerCount()Get the current backtrace count.- Returns:
- the current backtrace count
-
isBootingCore
public boolean isBootingCore() -
isBooting
public boolean isBooting() -
getCoverageData
-
isCoverageEnabled
public boolean isCoverageEnabled() -
getHashSeedK0
public long getHashSeedK0() -
getHashSeedK1
public long getHashSeedK1() -
getStaticScopeFactory
-
getFFI
-
setFFI
-
getDefinedMessage
-
getThreadStatus
-
freezeAndDedupString
Given a Ruby string, cache a deduplicated FString version of it, or find an existing copy already prepared. This is used to reduce in-memory duplication of pre-frozen or known-frozen strings. If the incoming string is already an FString, attempt to cache it directly without creating a new instance. The logic here reads like this: 1. If the string is not a natural String object, just freeze and return it. 2. Use anRuby.FStringEqual
wrapper to look up the deduplicated string. 3. If there's a dedup in the cache, return the dedup. 4. Otherwise, attempt to cache and return an FString version of the string.- Parameters:
string
- the string to deduplicate if an equivalent does not already exist- Returns:
- the deduplicated FString version of the string
- See Also:
-
freezeAndDedupString
Given a ByteList, cache a deduplicated FString version of it, or find an existing copy already prepared. This is equivalent to callingfreezeAndDedupString(RubyString)
with a new FString based on the given ByteList.- Parameters:
bytes
- the ByteList to deduplicate if an equivalent does not already exist- Returns:
- the deduplicated FString version of the ByteList
-
getParserManager
-
defineDATA
-
setTopLevelBinding
-
getTopLevelBinding
-
setRubyTimeout
-
getRubyTimeout
-
setRegexpTimeoutError
-
getRegexpTimeoutError
-
setChdirThread
-
getChdirThread
-
getChdirLocation
-
getRuntimeNumber
public int getRuntimeNumber() -
constant
- Specified by:
constant
in interfaceConstantizable
- See Also:
-
setBaseNewMethod
Set the base Class#new method.- Parameters:
baseNewMethod
-
-
getBaseNewMethod
Get the base Class#new method.- Returns:
- the base Class#new method
-
getNullToNilHandle
Get the "nullToNil" method handle filter for this runtime.- Returns:
- a method handle suitable for filtering a single IRubyObject value from null to nil
-
getNullToUndefinedHandle
-
getFilenoUtil
-
getJavaExtensionDefinitions
- Returns:
- Class$ -> extension initializer map
Note: Internal API, subject to change!
-
addToObjectSpace
-
newErrnoEADDRFromBindException
Deprecated. -
newFrozenError
Deprecated. -
newFrozenError
Deprecated. -
newFrozenError
Deprecated. -
addEventHook
Deprecated. -
removeEventHook
Deprecated. -
setTraceFunction
Deprecated. -
setTraceFunction
@Deprecated public void setTraceFunction(TraceEventManager.CallTraceFuncHook hook, RubyProc traceFunction) Deprecated. -
removeAllCallEventHooksFor
Deprecated. -
callEventHooks
@Deprecated public void callEventHooks(ThreadContext context, RubyEvent event, String file, int line, String name, IRubyObject type) Deprecated. -
hasEventHooks
Deprecated. -
setENV
Deprecated.
-
RubyModule.defineConstant(ThreadContext, String, IRubyObject)
with a reference to Object.