Package org.jruby

Class Ruby

java.lang.Object
org.jruby.Ruby
All Implemented Interfaces:
Constantizable

public final class Ruby extends Object implements 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.
  • Field Details

  • Method Details

    • registerMBeans

      public void registerMBeans()
    • newInstance

      public static Ruby newInstance()
      Returns a new instance of the JRuby runtime configured with defaults.
      Returns:
      the JRuby runtime
      See Also:
    • newInstance

      public static Ruby newInstance(RubyInstanceConfig config)
      Returns a new instance of the JRuby runtime configured as specified.
      Parameters:
      config - The instance configuration
      Returns:
      The JRuby runtime
      See Also:
    • newInstance

      public 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).
      Parameters:
      in - the custom input stream
      out - the custom output stream
      err - 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

      public static Ruby 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. Use JRuby.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

      public static Ruby getThreadLocalRuntime()
      Get the thread-local runtime for the current thread, or null if unset.
      Returns:
      the thread-local runtime, or null if unset
    • setThreadLocalRuntime

      public static void setThreadLocalRuntime(Ruby ruby)
      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

      public IRubyObject evalScriptlet(String script)
      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

      public IRubyObject 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). 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 run
      scope - The scope to execute against (ManyVarsDynamicScope is recommended, so it can grow as needed)
      Returns:
      The result of the eval
    • executeScript

      public IRubyObject 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. 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

      public 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. 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 contents
      filename - The filename to use when parsing, and for $PROGRAM_NAME and $0 ruby global variables.
    • parseFromMain

      @Deprecated public Node parseFromMain(InputStream inputStream, String filename)
      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 script
      filename - The filename to use for parsing
      Returns:
      The root node of the parsed script
    • parseFromMain

      public ParseResult parseFromMain(String fileName, InputStream in)
    • 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 execute
      printing - Whether $_ should be printed after each loop (as in the -p command-line flag)
      processLineEnds - Whether line endings should be processed by setting $\ to $/ and chop!ing every line read
      split - Whether to split each line read using String#split bytecode before executing.
      Returns:
      The result of executing the specified script
    • runNormally

      @Deprecated public IRubyObject runNormally(Node scriptNode, boolean wrap)
      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
      wrap - whether to wrap the execution in an anonymous module
      Returns:
      The result of executing the script
    • runNormally

      @Deprecated public IRubyObject runNormally(Node scriptNode, IRubyObject self, boolean wrap)
      Deprecated.
    • runNormally

      public IRubyObject runNormally(ParseResult scriptNode, IRubyObject self, boolean wrap)
    • runNormally

      @Deprecated public IRubyObject runNormally(Node scriptNode)
      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 public Script tryCompile(Node node)
      Deprecated.
    • tryCompile

      public Script 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.
      Parameters:
      result - The result to attempt to compiled
      Returns:
      an instance of the successfully-compiled Script, or null.
    • runScript

      public IRubyObject runScript(Script script)
    • runScript

      public IRubyObject runScript(Script script, boolean wrap)
    • runScript

      public IRubyObject runScript(Script script, IRubyObject self, boolean wrap)
    • runScriptBody

      public IRubyObject 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.
    • runInterpreter

      public IRubyObject runInterpreter(ThreadContext context, ParseResult parseResult, IRubyObject self)
    • runInterpreter

      public IRubyObject runInterpreter(ThreadContext context, Node rootNode, IRubyObject self)
    • runInterpreter

      public IRubyObject runInterpreter(Node scriptNode)
    • runInterpreter

      public IRubyObject runInterpreter(ParseResult parseResult)
    • runInterpreterBody

      public IRubyObject 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.
    • getParser

      @Deprecated public Parser getParser()
      Deprecated.
    • getBeanManager

      public BeanManager getBeanManager()
    • getJITCompiler

      public JITCompiler getJITCompiler()
    • getInlineStats

      public InlineStats getInlineStats()
    • getCaches

      public Caches getCaches()
      Get the Caches management object.
      Returns:
      the current runtime's Caches management object
    • allocSymbolId

      public int allocSymbolId()
    • allocModuleId

      public int allocModuleId()
    • addModule

      public void addModule(RubyModule module)
      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

      public void eachModule(Consumer<RubyModule> func)
      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(since="10.0") public RubyModule getModule(String name)
      Deprecated.
    • getClass

      @Deprecated(since="10.0") public RubyClass getClass(String name)
      Deprecated.
      Retrieve the class with the given name from the Object namespace.
      Parameters:
      name - The name of the class
      Returns:
      The class
    • fastGetClass

      @Deprecated public RubyClass fastGetClass(String internedName)
      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 class
      superClass - The super class for the new class
      allocator - 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 class
      superClass - The super class for the new class
      allocator - 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 use RubyModule.defineClassUnder(ThreadContext, String, RubyClass, ObjectAllocator) instead.
      Parameters:
      context - the current thread context
      id - The name for the new class as an ISO-8859_1 String (id-value)
      superClass - The super class for the new class
      allocator - An ObjectAllocator instance that can construct instances of the new class.
      parent - The namespace under which to define the new class
      callSites - The array of call sites to add
      Returns:
      The new class
    • defineModule

      @Deprecated(since="10.0") public RubyModule defineModule(String name)
      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

      public RubyModule defineModuleBootstrap(String name)
      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(since="10.0") public RubyModule defineModuleUnder(String name, RubyModule parent)
      Deprecated.
    • defineModuleUnder

      public RubyModule defineModuleUnder(ThreadContext context, String name, RubyModule parent)
      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 module
      parent - The class or module namespace under which to define the module
      Returns:
      The new module
    • getOrCreateModule

      @Deprecated(since="10.0") public RubyModule getOrCreateModule(String id)
      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

      public KCode getKCode()
    • setKCode

      public void setKCode(KCode kcode)
    • defineGlobalConstant

      @Deprecated(since="10.0") public void defineGlobalConstant(String name, IRubyObject value)
      Deprecated.
      rb_define_global_const Define a constant on the global namespace (i.e. Object) with the given name and value.
      Parameters:
      name - the name
      value - the value
    • fetchGlobalConstant

      @Deprecated(since="10.0") public IRubyObject fetchGlobalConstant(String name)
      Deprecated.
      Fetch a constant from the global namespace (i.e. Object) with the given name.
      Parameters:
      name - the name
      Returns:
      the value
    • isClassDefined

      @Deprecated(since="10.0") public boolean isClassDefined(String name)
      Deprecated.
    • loadJavaSupport

      public JavaSupport loadJavaSupport()
    • getNilPrefilledArray

      public IRubyObject[] getNilPrefilledArray()
    • getErrno

      public RubyClass getErrno(int n)
    • getIRManager

      public IRManager getIRManager()
    • getTopSelf

      public IRubyObject getTopSelf()
      Getter for property rubyTopSelf.
      Returns:
      Value of property rubyTopSelf.
    • setCurrentDirectory

      public void setCurrentDirectory(String dir)
    • getCurrentDirectory

      public String getCurrentDirectory()
    • setCurrentLine

      public void setCurrentLine(int line)
    • getCurrentLine

      public int getCurrentLine()
    • setArgsFile

      public void setArgsFile(IRubyObject argsFile)
    • getArgsFile

      public IRubyObject getArgsFile()
    • getEtc

      @Deprecated(since="10.0") public RubyModule getEtc()
      Deprecated.
    • setEtc

      public void setEtc(RubyModule etcModule)
    • getObject

      public RubyClass getObject()
    • getBasicObject

      public RubyClass getBasicObject()
    • getModule

      public RubyClass getModule()
    • getRefinement

      public RubyClass getRefinement()
    • getClassClass

      public RubyClass getClassClass()
    • getKernel

      public RubyModule getKernel()
    • getPrivateMethodMissing

      public DynamicMethod getPrivateMethodMissing()
    • setPrivateMethodMissing

      public void setPrivateMethodMissing(DynamicMethod method)
    • getProtectedMethodMissing

      public DynamicMethod getProtectedMethodMissing()
    • setProtectedMethodMissing

      public void setProtectedMethodMissing(DynamicMethod method)
    • getVariableMethodMissing

      public DynamicMethod getVariableMethodMissing()
    • setVariableMethodMissing

      public void setVariableMethodMissing(DynamicMethod method)
    • getSuperMethodMissing

      public DynamicMethod getSuperMethodMissing()
    • setSuperMethodMissing

      public void setSuperMethodMissing(DynamicMethod method)
    • getNormalMethodMissing

      public DynamicMethod getNormalMethodMissing()
    • setNormalMethodMissing

      public void setNormalMethodMissing(DynamicMethod method)
    • getDefaultMethodMissing

      public DynamicMethod getDefaultMethodMissing()
    • isDefaultMethodMissing

      public boolean isDefaultMethodMissing(DynamicMethod method)
    • setDefaultMethodMissing

      public void setDefaultMethodMissing(DynamicMethod method, DynamicMethod moduleMethod)
    • getRespondToMethod

      public DynamicMethod getRespondToMethod()
    • setRespondToMethod

      public void setRespondToMethod(DynamicMethod rtm)
    • getRespondToMissingMethod

      public DynamicMethod getRespondToMissingMethod()
    • setRespondToMissingMethod

      public void setRespondToMissingMethod(DynamicMethod rtmm)
    • getDummy

      public RubyClass getDummy()
    • getComparable

      public RubyModule getComparable()
    • getNumeric

      public RubyClass getNumeric()
    • getFloat

      public RubyClass getFloat()
    • getInteger

      public RubyClass getInteger()
    • getFixnum

      public RubyClass getFixnum()
    • getComplex

      public RubyClass getComplex()
    • getRational

      public RubyClass getRational()
    • getEnumerable

      public RubyModule getEnumerable()
    • getEnumerator

      public RubyClass getEnumerator()
    • getYielder

      public RubyClass getYielder()
    • getGenerator

      public RubyClass getGenerator()
    • getChain

      public RubyClass getChain()
    • getArithmeticSequence

      public RubyClass getArithmeticSequence()
    • getProducer

      public RubyClass getProducer()
    • getFiber

      public RubyClass getFiber()
    • getString

      public RubyClass getString()
    • getEncoding

      public RubyClass getEncoding()
    • getConverter

      public RubyClass getConverter()
    • getSymbol

      public RubyClass getSymbol()
    • getArray

      public RubyClass getArray()
    • getHash

      public RubyClass getHash()
    • getRange

      public RubyClass getRange()
    • getTrue

      public RubyBoolean getTrue()
      Returns the "true" instance from the instance pool.
      Returns:
      The "true" instance.
    • getTrueString

      public RubyString getTrueString()
    • getNilString

      public RubyString getNilString()
    • getNilInspectString

      public RubyString getNilInspectString()
    • getFalse

      public RubyBoolean getFalse()
      Returns the "false" instance from the instance pool.
      Returns:
      The "false" instance.
    • getFalseString

      public RubyString getFalseString()
    • getNil

      public IRubyObject getNil()
      Returns the "nil" singleton instance.
      Returns:
      "nil"
    • getSingleNilArray

      public IRubyObject[] getSingleNilArray()
    • getNilClass

      public RubyClass getNilClass()
    • getTrueClass

      public RubyClass getTrueClass()
    • getFalseClass

      public RubyClass getFalseClass()
    • getProc

      public RubyClass getProc()
    • getBinding

      public RubyClass getBinding()
    • getMethod

      public RubyClass getMethod()
    • getUnboundMethod

      public RubyClass getUnboundMethod()
    • getMatchData

      public RubyClass getMatchData()
    • getRegexp

      public RubyClass getRegexp()
    • getTime

      public RubyClass getTime()
    • getMath

      public RubyModule getMath()
    • getMarshal

      public RubyModule getMarshal()
    • getBignum

      @Deprecated(since="10.0") public RubyClass getBignum()
      Deprecated.
      Returns:
    • getDateError

      public RubyClass getDateError()
    • setDateError

      public void setDateError(RubyClass dateError)
    • getDir

      public RubyClass getDir()
    • getFile

      public RubyClass getFile()
    • getFileStat

      public RubyClass getFileStat()
    • getFileTest

      public RubyModule getFileTest()
    • getIO

      public RubyClass getIO()
    • getIOBuffer

      public RubyClass getIOBuffer()
    • getThread

      public RubyClass getThread()
    • getThreadGroup

      public RubyClass getThreadGroup()
    • getDefaultThreadGroup

      public RubyThreadGroup getDefaultThreadGroup()
    • getContinuation

      public RubyClass getContinuation()
    • getStructClass

      public RubyClass getStructClass()
    • getRandomClass

      public RubyClass getRandomClass()
    • getTmsStruct

      public IRubyObject getTmsStruct()
    • getPasswdStruct

      public IRubyObject getPasswdStruct()
    • setPasswdStruct

      public void setPasswdStruct(RubyClass passwdStruct)
    • getGroupStruct

      public IRubyObject getGroupStruct()
    • setGroupStruct

      public void setGroupStruct(RubyClass groupStruct)
    • getGC

      public RubyModule getGC()
    • getObjectSpaceModule

      public RubyModule getObjectSpaceModule()
    • getProcess

      public RubyModule getProcess()
    • getProcStatus

      public RubyClass getProcStatus()
    • getProcUID

      public RubyModule getProcUID()
    • getProcGID

      public RubyModule getProcGID()
    • getProcSysModule

      public RubyModule getProcSysModule()
    • getPrecision

      public RubyModule getPrecision()
    • getENV

      public RubyHash getENV()
    • getLocation

      public RubyClass getLocation()
    • setLocation

      public void setLocation(RubyClass location)
    • getMutex

      public RubyClass getMutex()
    • getConditionVariable

      public RubyClass getConditionVariable()
    • getQueue

      public RubyClass getQueue()
    • getClosedQueueError

      public RubyClass getClosedQueueError()
    • getSizedQueueClass

      public RubyClass getSizedQueueClass()
    • getWarning

      public RubyModule getWarning()
    • getErrno

      public RubyModule getErrno()
    • getException

      public RubyClass getException()
    • getNameError

      public RubyClass getNameError()
    • getNameErrorMessage

      public RubyClass getNameErrorMessage()
    • getNoMethodError

      public RubyClass getNoMethodError()
    • getSignalException

      public RubyClass getSignalException()
    • getRangeError

      public RubyClass getRangeError()
    • getSystemExit

      public RubyClass getSystemExit()
    • getLocalJumpError

      public RubyClass getLocalJumpError()
    • getNativeException

      public RubyClass getNativeException()
    • getSystemCallError

      public RubyClass getSystemCallError()
    • getKeyError

      public RubyClass getKeyError()
    • getFatal

      public RubyClass getFatal()
    • getInterrupt

      public RubyClass getInterrupt()
    • getTypeError

      public RubyClass getTypeError()
    • getNoMatchingPatternError

      public RubyClass getNoMatchingPatternError()
    • getArgumentError

      public RubyClass getArgumentError()
    • getUncaughtThrowError

      public RubyClass getUncaughtThrowError()
    • getIndexError

      public RubyClass getIndexError()
    • getStopIteration

      public RubyClass getStopIteration()
    • getSyntaxError

      public RubyClass getSyntaxError()
    • getStandardError

      public RubyClass getStandardError()
    • getRuntimeError

      public RubyClass getRuntimeError()
    • getFrozenError

      public RubyClass getFrozenError()
    • getIOError

      public RubyClass getIOError()
    • getIOTimeoutError

      public RubyClass getIOTimeoutError()
    • getLoadError

      public RubyClass getLoadError()
    • getNotImplementedError

      public RubyClass getNotImplementedError()
    • getSecurityError

      public RubyClass getSecurityError()
    • getNoMemoryError

      public RubyClass getNoMemoryError()
    • getRegexpError

      public RubyClass getRegexpError()
    • getInterruptedRegexpError

      public RubyClass getInterruptedRegexpError()
    • getEOFError

      public RubyClass getEOFError()
    • getThreadError

      public RubyClass getThreadError()
    • getConcurrencyError

      public RubyClass getConcurrencyError()
    • getSystemStackError

      public RubyClass getSystemStackError()
    • getZeroDivisionError

      public RubyClass getZeroDivisionError()
    • getFloatDomainError

      public RubyClass getFloatDomainError()
    • getMathDomainError

      public RubyClass getMathDomainError()
    • getEncodingError

      public RubyClass getEncodingError()
    • getEncodingCompatibilityError

      public RubyClass getEncodingCompatibilityError()
    • getConverterNotFoundError

      public RubyClass getConverterNotFoundError()
    • getFiberError

      public RubyClass getFiberError()
    • getUndefinedConversionError

      public RubyClass getUndefinedConversionError()
    • getInvalidByteSequenceError

      public RubyClass getInvalidByteSequenceError()
    • getBufferLockedError

      public RubyClass getBufferLockedError()
    • getBufferAllocationError

      public RubyClass getBufferAllocationError()
    • getBufferAccessError

      public RubyClass getBufferAccessError()
    • getBufferInvalidatedError

      public RubyClass getBufferInvalidatedError()
    • getBufferMaskError

      public RubyClass getBufferMaskError()
    • getData

      public RubyClass getData()
    • getDefaultRandom

      public RubyRandom getDefaultRandom()
    • setDefaultRandom

      public void setDefaultRandom(RubyRandom random)
    • getVerbose

      public IRubyObject 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

      public void setVerbose(IRubyObject verbose)
      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

      public void setVerbose(Boolean verbose)
      Sets the $VERBOSE level
      Parameters:
      verbose - null, true and false are all valid
      See Also:
    • getDebug

      public IRubyObject getDebug()
      Returns:
      $DEBUG value
    • isDebug

      public boolean isDebug()
      Returns:
      $DEBUG value as a boolean
    • setDebug

      public void setDebug(IRubyObject debug)
      Setter for property isDebug.
      Parameters:
      debug - the $DEBUG value
    • setDebug

      public void setDebug(boolean debug)
      Sets the $DEBUG flag
      Parameters:
      debug -
    • getWarningCategories

      public Set<RubyWarnings.Category> getWarningCategories()
      Get the current enabled warning categories.
      Returns:
      a set of the currently-enabled warning categories
    • getJavaSupport

      public JavaSupport getJavaSupport()
    • getObjectSpecializer

      public RubyObjectSpecializer getObjectSpecializer()
    • getClassLoader

      public static ClassLoader getClassLoader()
    • getJRubyClassLoader

      public JRubyClassLoader getJRubyClassLoader()
    • defineVariable

      public void defineVariable(GlobalVariable variable, GlobalVariable.Scope scope)
      Defines a global variable
    • defineReadonlyVariable

      public void defineReadonlyVariable(String name, IRubyObject value, GlobalVariable.Scope scope)
      defines a readonly global variable
    • parseFile

      @Deprecated public Node parseFile(InputStream in, String file, DynamicScope scope)
      Deprecated.
    • parseFile

      @Deprecated public ParseResult parseFile(String file, InputStream in, DynamicScope scope)
      Deprecated.
    • parseFile

      @Deprecated public Node parseFile(InputStream in, String file, DynamicScope scope, int lineNumber)
      Deprecated.
    • parseFile

      @Deprecated public ParseResult parseFile(String file, InputStream in, DynamicScope scope, int lineNumber)
      Deprecated.
    • parseFileFromMain

      @Deprecated public Node parseFileFromMain(InputStream in, String file, DynamicScope scope)
      Deprecated.
    • parseFileFromMain

      @Deprecated public ParseResult parseFileFromMain(String file, InputStream in, DynamicScope scope)
      Deprecated.
    • parseInline

      @Deprecated public Node parseInline(InputStream in, String file, DynamicScope scope)
      Deprecated.
    • setupSourceEncoding

      public org.jcodings.Encoding setupSourceEncoding(org.jcodings.Encoding defaultEncoding)
    • parseEval

      @Deprecated public Node parseEval(String source, String file, DynamicScope scope, int lineNumber)
      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

      public ThreadService getThreadService()
    • getCurrentContext

      public ThreadContext getCurrentContext()
    • getLoadService

      public LoadService 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

      public Charset 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

      public EncodingService getEncodingService()
    • getWarnings

      public RubyWarnings getWarnings()
    • getStderr

      public IRubyObject getStderr()
    • getOriginalStderr

      public IRubyObject 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

      public PrintStream getErrorStream()
    • getInputStream

      public InputStream getInputStream()
    • getOutputStream

      public PrintStream getOutputStream()
    • getClassFromPath

      public RubyModule getClassFromPath(String path)
    • 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

      public void printError(RubyException ex)
      Prints a Ruby exception with backtrace to the configured stderr stream. MRI: eval.c - error_print()
    • printError

      public void printError(Throwable ex)
      Prints an exception to System.err.
      Parameters:
      ex -
    • printErrorString

      public void printErrorString(String msg)
      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

      public void loadFile(String scriptName, InputStream in, boolean wrap)
    • loadScope

      public void loadScope(IRScope scope, boolean wrap)
    • compileAndLoadFile

      public void compileAndLoadFile(String filename, InputStream in, boolean wrap)
    • setupWrappedToplevel

      public StaticScope setupWrappedToplevel(IRubyObject self, StaticScope top)
    • loadScript

      public void loadScript(Script script)
    • loadScript

      public void loadScript(Script script, boolean wrap)
    • loadExtension

      public 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.
      Parameters:
      extName - The name of the extension, to go on the frame wrapping it
      extension - The extension object to load
      wrap - Whether to use a new "self" for toplevel
    • addBoundMethod

      public void addBoundMethod(String className, String methodName, String rubyName)
    • addBoundMethods

      public void addBoundMethods(String className, String... tuples)
    • addBoundMethods

      public void addBoundMethods(int tuplesIndex, String... classNamesAndTuples)
    • getBoundMethods

      public Map<String,Map<String,String>> getBoundMethods()
    • getTraceEvents

      public TraceEventManager getTraceEvents()
    • getGlobalVariables

      public GlobalVariables getGlobalVariables()
    • pushExitFunction

      public void pushExitFunction(Ruby.ExitFunction func)
      Add an exit function to be run on runtime exit. Functions are run in FILO order.
      Parameters:
      func - the function to be run
    • pushExitBlock

      public IRubyObject pushExitBlock(RubyProc proc)
      Push block onto exit stack. When runtime environment exits these blocks will be evaluated.
      Returns:
      the element that was pushed onto stack
    • pushPostExitFunction

      public void pushPostExitFunction(Ruby.ExitFunction postExit)
      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 - the Ruby.ExitFunction to run after user exit hooks have completed
    • pushEndBlock

      public void pushEndBlock(RubyProc proc)
      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

      public void addInternalFinalizer(Finalizable finalizer)
    • addFinalizer

      public void addFinalizer(Finalizable finalizer)
    • removeInternalFinalizer

      public void removeInternalFinalizer(Finalizable finalizer)
    • removeFinalizer

      public void removeFinalizer(Finalizable finalizer)
    • 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 default tearDown(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

      public void printProfileData(ProfileCollection profileData)
      TDOD remove the synchronized. Synchronization should be a implementation detail of the ProfilingService.
      Parameters:
      profileData -
    • getProfilingService

      public ProfilingService getProfilingService()
      Returns:
      the, for this ruby instance, configured implementation of ProfilingService, or null
    • newEmptyArray

      @Deprecated(since="10.0") public RubyArray newEmptyArray()
      Deprecated.
    • newArray

      @Deprecated(since="10.0") public RubyArray newArray()
      Deprecated.
    • newArrayLight

      @Deprecated(since="10.0") public RubyArray newArrayLight()
      Deprecated.
    • newArray

      @Deprecated(since="10.0") public RubyArray newArray(IRubyObject object)
      Deprecated.
    • newArray

      @Deprecated(since="10.0") public RubyArray newArray(IRubyObject car, IRubyObject cdr)
      Deprecated.
    • newArray

      @Deprecated(since="10.0") public RubyArray newArray(IRubyObject... objects)
      Deprecated.
    • newArrayNoCopy

      @Deprecated(since="10.0") public RubyArray newArrayNoCopy(IRubyObject... objects)
      Deprecated.
    • newArrayNoCopyLight

      @Deprecated(since="10.0") public RubyArray newArrayNoCopyLight(IRubyObject... objects)
      Deprecated.
    • newArray

      @Deprecated(since="10.0") public RubyArray newArray(List<IRubyObject> list)
      Deprecated.
    • newArray

      @Deprecated(since="10.0") public RubyArray newArray(int size)
      Deprecated.
    • getEmptyFrozenArray

      public RubyArray getEmptyFrozenArray()
    • getEmptyFrozenString

      public RubyString getEmptyFrozenString()
    • newBoolean

      public RubyBoolean newBoolean(boolean value)
    • newFileStat

      public RubyFileStat newFileStat(String filename, boolean lstat)
    • newFileStat

      public RubyFileStat newFileStat(FileDescriptor descriptor)
    • newFixnum

      public RubyFixnum newFixnum(long value)
    • newFixnum

      public RubyFixnum newFixnum(int value)
    • newFixnum

      public RubyFixnum newFixnum(jnr.constants.Constant value)
    • newFloat

      public RubyFloat newFloat(double value)
    • newNumeric

      public RubyNumeric newNumeric()
    • newRational

      public RubyRational newRational(long num, long den)
    • newRationalReduced

      public RubyRational newRationalReduced(long num, long den)
    • newProc

      public RubyProc newProc(Block.Type type, Block block)
    • newBlockPassProc

      public RubyProc newBlockPassProc(Block.Type type, Block block)
    • newBinding

      public RubyBinding newBinding()
    • newBinding

      public RubyBinding newBinding(Binding binding)
    • newString

      public RubyString newString()
    • newString

      public RubyString newString(String string)
    • newDeduplicatedString

      public RubyString newDeduplicatedString(String string)
    • newString

      public RubyString newString(ByteList byteList)
    • newSymbol

      public RubySymbol newSymbol(String name)
      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

      public RubySymbol newSymbol(String name, org.jcodings.Encoding encoding)
    • newSymbol

      public RubySymbol newSymbol(ByteList name)
    • fastNewSymbol

      public RubySymbol fastNewSymbol(String internedName)
      Faster than newSymbol(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, call newSymbol(String) instead.
      Returns:
      the symbol for name
    • newTime

      public RubyTime newTime(long milliseconds)
    • newRuntimeError

      public RaiseException newRuntimeError(String message)
    • newArgumentError

      public RaiseException newArgumentError(String message)
    • newArgumentError

      @Deprecated(since="10.0") public RaiseException newArgumentError(int got, int expected)
      Parameters:
      got -
      expected -
      Returns:
    • newArgumentError

      public RaiseException newArgumentError(int got, int min, int max)
    • 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

      public RaiseException newErrnoEBADFError()
    • newErrnoEISCONNError

      public RaiseException newErrnoEISCONNError()
    • newErrnoEINPROGRESSError

      public RaiseException newErrnoEINPROGRESSError()
    • newErrnoEINPROGRESSWritableError

      public RaiseException newErrnoEINPROGRESSWritableError()
    • newErrnoENOPROTOOPTError

      public RaiseException newErrnoENOPROTOOPTError()
    • newErrnoEPIPEError

      public RaiseException newErrnoEPIPEError()
    • newErrnoECONNABORTEDError

      public RaiseException newErrnoECONNABORTEDError()
    • newErrnoECONNREFUSEDError

      public RaiseException newErrnoECONNREFUSEDError()
    • newErrnoECONNREFUSEDError

      public RaiseException newErrnoECONNREFUSEDError(String message)
    • newErrnoECONNRESETError

      public RaiseException newErrnoECONNRESETError()
    • newErrnoEADDRINUSEError

      public RaiseException newErrnoEADDRINUSEError()
    • newErrnoEADDRINUSEError

      public RaiseException newErrnoEADDRINUSEError(String message)
    • newErrnoEHOSTUNREACHError

      public RaiseException newErrnoEHOSTUNREACHError(String message)
    • newErrnoEINVALError

      public RaiseException newErrnoEINVALError()
    • newErrnoELOOPError

      public RaiseException newErrnoELOOPError()
    • newErrnoEMFILEError

      public RaiseException newErrnoEMFILEError()
    • newErrnoENFILEError

      public RaiseException newErrnoENFILEError()
    • newErrnoENOENTError

      public RaiseException newErrnoENOENTError()
    • newErrnoEACCESError

      public RaiseException newErrnoEACCESError(String message)
    • newErrnoEAGAINError

      public RaiseException newErrnoEAGAINError(String message)
    • newErrnoEAGAINReadableError

      public RaiseException newErrnoEAGAINReadableError(String message)
    • newErrnoEAGAINWritableError

      public RaiseException newErrnoEAGAINWritableError(String message)
    • newErrnoEISDirError

      public RaiseException newErrnoEISDirError(String message)
    • newErrnoEPERMError

      public RaiseException newErrnoEPERMError(String name)
    • newErrnoEISDirError

      public RaiseException newErrnoEISDirError()
    • newErrnoESPIPEError

      public RaiseException newErrnoESPIPEError()
    • newErrnoEBADFError

      public RaiseException newErrnoEBADFError(String message)
    • newErrnoEINPROGRESSError

      public RaiseException newErrnoEINPROGRESSError(String message)
    • newErrnoEINPROGRESSWritableError

      public RaiseException newErrnoEINPROGRESSWritableError(String message)
    • newErrnoEISCONNError

      public RaiseException newErrnoEISCONNError(String message)
    • newErrnoEINVALError

      public RaiseException newErrnoEINVALError(String message)
    • newErrnoENOTDIRError

      public RaiseException newErrnoENOTDIRError(String message)
    • newErrnoENOTEMPTYError

      public RaiseException newErrnoENOTEMPTYError(String message)
    • newErrnoENOTSOCKError

      public RaiseException newErrnoENOTSOCKError(String message)
    • newErrnoENOTCONNError

      public RaiseException newErrnoENOTCONNError(String message)
    • newErrnoENOTCONNError

      public RaiseException newErrnoENOTCONNError()
    • newErrnoENOENTError

      public RaiseException newErrnoENOENTError(String message)
    • newErrnoEOPNOTSUPPError

      public RaiseException newErrnoEOPNOTSUPPError(String message)
    • newErrnoESPIPEError

      public RaiseException newErrnoESPIPEError(String message)
    • newErrnoEEXISTError

      public RaiseException newErrnoEEXISTError(String message)
    • newErrnoEDOMError

      public RaiseException newErrnoEDOMError(String message)
    • newErrnoEDOMError

      public RaiseException newErrnoEDOMError()
    • newErrnoECHILDError

      public RaiseException newErrnoECHILDError()
    • newErrnoEADDRNOTAVAILError

      public RaiseException newErrnoEADDRNOTAVAILError(String message)
    • newErrnoESRCHError

      public RaiseException newErrnoESRCHError()
    • newErrnoEWOULDBLOCKError

      public RaiseException newErrnoEWOULDBLOCKError()
    • newErrnoEDESTADDRREQError

      public RaiseException newErrnoEDESTADDRREQError(String func)
    • newErrnoENETUNREACHError

      public RaiseException newErrnoENETUNREACHError()
    • newErrnoEMSGSIZEError

      public RaiseException newErrnoEMSGSIZEError()
    • newErrnoEXDEVError

      public RaiseException newErrnoEXDEVError(String message)
    • newIndexError

      public RaiseException newIndexError(String message)
    • newSecurityError

      public RaiseException newSecurityError(String message)
    • newSystemCallError

      public RaiseException newSystemCallError(String message)
    • newKeyError

      public RaiseException newKeyError(String message, IRubyObject recv, IRubyObject key)
    • newErrnoEINTRError

      public RaiseException newErrnoEINTRError()
    • newErrnoEAFNOSUPPORTError

      public RaiseException newErrnoEAFNOSUPPORTError(String message)
    • newErrnoETIMEDOUTError

      public RaiseException newErrnoETIMEDOUTError()
    • newErrnoFromLastPOSIXErrno

      public RaiseException newErrnoFromLastPOSIXErrno()
    • newErrnoFromInt

      public RaiseException newErrnoFromInt(int errno, String methodName, String message)
    • newErrnoFromInt

      public RaiseException newErrnoFromInt(int errno, String message)
    • newErrnoFromErrno

      public RaiseException newErrnoFromErrno(jnr.constants.platform.Errno errno, String message)
    • newErrnoFromInt

      public RaiseException newErrnoFromInt(int errno)
    • newErrnoFromBindException

      public RaiseException newErrnoFromBindException(BindException be, String contextMessage)
    • newErrnoEADDRFromBindException

      public RaiseException newErrnoEADDRFromBindException(BindException be, String contextMessage)
    • newTypeError

      @Deprecated public RaiseException newTypeError(String message)
      Deprecated.
    • newThreadError

      public RaiseException newThreadError(String message)
    • newConcurrencyError

      public RaiseException newConcurrencyError(String message)
    • newSyntaxError

      public RaiseException newSyntaxError(String message)
    • newSyntaxError

      public RaiseException newSyntaxError(String message, String path)
    • newRegexpError

      public RaiseException newRegexpError(String message)
    • newInterruptedRegexpError

      public RaiseException newInterruptedRegexpError(String message)
    • newRangeError

      public RaiseException newRangeError(String message)
    • newNotImplementedError

      public RaiseException newNotImplementedError(String message)
    • newInvalidEncoding

      @Deprecated(since="9.4-") public RaiseException newInvalidEncoding(String message)
      Deprecated.
    • newIllegalSequence

      @Deprecated(since="9.4-") public RaiseException newIllegalSequence(String message)
      Deprecated.
    • newNameError

      public RaiseException newNameError(String message, IRubyObject recv, IRubyObject name)
      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 message
      recv - the receiver object
      name - the name that failed
      privateCall - whether the failure was due to method visibility
      Returns:
      a new NameError
    • newNameError

      public RaiseException newNameError(String message, IRubyObject recv, String name)
      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 NameError
      name - the name that failed
      exception - the original exception, or null
      printWhenVerbose - 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(since="10.0") public RaiseException newNameError(String message, String name)
      Construct a NameError with a pre-formatted message and name.
      Parameters:
      message - the pre-formatted message for the error
      name - the name that failed
      Returns:
      a new NameError
    • newNameError

      @Deprecated(since="10.0") public RaiseException newNameError(String message, IRubyObject name)
    • newNameError

      @Deprecated(since="10.0") public RaiseException newNameError(String message, String name, Throwable origException)
      Construct a NameError with an optional originating exception and a pre-formatted message. This is the same as calling newNameError(String, String, Throwable, boolean) with a null originating exception and false for verbose-mode logging.
      Parameters:
      message - a formatted string message for the error
      name - the name that failed
      origException - 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 like newNameError(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

      public RaiseException newNoMethodError(String message, String name, IRubyObject args)
      Construct a NoMethodError with a pre-formatted message.
      Parameters:
      message - the pre-formatted message
      name - the name that failed
      args - the original arguments to the call that failed
      Returns:
      a new NoMethodError
    • newLocalJumpError

      public RaiseException newLocalJumpError(RubyLocalJumpError.Reason reason, IRubyObject exitValue, String message)
    • newLocalJumpErrorNoBlock

      public RaiseException newLocalJumpErrorNoBlock()
    • newRedoLocalJumpError

      public RaiseException newRedoLocalJumpError()
    • newLoadError

      public RaiseException newLoadError(String message)
    • newLoadError

      public RaiseException newLoadError(String message, String path)
    • newFrozenError

      public RaiseException newFrozenError(String objectType, IRubyObject receiver)
    • newFrozenError

      @Deprecated(since="10.0") public RaiseException newFrozenError(IRubyObject receiver, String message)
      Deprecated.
    • newFrozenError

      public RaiseException newFrozenError(IRubyObject receiver)
    • newSystemStackError

      public RaiseException newSystemStackError(String message)
    • newSystemStackError

      public RaiseException newSystemStackError(String message, StackOverflowError error)
    • newSystemExit

      public RaiseException newSystemExit(int status)
    • newSystemExit

      public RaiseException newSystemExit(int status, String message)
    • newIOError

      public RaiseException newIOError(String message)
      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

      public RaiseException newStandardError(String message)
    • newIOErrorFromException

      public RaiseException newIOErrorFromException(IOException ex)
      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 public RaiseException newTypeError(IRubyObject receivedObject, RubyClass expectedType)
      Deprecated.
    • newTypeError

      @Deprecated public RaiseException newTypeError(IRubyObject receivedObject, RubyModule expectedType)
      Deprecated.
    • newTypeError

      @Deprecated public RaiseException newTypeError(IRubyObject receivedObject, String expectedType)
      Deprecated.
    • newEOFError

      public RaiseException newEOFError()
    • newEOFError

      public RaiseException newEOFError(String message)
    • newZeroDivisionError

      public RaiseException newZeroDivisionError()
    • newFloatDomainError

      public RaiseException newFloatDomainError(String message)
    • newMathDomainError

      public RaiseException newMathDomainError(String message)
    • newEncodingError

      public RaiseException newEncodingError(String message)
    • newEncodingCompatibilityError

      public RaiseException newEncodingCompatibilityError(String message)
    • newConverterNotFoundError

      public RaiseException newConverterNotFoundError(String message)
    • newFiberError

      public RaiseException newFiberError(String message)
    • newUndefinedConversionError

      public RaiseException newUndefinedConversionError(String message)
    • newInvalidByteSequenceError

      public RaiseException newInvalidByteSequenceError(String message)
    • newBufferLockedError

      public RaiseException newBufferLockedError(String message)
    • newBufferAllocationError

      public RaiseException newBufferAllocationError(String message)
    • newBufferAccessError

      public RaiseException newBufferAccessError(String message)
    • newBufferInvalidatedError

      public RaiseException newBufferInvalidatedError(String message)
    • newBufferMaskError

      public RaiseException newBufferMaskError(String message)
    • newRaiseException

      public RaiseException newRaiseException(RubyClass exceptionClass, String message)
      Construct a new RaiseException wrapping a new Ruby exception object appropriate to the given exception class. There are additional forms of this construction logic in RaiseException.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 object
      message - a simple message for the exception
      Returns:
      a new RaiseException wrapping a new Ruby exception
      See Also:
    • newStopIteration

      public RaiseException newStopIteration(IRubyObject result, String message)
      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

      public RubyObject.Data newData(RubyClass objectClass, Object sval)
    • getSymbolTable

      public RubySymbol.SymbolTable getSymbolTable()
    • getObjectSpace

      public ObjectSpace getObjectSpace()
    • getIn

      public InputStream getIn()
    • getOut

      public PrintStream getOut()
    • getErr

      public PrintStream getErr()
    • isAbortOnException

      public boolean isAbortOnException()
    • setAbortOnException

      public void setAbortOnException(boolean abortOnException)
    • isGlobalAbortOnExceptionEnabled

      @Deprecated public boolean isGlobalAbortOnExceptionEnabled()
      Deprecated.
    • setGlobalAbortOnExceptionEnabled

      @Deprecated public void setGlobalAbortOnExceptionEnabled(boolean enable)
      Deprecated.
    • getReportOnException

      @Deprecated public IRubyObject getReportOnException()
      Deprecated.
    • isReportOnException

      public boolean isReportOnException()
    • setReportOnException

      public void setReportOnException(IRubyObject enable)
    • setReportOnException

      public void setReportOnException(boolean enable)
    • isDoNotReverseLookupEnabled

      public boolean isDoNotReverseLookupEnabled()
    • setDoNotReverseLookupEnabled

      public void setDoNotReverseLookupEnabled(boolean b)
    • registerInspecting

      public void registerInspecting(Object obj)
    • isInspecting

      public boolean isInspecting(Object obj)
    • unregisterInspecting

      public void unregisterInspecting(Object obj)
    • isObjectSpaceEnabled

      public boolean isObjectSpaceEnabled()
    • setObjectSpaceEnabled

      public void setObjectSpaceEnabled(boolean objectSpaceEnabled)
    • isSiphashEnabled

      public boolean isSiphashEnabled()
    • getStartTime

      public long getStartTime()
    • getProfile

      public Profile getProfile()
    • getJRubyHome

      public String getJRubyHome()
    • setJRubyHome

      public void setJRubyHome(String home)
    • getInstanceConfig

      public RubyInstanceConfig 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

      public void setRecordSeparatorVar(GlobalVariable recordSeparatorVar)
    • getRecordSeparatorVar

      public GlobalVariable getRecordSeparatorVar()
    • getExecutor

      public ExecutorService getExecutor()
    • getFiberExecutor

      public ExecutorService getFiberExecutor()
    • getTimezoneCache

      public Map<String,org.joda.time.DateTimeZone> getTimezoneCache()
    • getConstantInvalidator

      public Invalidator getConstantInvalidator(String constantName)
    • getCheckpointInvalidator

      public Invalidator getCheckpointInvalidator()
    • loadConstantSet

      @Deprecated(since="10.0") public <C extends Enum<C> & jnr.constants.Constant> void loadConstantSet(RubyModule module, Class<C> enumClass)
      Define all constants from the given jnr-constants enum which are defined on the current platform.
      Type Parameters:
      C - the enum type, which must implement Constant.
      Parameters:
      module - the module in which we want to define the constants
      enumClass - the enum class of the constants to define
    • loadConstantSet

      @Deprecated(since="10.0") public void loadConstantSet(RubyModule module, String constantSetName)
      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 constants
      constantSetName - 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

      public Object 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

      public SelectorPool getSelectorPool()
      Get the runtime-global selector pool
      Returns:
      a SelectorPool from which to getService Selector instances
    • getRuntimeCache

      public RuntimeCache getRuntimeCache()
      Get the core class RuntimeCache instance, for doing dynamic calls from core class methods.
    • getCachedStrptimePattern

      public List<StrptimeToken> getCachedStrptimePattern(String pattern)
    • 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

      public CoverageData getCoverageData()
    • isCoverageEnabled

      public boolean isCoverageEnabled()
    • getHashSeedK0

      public long getHashSeedK0()
    • getHashSeedK1

      public long getHashSeedK1()
    • getStaticScopeFactory

      public StaticScopeFactory getStaticScopeFactory()
    • getFFI

      public FFI getFFI()
    • setFFI

      public void setFFI(FFI ffi)
    • getDefinedMessage

      public RubyString getDefinedMessage(DefinedMessage definedMessage)
    • getThreadStatus

      public RubyString getThreadStatus(RubyThread.Status status)
    • freezeAndDedupString

      public RubyString freezeAndDedupString(RubyString string)
      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 an Ruby.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

      public RubyString freezeAndDedupString(ByteList bytes)
      Given a ByteList, cache a deduplicated FString version of it, or find an existing copy already prepared. This is equivalent to calling freezeAndDedupString(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

      public ParserManager getParserManager()
    • defineDATA

      public void defineDATA(IRubyObject io)
    • setTopLevelBinding

      public void setTopLevelBinding(RubyBinding rubyBinding)
    • getTopLevelBinding

      public RubyBinding getTopLevelBinding()
    • setRubyTimeout

      public void setRubyTimeout(IRubyObject timeout)
    • getRubyTimeout

      public IRubyObject getRubyTimeout()
    • setRegexpTimeoutError

      public void setRegexpTimeoutError(RubyClass error)
    • getRegexpTimeoutError

      public RubyClass getRegexpTimeoutError()
    • setChdirThread

      public void setChdirThread(RubyThread thread)
    • getChdirThread

      public RubyThread getChdirThread()
    • getChdirLocation

      public RubyStackTraceElement getChdirLocation()
    • getRuntimeNumber

      public int getRuntimeNumber()
    • constant

      public Object constant()
      Specified by:
      constant in interface Constantizable
      See Also:
    • setBaseNewMethod

      public void setBaseNewMethod(DynamicMethod baseNewMethod)
      Set the base Class#new method.
      Parameters:
      baseNewMethod -
    • getBaseNewMethod

      public DynamicMethod getBaseNewMethod()
      Get the base Class#new method.
      Returns:
      the base Class#new method
    • getNullToNilHandle

      public MethodHandle 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

      public MethodHandle getNullToUndefinedHandle()
    • getFilenoUtil

      public FilenoUtil getFilenoUtil()
    • getJavaExtensionDefinitions

      public Map<Class,Consumer<RubyModule>> getJavaExtensionDefinitions()
      Returns:
      Class$ -> extension initializer map

      Note: Internal API, subject to change!

    • addToObjectSpace

      public void addToObjectSpace(boolean useObjectSpace, IRubyObject object)
    • newErrnoEADDRFromBindException

      @Deprecated public RaiseException newErrnoEADDRFromBindException(BindException be)
      Deprecated.
    • newFrozenError

      @Deprecated public RaiseException newFrozenError(String objectType)
      Deprecated.
    • newFrozenError

      @Deprecated public RaiseException newFrozenError(RubyModule type)
      Deprecated.
    • newFrozenError

      @Deprecated public RaiseException newFrozenError(String objectType, boolean runtimeError)
      Deprecated.
    • addEventHook

      @Deprecated public void addEventHook(EventHook hook)
      Deprecated.
    • removeEventHook

      @Deprecated public void removeEventHook(EventHook hook)
      Deprecated.
    • setTraceFunction

      @Deprecated public void setTraceFunction(RubyProc traceFunction)
      Deprecated.
    • setTraceFunction

      @Deprecated public void setTraceFunction(TraceEventManager.CallTraceFuncHook hook, RubyProc traceFunction)
      Deprecated.
    • removeAllCallEventHooksFor

      @Deprecated public void removeAllCallEventHooksFor(ThreadContext context)
      Deprecated.
    • callEventHooks

      @Deprecated public void callEventHooks(ThreadContext context, RubyEvent event, String file, int line, String name, IRubyObject type)
      Deprecated.
    • hasEventHooks

      @Deprecated public boolean hasEventHooks()
      Deprecated.
    • setENV

      @Deprecated public void setENV(RubyHash env)
      Deprecated.