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

    • LOG

      private static final Logger LOG
      The logger used to log relevant bits.
    • NIL_PREFILLED_ARRAY_SIZE

      public static final int NIL_PREFILLED_ARRAY_SIZE
      See Also:
    • nilPrefilledArray

      private final IRubyObject[] nilPrefilledArray
    • errnos

      private final Map<Integer,RubyClass> errnos
    • defaultRand

    • charsetMap

      private RubyHash charsetMap
    • ROOT_FRAME_NAME

      static final String ROOT_FRAME_NAME
      See Also:
    • interest

      private static final EnumSet<RubyEvent> interest
    • callTraceFuncHook

      private final Ruby.CallTraceFuncHook callTraceFuncHook
    • ADDR_NOT_AVAIL_PATTERN

      private static final Pattern ADDR_NOT_AVAIL_PATTERN
    • inspect

      private final ThreadLocal<Map<Object,Object>> inspect
    • DEDUP_WRAPPER_CACHE

      private final ThreadLocal<Ruby.FStringEqual> DEDUP_WRAPPER_CACHE
    • LEGACY_RECURSE

      @Deprecated private static final Ruby.RecursiveFunctionEx<Ruby.RecursiveFunction> LEGACY_RECURSE
      Deprecated.
    • constantNameInvalidators

      private final ConcurrentHashMap<String,Invalidator> constantNameInvalidators
    • checkpointInvalidator

      private final Invalidator checkpointInvalidator
    • threadService

      private ThreadService threadService
    • posix

      private final jnr.posix.POSIX posix
    • nativePosix

      private jnr.posix.POSIX nativePosix
    • objectSpace

      private final ObjectSpace objectSpace
    • symbolTable

      private final RubySymbol.SymbolTable symbolTable
    • EMPTY_HOOKS

      private static final EventHook[] EMPTY_HOOKS
    • eventHooks

      private volatile EventHook[] eventHooks
    • hasEventHooks

      private boolean hasEventHooks
    • abortOnException

      private boolean abortOnException
    • reportOnException

      private boolean reportOnException
    • doNotReverseLookupEnabled

      private boolean doNotReverseLookupEnabled
    • objectSpaceEnabled

      private volatile boolean objectSpaceEnabled
    • siphashEnabled

      private boolean siphashEnabled
    • globalState

      @Deprecated private long globalState
      Deprecated.
    • topSelf

      private final IRubyObject topSelf
    • nilObject

      private final RubyNil nilObject
    • singleNilArray

      private final IRubyObject[] singleNilArray
    • trueObject

      private final RubyBoolean trueObject
    • falseObject

      private final RubyBoolean falseObject
    • fixnumCache

      final RubyFixnum[] fixnumCache
    • fixnumConstants

      final Object[] fixnumConstants
    • rootFiber

      @Deprecated private IRubyObject rootFiber
      Deprecated.
    • verbose

      private boolean verbose
    • warningsEnabled

      private boolean warningsEnabled
    • debug

      private boolean debug
    • verboseValue

      private IRubyObject verboseValue
    • defaultThreadGroup

      private RubyThreadGroup defaultThreadGroup
    • basicObjectClass

      private final RubyClass basicObjectClass
      All the core classes we keep hard references to. These are here largely so that if someone redefines String or Array we won't start blowing up creating strings and arrays internally. They also provide much faster access than going through normal hash lookup on the Object class.
    • objectClass

      private final RubyClass objectClass
    • moduleClass

      private final RubyClass moduleClass
    • classClass

      private final RubyClass classClass
    • nilClass

      private final RubyClass nilClass
    • trueClass

      private final RubyClass trueClass
    • falseClass

      private final RubyClass falseClass
    • numericClass

      private final RubyClass numericClass
    • floatClass

      private final RubyClass floatClass
    • integerClass

      private final RubyClass integerClass
    • fixnumClass

      private final RubyClass fixnumClass
    • complexClass

      private final RubyClass complexClass
    • rationalClass

      private final RubyClass rationalClass
    • enumeratorClass

      private final RubyClass enumeratorClass
    • yielderClass

      private final RubyClass yielderClass
    • fiberClass

      private final RubyClass fiberClass
    • generatorClass

      private final RubyClass generatorClass
    • chainClass

      private final RubyClass chainClass
    • aseqClass

      private final RubyClass aseqClass
    • arrayClass

      private final RubyClass arrayClass
    • hashClass

      private final RubyClass hashClass
    • rangeClass

      private final RubyClass rangeClass
    • stringClass

      private final RubyClass stringClass
    • encodingClass

      private final RubyClass encodingClass
    • converterClass

      private final RubyClass converterClass
    • symbolClass

      private final RubyClass symbolClass
    • procClass

      private final RubyClass procClass
    • bindingClass

      private final RubyClass bindingClass
    • methodClass

      private final RubyClass methodClass
    • unboundMethodClass

      private final RubyClass unboundMethodClass
    • matchDataClass

      private final RubyClass matchDataClass
    • regexpClass

      private final RubyClass regexpClass
    • timeClass

      private final RubyClass timeClass
    • bignumClass

      private final RubyClass bignumClass
    • dirClass

      private final RubyClass dirClass
    • fileClass

      private final RubyClass fileClass
    • fileStatClass

      private final RubyClass fileStatClass
    • ioClass

      private final RubyClass ioClass
    • threadClass

      private final RubyClass threadClass
    • threadGroupClass

      private final RubyClass threadGroupClass
    • continuationClass

      private final RubyClass continuationClass
    • structClass

      private final RubyClass structClass
    • exceptionClass

      private final RubyClass exceptionClass
    • dummyClass

      private final RubyClass dummyClass
    • randomClass

      private final RubyClass randomClass
    • dataClass

      private final RubyClass dataClass
    • mutexClass

      private final RubyClass mutexClass
    • conditionVariableClass

      private final RubyClass conditionVariableClass
    • queueClass

      private final RubyClass queueClass
    • closedQueueError

      private final RubyClass closedQueueError
    • sizedQueueClass

      private final RubyClass sizedQueueClass
    • tmsStruct

      private RubyClass tmsStruct
    • passwdStruct

      private RubyClass passwdStruct
    • groupStruct

      private RubyClass groupStruct
    • procStatusClass

      private RubyClass procStatusClass
    • runtimeError

      private RubyClass runtimeError
    • frozenError

      private RubyClass frozenError
    • ioError

      private RubyClass ioError
    • scriptError

      private RubyClass scriptError
    • nameError

      private RubyClass nameError
    • nameErrorMessage

      private RubyClass nameErrorMessage
    • noMethodError

      private RubyClass noMethodError
    • signalException

      private RubyClass signalException
    • rangeError

      private RubyClass rangeError
    • systemExit

      private RubyClass systemExit
    • localJumpError

      private RubyClass localJumpError
    • nativeException

      private RubyClass nativeException
    • systemCallError

      private RubyClass systemCallError
    • fatal

      private RubyClass fatal
    • interrupt

      private RubyClass interrupt
    • typeError

      private RubyClass typeError
    • argumentError

      private RubyClass argumentError
    • uncaughtThrowError

      private RubyClass uncaughtThrowError
    • indexError

      private RubyClass indexError
    • stopIteration

      private RubyClass stopIteration
    • syntaxError

      private RubyClass syntaxError
    • standardError

      private RubyClass standardError
    • loadError

      private RubyClass loadError
    • notImplementedError

      private RubyClass notImplementedError
    • securityError

      private RubyClass securityError
    • noMemoryError

      private RubyClass noMemoryError
    • regexpError

      private RubyClass regexpError
    • eofError

      private RubyClass eofError
    • threadError

      private RubyClass threadError
    • concurrencyError

      private RubyClass concurrencyError
    • systemStackError

      private RubyClass systemStackError
    • zeroDivisionError

      private RubyClass zeroDivisionError
    • floatDomainError

      private RubyClass floatDomainError
    • mathDomainError

      private RubyClass mathDomainError
    • encodingError

      private RubyClass encodingError
    • encodingCompatibilityError

      private RubyClass encodingCompatibilityError
    • converterNotFoundError

      private RubyClass converterNotFoundError
    • undefinedConversionError

      private RubyClass undefinedConversionError
    • invalidByteSequenceError

      private RubyClass invalidByteSequenceError
    • fiberError

      private RubyClass fiberError
    • keyError

      private RubyClass keyError
    • locationClass

      private RubyClass locationClass
    • interruptedRegexpError

      private RubyClass interruptedRegexpError
    • kernelModule

      private final RubyModule kernelModule
      All the core modules we keep direct references to, for quick access and to ensure they remain available.
    • comparableModule

      private final RubyModule comparableModule
    • enumerableModule

      private final RubyModule enumerableModule
    • mathModule

      private final RubyModule mathModule
    • marshalModule

      private final RubyModule marshalModule
    • fileTestModule

      private final RubyModule fileTestModule
    • gcModule

      private final RubyModule gcModule
    • objectSpaceModule

      private final RubyModule objectSpaceModule
    • processModule

      private final RubyModule processModule
    • warningModule

      private final RubyModule warningModule
    • etcModule

      private RubyModule etcModule
    • procUIDModule

      private RubyModule procUIDModule
    • procGIDModule

      private RubyModule procGIDModule
    • procSysModule

      private RubyModule procSysModule
    • precisionModule

      private RubyModule precisionModule
    • errnoModule

      private RubyModule errnoModule
    • privateMethodMissing

      private DynamicMethod privateMethodMissing
    • protectedMethodMissing

      private DynamicMethod protectedMethodMissing
    • variableMethodMissing

      private DynamicMethod variableMethodMissing
    • superMethodMissing

      private DynamicMethod superMethodMissing
    • normalMethodMissing

      private DynamicMethod normalMethodMissing
    • defaultMethodMissing

      private DynamicMethod defaultMethodMissing
    • defaultModuleMethodMissing

      private DynamicMethod defaultModuleMethodMissing
    • respondTo

      private DynamicMethod respondTo
    • respondToMissing

      private DynamicMethod respondToMissing
    • recordSeparatorVar

      private GlobalVariable recordSeparatorVar
    • currentDirectory

      private volatile String currentDirectory
    • currentLine

      private volatile int currentLine
    • argsFile

      private volatile IRubyObject argsFile
    • startTime

      private final long startTime
    • config

      final RubyInstanceConfig config
    • in

      private InputStream in
    • out

      private PrintStream out
    • err

      private PrintStream err
    • javaSupport

      private final JavaSupport javaSupport
    • jrubyClassLoader

      private final JRubyClassLoader jrubyClassLoader
    • beanManager

      private final BeanManager beanManager
    • parserStats

      private final ParserStats parserStats
    • inlineStats

      private final InlineStats inlineStats
    • jitCompiler

      private final JITCompiler jitCompiler
    • caches

      private final Caches caches
    • securityRestricted

      private static volatile boolean securityRestricted
    • parser

      private final Parser parser
    • loadService

      private final LoadService loadService
    • defaultInternalEncoding

      private org.jcodings.Encoding defaultInternalEncoding
    • defaultExternalEncoding

      private org.jcodings.Encoding defaultExternalEncoding
    • defaultFilesystemEncoding

      private org.jcodings.Encoding defaultFilesystemEncoding
    • encodingService

      private final EncodingService encodingService
    • globalVariables

      private final GlobalVariables globalVariables
    • warnings

      private final RubyWarnings warnings
    • regexpWarnings

      private final org.joni.WarnCallback regexpWarnings
    • exitBlocks

      private final List<Ruby.ExitFunction> exitBlocks
      Reserved for userland at_exit logic that runs before internal services start shutting down.
    • postExitBlocks

      private final List<Ruby.ExitFunction> postExitBlocks
      Registry of shutdown operations that should happen after all user code has been run (e.g. at_exit hooks).
    • profile

      private Profile profile
    • kcode

      private KCode kcode
    • symbolLastId

      private final AtomicInteger symbolLastId
    • moduleLastId

      private final AtomicInteger moduleLastId
    • allModules

      private final ConcurrentWeakHashMap<RubyModule,Object> allModules
    • timeZoneCache

      private final Map<String,org.joda.time.DateTimeZone> timeZoneCache
    • finalizers

      private Map<Finalizable,Object> finalizers
      A list of "external" finalizers (the ones, registered via ObjectSpace), weakly referenced, to be executed on tearDown.
    • internalFinalizers

      private Map<Finalizable,Object> internalFinalizers
      A list of JRuby-internal finalizers, weakly referenced, to be executed on tearDown.
    • finalizersMutex

      private final Object finalizersMutex
    • internalFinalizersMutex

      private final Object internalFinalizersMutex
    • executor

      private final ExecutorService executor
    • fiberExecutor

      private final ExecutorService fiberExecutor
    • hierarchyLock

      private final Object hierarchyLock
    • dynamicMethodSerial

      private final AtomicLong dynamicMethodSerial
    • moduleGeneration

      private final AtomicInteger moduleGeneration
    • boundMethods

      private final Map<String,Map<String,String>> boundMethods
    • selectorPool

      private final SelectorPool selectorPool
    • runtimeCache

      private final RuntimeCache runtimeCache
    • ERRNO_BACKTRACE_MESSAGE

      public static final String ERRNO_BACKTRACE_MESSAGE
      See Also:
    • STOPIERATION_BACKTRACE_MESSAGE

      public static final String STOPIERATION_BACKTRACE_MESSAGE
      See Also:
    • exceptionCount

      private final AtomicInteger exceptionCount
    • backtraceCount

      private final AtomicInteger backtraceCount
    • callerCount

      private final AtomicInteger callerCount
    • warningCount

      private final AtomicInteger warningCount
    • fixnumInvalidator

      private final Invalidator fixnumInvalidator
    • floatInvalidator

      private final Invalidator floatInvalidator
    • fixnumReopened

      private boolean fixnumReopened
    • floatReopened

      private boolean floatReopened
    • coreIsBooted

      private final boolean coreIsBooted
    • runtimeIsBooted

      private final boolean runtimeIsBooted
    • envObject

      private RubyHash envObject
    • coverageData

      private final CoverageData coverageData
    • globalRuntime

      private static volatile Ruby globalRuntime
      The "global" runtime. Set to the first runtime created, normally.
    • threadLocalRuntime

      private static final ThreadLocal<Ruby> threadLocalRuntime
      The "thread local" runtime. Set to the global runtime if unset.
    • random

      final Random random
      The runtime-local random number generator. Uses SecureRandom if permissions allow.
    • hashSeedK0

      private final long hashSeedK0
      The runtime-local seed for hash randomization
    • hashSeedK1

      private final long hashSeedK1
    • staticScopeFactory

      private final StaticScopeFactory staticScopeFactory
    • irManager

      private final IRManager irManager
    • ffi

      private FFI ffi
    • profilingServiceLookup

      private final ProfilingServiceLookup profilingServiceLookup
      Used to find the ProfilingService implementation to use. If profiling is disabled it's null
    • definedMessages

      private final EnumMap<DefinedMessage,RubyString> definedMessages
    • threadStatuses

      private final EnumMap<RubyThread.Status,RubyString> threadStatuses
    • DISABLED_OBJECTSPACE

      private static final Ruby.ObjectSpacer DISABLED_OBJECTSPACE
    • ENABLED_OBJECTSPACE

      private static final Ruby.ObjectSpacer ENABLED_OBJECTSPACE
    • objectSpacer

      private final Ruby.ObjectSpacer objectSpacer
    • emptyFrozenArray

      private final RubyArray emptyFrozenArray
    • dedupMap

      A map from Ruby string data to a pre-frozen global version of that string. Access must be synchronized.
    • RUNTIME_NUMBER

      private static final AtomicInteger RUNTIME_NUMBER
    • runtimeNumber

      private final int runtimeNumber
    • configBean

      private final Config configBean
    • runtimeBean

      private final Runtime runtimeBean
    • filenoUtil

      private final FilenoUtil filenoUtil
    • interpreter

      private final Interpreter interpreter
    • constant

      private final Object constant
      A representation of this runtime as a JIT-optimizable constant. Used for e.g. invokedynamic binding of runtime accesses.
    • baseNewMethod

      private DynamicMethod baseNewMethod
      The built-in Class#new method, so we can bind more directly to allocate and initialize.
    • nullToNil

      private MethodHandle nullToNil
      The nullToNil filter for this runtime.
    • POPULATORS

      public final ClassValue<TypePopulator> POPULATORS
    • sites

      public final JavaSites sites
    • mriRecursionGuard

      private volatile MRIRecursionGuard mriRecursionGuard
    • javaExtensionDefinitions

      private final Map<Class,Consumer<RubyModule>> javaExtensionDefinitions
    • strptimeFormatCache

      private final Map<String,List<StrptimeToken>> strptimeFormatCache
    • tzVar

      transient RubyString tzVar
  • Constructor Details

    • Ruby

      private Ruby(RubyInstanceConfig config)
      Create and initialize a new JRuby runtime. The properties of the specified RubyInstanceConfig will be used to determine various JRuby runtime characteristics.
      Parameters:
      config - The configuration to use for the new instance
      See Also:
  • Method Details

    • initProfiling

      private void initProfiling()
    • initBootLibraries

      private void initBootLibraries()
    • initKernelGsub

      private void initKernelGsub(RubyModule kernel)
    • initObjectSpacer

      private Ruby.ObjectSpacer initObjectSpacer(RubyInstanceConfig config)
    • initJRubyClassLoader

      private JRubyClassLoader initJRubyClassLoader(RubyInstanceConfig config)
    • initDefaultEncodings

      private void initDefaultEncodings()
    • initDataClass

      private RubyClass initDataClass()
    • initRandom

      private Random initRandom()
    • registerMBeans

      public void registerMBeans()
    • reinitialize

      void reinitialize(boolean reinitCore)
    • 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:
    • loadRequiredLibraries

      private void loadRequiredLibraries()
    • 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.
    • setGlobalRuntimeFirstTimeOnly

      private static void setGlobalRuntimeFirstTimeOnly(Ruby runtime)
      Set the global runtime to the given runtime only if it has no been set.
      Parameters:
      runtime - the runtime to use for global runtime
    • 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
    • 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)
    • 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.
      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.
    • tryScriptFromClass

      private Script tryScriptFromClass(String filename)
    • parseFromMain

      public Node parseFromMain(InputStream inputStream, String filename)
      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
    • parseFromMain

      public ParseResult parseFromMain(String fileName, InputStream in)
    • runWithGetsLoop

      @Deprecated public IRubyObject runWithGetsLoop(Node scriptNode, boolean printing, boolean processLineEnds, boolean split, boolean unused)
      Deprecated.
      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
    • runWithGetsLoop

      public IRubyObject runWithGetsLoop(RootNode 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
    • addGetsLoop

      private RootNode addGetsLoop(RootNode oldRoot, boolean printing, boolean processLineEndings, boolean split)
    • runNormally

      public IRubyObject runNormally(Node scriptNode, boolean wrap)
      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

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

      public IRubyObject runNormally(Node scriptNode)
      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
    • precompileCLI

      private ScriptAndCode precompileCLI(RootNode scriptNode)
    • tryCompile

      public Script tryCompile(Node node)
      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:
      node - The node to attempt to compiled
      Returns:
      an instance of the successfully-compiled Script, or null.
    • tryCompile

      private ScriptAndCode tryCompile(RootNode root, ClassDefiningClassLoader classLoader)
    • 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

      public Parser getParser()
    • 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
    • getDefaultInstance

      public static Ruby getDefaultInstance()
      Deprecated.
      use #newInstance()
    • getCurrentInstance

      @Deprecated public static Ruby getCurrentInstance()
      Deprecated.
    • setCurrentInstance

      @Deprecated public static void setCurrentInstance(Ruby runtime)
      Deprecated.
    • allocSymbolId

      public int allocSymbolId()
    • allocModuleId

      public int allocModuleId()
    • addModule

      public void addModule(RubyModule module)
    • eachModule

      public void eachModule(Consumer<RubyModule> func)
    • getModule

      public RubyModule getModule(String name)
      Retrieve the module with the given name from the Object namespace.
      Parameters:
      name - The name of the module
      Returns:
      The module or null if not found
    • fastGetModule

      @Deprecated public RubyModule fastGetModule(String internedName)
      Deprecated.
    • getClass

      public RubyClass getClass(String name)
      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

      public RubyClass defineClass(String name, RubyClass superClass, ObjectAllocator allocator)
      Define a new class under the Object namespace. Roughly equivalent to rb_define_class in MRI.
      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

      public RubyClass defineClass(String name, RubyClass superClass, ObjectAllocator allocator, CallSite[] callSites)
      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
    • defineClassUnder

      public RubyClass defineClassUnder(String name, RubyClass superClass, ObjectAllocator allocator, RubyModule parent)
      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

      public RubyClass defineClassUnder(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.
      Parameters:
      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

      public RubyModule defineModule(String name)
      Define a new module under the Object namespace. Roughly equivalent to rb_define_module in MRI.
      Parameters:
      name - The name of the new module
    • defineModuleUnder

      public RubyModule defineModuleUnder(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.
      Parameters:
      name - The name of the new module
      parent - The class or module namespace under which to define the module
    • getOrCreateModule

      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
    • getKCode

      public KCode getKCode()
    • setKCode

      public void setKCode(KCode kcode)
    • defineGlobalConstant

      public void defineGlobalConstant(String name, IRubyObject value)
      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

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

      public boolean isClassDefined(String name)
    • loadJavaSupport

      public JavaSupport loadJavaSupport()
    • loadBundler

      private void loadBundler()
    • doesReflectionWork

      private boolean doesReflectionWork()
    • initDefinedMessages

      private void initDefinedMessages()
    • initThreadStatuses

      private void initThreadStatuses()
    • initContinuation

      private RubyClass initContinuation()
    • getNilPrefilledArray

      public IRubyObject[] getNilPrefilledArray()
    • initExceptions

      private void initExceptions()
    • ifAllowed

      private void ifAllowed(String name, Consumer<Ruby> callback)
    • initNativeException

      private void initNativeException()
    • getErrno

      public RubyClass getErrno(int n)
    • initErrno

      private void initErrno()
      Create module Errno's Variables. We have this method since Errno does not have its own java class.
    • createSysErr

      private void createSysErr(int i, String name)
      Creates a system error.
      Parameters:
      i - the error code (will probably use a java exception instead)
      name - of the error to define.
    • initJavaSupport

      private void initJavaSupport()
      Load libraries expected to be present after a normal boot. This used to register lazy "builtins" that were shipped with JRuby but did not have a file on the filesystem to load via normal `require` logic. Because of how this interacted (badly) with require-hooking tools like bootsnap, we have moved to having all builtins as actual files rather than special virtual entries.
    • initRubyKernel

      private void initRubyKernel()
    • initRubyPreludes

      private void initRubyPreludes()
    • 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

      public RubyModule getEtc()
    • setEtc

      public void setEtc(RubyModule etcModule)
    • getObject

      public RubyClass getObject()
    • getBasicObject

      public RubyClass getBasicObject()
    • getModule

      public RubyClass getModule()
    • 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()
    • 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.
    • getFalse

      public RubyBoolean getFalse()
      Returns the "false" instance from the instance pool.
      Returns:
      The "false" instance.
    • 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

      public RubyClass getBignum()
    • getDir

      public RubyClass getDir()
    • getFile

      public RubyClass getFile()
    • getFileStat

      public RubyClass getFileStat()
    • getFileTest

      public RubyModule getFileTest()
    • getIO

      public RubyClass getIO()
    • getThread

      public RubyClass getThread()
    • getThreadGroup

      public RubyClass getThreadGroup()
    • getDefaultThreadGroup

      public RubyThreadGroup getDefaultThreadGroup()
    • setDefaultThreadGroup

      void setDefaultThreadGroup(RubyThreadGroup defaultThreadGroup)
    • getContinuation

      public RubyClass getContinuation()
    • getStructClass

      public RubyClass getStructClass()
    • getRandomClass

      public RubyClass getRandomClass()
    • getTmsStruct

      public IRubyObject getTmsStruct()
    • setTmsStruct

      void setTmsStruct(RubyClass tmsStruct)
    • 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()
    • setProcStatus

      void setProcStatus(RubyClass procStatusClass)
    • getProcUID

      public RubyModule getProcUID()
    • setProcUID

      void setProcUID(RubyModule procUIDModule)
    • getProcGID

      public RubyModule getProcGID()
    • setProcGID

      void setProcGID(RubyModule procGIDModule)
    • getProcSysModule

      public RubyModule getProcSysModule()
    • setProcSys

      void setProcSys(RubyModule procSysModule)
    • getPrecision

      public RubyModule getPrecision()
    • setPrecision

      void setPrecision(RubyModule precisionModule)
    • getENV

      public RubyHash getENV()
    • setENV

      public void setENV(RubyHash env)
    • 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()
    • 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()
    • 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()
    • getDefaultRand

      public RubyRandom.RandomType getDefaultRand()
      Deprecated.
      internal API, to be hidden
    • setDefaultRand

      public void setDefaultRand(RubyRandom.RandomType defaultRand)
    • getCharsetMap

      @Deprecated public RubyHash getCharsetMap()
      Deprecated.
    • getVerbose

      public IRubyObject getVerbose()
      Getter for property isVerbose.
      Returns:
      Value of property isVerbose.
    • isVerbose

      public boolean isVerbose()
    • warningsEnabled

      public boolean warningsEnabled()
    • setVerbose

      public void setVerbose(IRubyObject verbose)
      Setter for property isVerbose.
      Parameters:
      verbose - New value of property isVerbose.
    • getDebug

      public IRubyObject getDebug()
      Getter for property isDebug.
      Returns:
      Value of property isDebug.
    • isDebug

      public boolean isDebug()
    • setDebug

      public void setDebug(IRubyObject debug)
      Setter for property isDebug.
      Parameters:
      debug - New value of property isDebug.
    • getJavaSupport

      public JavaSupport getJavaSupport()
    • 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

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

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

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

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

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

      public ParseResult parseFileFromMain(String file, InputStream in, DynamicScope scope)
    • parseFileFromMainAndGetAST

      private Node parseFileFromMainAndGetAST(InputStream in, String file, DynamicScope scope)
    • parseFileAndGetAST

      private Node parseFileAndGetAST(InputStream in, String file, DynamicScope scope, int lineNumber, boolean isFromMain)
    • parseInline

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

      private void setupSourceEncoding(ParserConfiguration parserConfig, org.jcodings.Encoding defaultEncoding)
    • parseEval

      public Node parseEval(String content, String file, DynamicScope scope, int lineNumber)
    • encodeToBytes

      private byte[] encodeToBytes(String string)
    • parse

      @Deprecated public Node parse(String content, String file, DynamicScope scope, int lineNumber, boolean extraPositionInformation)
      Deprecated.
    • parseEval

      public Node parseEval(ByteList content, String file, DynamicScope scope, int lineNumber)
    • parse

      public Node parse(ByteList content, String file, DynamicScope scope, int lineNumber, boolean extraPositionInformation)
    • 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()
    • getRegexpWarnings

      org.joni.WarnCallback getRegexpWarnings()
    • 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 an error with backtrace to the error stream. MRI: eval.c - error_print()
    • printError

      public void printError(Throwable ex)
    • 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)
    • wrapWithModule

      private void wrapWithModule(RubyBasicObject self, ParseResult result)
    • 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)
    • addBoundMethodsPacked

      @Deprecated public void addBoundMethodsPacked(String className, String packedTuples)
      Deprecated.
    • addSimpleBoundMethodsPacked

      @Deprecated public void addSimpleBoundMethodsPacked(String className, String packedNames)
      Deprecated.
    • getBoundMethods

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

      public void addEventHook(EventHook hook)
    • removeEventHook

      public void removeEventHook(EventHook hook)
    • setTraceFunction

      public void setTraceFunction(RubyProc traceFunction)
    • setTraceFunction

      public void setTraceFunction(Ruby.CallTraceFuncHook hook, RubyProc traceFunction)
    • removeAllCallEventHooksFor

      public void removeAllCallEventHooksFor(ThreadContext context)
      Remove all event hooks which are associated with a particular thread.
      Parameters:
      context - the context of the ruby thread we are interested in.
    • callEventHooks

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

      public boolean hasEventHooks()
    • getGlobalVariables

      public GlobalVariables getGlobalVariables()
    • setGlobalVariables

      @Deprecated public void setGlobalVariables(GlobalVariables globalVariables)
      Deprecated.
    • 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).
    • alreadyRegisteredEndBlock

      private boolean alreadyRegisteredEndBlock(RubyProc newProc)
    • 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)
    • systemTeardown

      private void systemTeardown(ThreadContext context)
    • userTeardown

      private int userTeardown(ThreadContext context)
    • 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 -
    • getProfilingServiceLookup

      private ProfilingServiceLookup getProfilingServiceLookup()
      Simple getter for #profilingServiceLookup to avoid direct property access
      Returns:
      #profilingServiceLookup
    • getProfilingService

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

      public RubyArray newEmptyArray()
    • newArray

      public RubyArray newArray()
    • newArrayLight

      public RubyArray newArrayLight()
    • newArray

      public RubyArray newArray(IRubyObject object)
    • newArray

      public RubyArray newArray(IRubyObject car, IRubyObject cdr)
    • newArray

      public RubyArray newArray(IRubyObject... objects)
    • newArrayNoCopy

      public RubyArray newArrayNoCopy(IRubyObject... objects)
    • newArrayNoCopyLight

      public RubyArray newArrayNoCopyLight(IRubyObject... objects)
    • newArray

      public RubyArray newArray(List<IRubyObject> list)
    • newArray

      public RubyArray newArray(int size)
    • getEmptyFrozenArray

      public RubyArray getEmptyFrozenArray()
    • 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)
    • newStringShared

      @Deprecated public RubyString newStringShared(ByteList byteList)
      Deprecated.
    • newSymbol

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

      public RaiseException newArgumentError(int got, int expected)
    • newArgumentError

      public RaiseException newArgumentError(int got, int min, int max)
    • newArgumentError

      public RaiseException newArgumentError(String name, int got, int expected)
    • newArgumentError

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

      public RaiseException newTypeError(String message)
    • newThreadError

      public RaiseException newThreadError(String message)
    • newConcurrencyError

      public RaiseException newConcurrencyError(String message)
    • newSyntaxError

      public RaiseException newSyntaxError(String message)
    • 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 public RaiseException newInvalidEncoding(String message)
      Deprecated.
    • newIllegalSequence

      @Deprecated 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

      public RaiseException newNameError(String message, String name)
      Construct a NameError with a pre-formatted message and name. This is the same as calling newNameError(String, String, Throwable) with a null originating exception.
      Parameters:
      message - the pre-formatted message for the error
      name - the name that failed
      Returns:
      a new NameError
    • newNameError

      public RaiseException newNameError(String message, IRubyObject name)
    • newNameError

      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)
    • newFrozenError

      public RaiseException newFrozenError(RubyModule type)
    • newFrozenError

      public RaiseException newFrozenError(String objectType, boolean runtimeError)
    • 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)
    • 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

      public RaiseException newTypeError(IRubyObject receivedObject, RubyClass expectedType)
    • newTypeError

      public RaiseException newTypeError(IRubyObject receivedObject, RubyModule expectedType)
    • newTypeError

      public RaiseException newTypeError(IRubyObject receivedObject, String expectedType)
    • 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)
    • 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).
      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:
    • newLightweightErrnoException

      private RaiseException newLightweightErrnoException(RubyClass exceptionClass, String message)
      Generate one of the ERRNO exceptions. This differs from the normal logic by avoiding the generation of a backtrace. Many ERRNO values are expected, such as EAGAIN, and JRuby pays a very high cost to generate backtraces that are never used. The flags -Xerrno.backtrace=true or the property jruby.errno.backtrace=true forces all errno exceptions to generate a backtrace.
      Parameters:
      exceptionClass -
      message -
      Returns:
    • 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
    • newLightweightStopIterationError

      @Deprecated public RaiseException newLightweightStopIterationError(String message)
      Deprecated.
    • disabledBacktrace

      private IRubyObject disabledBacktrace()
    • 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()
    • is2_0

      @Deprecated public boolean is2_0()
      Deprecated.
    • getGlobalState

      @Deprecated public long getGlobalState()
      Deprecated.
      GET_VM_STATE_VERSION
    • incGlobalState

      @Deprecated public void incGlobalState()
      Deprecated.
      INC_VM_STATE_VERSION
    • 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()
    • getConstantGeneration

      @Deprecated public int getConstantGeneration()
      Deprecated.
    • getConstantInvalidator

      public Invalidator getConstantInvalidator(String constantName)
    • addConstantInvalidator

      private Invalidator addConstantInvalidator(String constantName)
    • getCheckpointInvalidator

      public Invalidator getCheckpointInvalidator()
    • loadConstantSet

      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

      public void loadConstantSet(RubyModule module, String constantSetName)
      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)
    • addProfiledMethod

      void addProfiledMethod(String id, DynamicMethod method)
      Add a method, so it can be printed out later.
      Parameters:
      id - raw name String of the method to be profiled
      method -
    • 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
    • reopenFixnum

      @Deprecated public void reopenFixnum()
      Deprecated.
      Mark Fixnum as reopened
    • getFixnumInvalidator

      @Deprecated public Invalidator getFixnumInvalidator()
      Deprecated.
      Retrieve the invalidator for Fixnum reopening
    • isFixnumReopened

      @Deprecated public boolean isFixnumReopened()
      Deprecated.
      Whether the Float class has been reopened and modified
    • reopenFloat

      @Deprecated public void reopenFloat()
      Deprecated.
      Mark Float as reopened
    • getFloatInvalidator

      @Deprecated public Invalidator getFloatInvalidator()
      Deprecated.
      Retrieve the invalidator for Float reopening
    • isFloatReopened

      @Deprecated public boolean isFloatReopened()
      Deprecated.
      Whether the Float class has been reopened and modified
    • isBootingCore

      public boolean isBootingCore()
    • isBooting

      public boolean isBooting()
    • getCoverageData

      public CoverageData getCoverageData()
    • getRandom

      public Random getRandom()
      Deprecated.
      internal API, to be removed
    • 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 frozen, duplicated copy of it, or find an existing copy already prepared. This is used to reduce in-memory duplication of pre-frozen or known-frozen strings. Note that this cache does some sync against the Ruby instance. This could cause contention under heavy concurrent load, so a reexamination of this design might be warranted. Because RubyString.equals does not consider encoding, and MRI's logic for deduplication does need to consider encoding, we use a wrapper object as the key. These wrappers need to be used on all get operations, so if we don't need to insert anything we reuse that wrapper the next time. The logic here reads like this: 1. If the string is not a natural String object, just freeze and return it. 2. Use the wrapper from the thread-local cache or create and set a new one. 3. Use the wrapper to look up the deduplicated string. 4. If there's a dedup in the cache, clear the wrapper for next time and return the dedup. 5. Remove the wrapper from the threadlocal to avoid reusing it, since we'll insert it. 6. Atomically set the new entry or repair the GCed entry that already exists. 7. Return the newly-deduplicated string.
      Parameters:
      string - the string to freeze-dup if an equivalent does not already exist
      Returns:
      the freeze-duped version of the string
    • 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
    • addLoadParseToStats

      private void addLoadParseToStats()
    • addEvalParseToStats

      private void addEvalParseToStats()
    • getFilenoUtil

      public FilenoUtil getFilenoUtil()
    • getData

      public RubyClass getData()
    • getJavaExtensionDefinitions

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

      @Deprecated public int getSafeLevel()
      Deprecated.
    • setSafeLevel

      @Deprecated public void setSafeLevel(int safeLevel)
      Deprecated.
    • checkSafeString

      @Deprecated public void checkSafeString(IRubyObject object)
      Deprecated.
    • secure

      @Deprecated public void secure(int level)
      Deprecated.
    • newNameErrorObject

      @Deprecated public RaiseException newNameErrorObject(String message, IRubyObject name)
      Deprecated.
    • is1_8

      @Deprecated public boolean is1_8()
      Deprecated.
    • is1_9

      @Deprecated public boolean is1_9()
      Deprecated.
    • safeRecurse

      @Deprecated public IRubyObject safeRecurse(Ruby.RecursiveFunction func, IRubyObject obj, String name, boolean outer)
      Deprecated.
    • getProfiledMethods

      @Deprecated public ProfiledMethods getProfiledMethods()
      Deprecated.
    • safeRecurse

      @Deprecated public <T> IRubyObject safeRecurse(Ruby.RecursiveFunctionEx<T> func, ThreadContext context, T state, IRubyObject obj, String name, boolean outer)
      Deprecated.
      Use ThreadContext.safeRecurse
    • execRecursive

      @Deprecated public IRubyObject execRecursive(Ruby.RecursiveFunction func, IRubyObject obj)
      Deprecated.
      Perform a recursive walk on the given object using the given function. Do not call this method directly unless you know you're within a call to recursiveListOperation, which will ensure the thread-local recursion tracking data structs are cleared. MRI: rb_exec_recursive Calls func(obj, arg, recursive), where recursive is non-zero if the current method is called recursively on obj
      Parameters:
      func -
      obj -
      Returns:
    • execRecursiveOuter

      @Deprecated public IRubyObject execRecursiveOuter(Ruby.RecursiveFunction func, IRubyObject obj)
      Deprecated.
      Use ThreadContext.safeRecurse.
      Perform a recursive walk on the given object using the given function. Treat this as the outermost call, cleaning up recursive structures. MRI: rb_exec_recursive_outer If recursion is detected on the current method and obj, the outermost func will be called with (obj, arg, Qtrue). All inner func will be short-circuited using throw.
      Parameters:
      func -
      obj -
      Returns:
    • recursiveListOperation

      @Deprecated public <T extends IRubyObject> T recursiveListOperation(Callable<T> body)
      Deprecated.
      Begin a recursive walk that may make one or more calls to execRecursive. Clean up recursive structures once complete.
      Type Parameters:
      T -
      Parameters:
      body -
      Returns:
    • oldRecursionGuard

      @Deprecated private MRIRecursionGuard oldRecursionGuard()
      Deprecated.
    • getRootFiber

      @Deprecated public IRubyObject getRootFiber()
      Deprecated.
    • setRootFiber

      @Deprecated public void setRootFiber(IRubyObject fiber)
      Deprecated.
    • setKernel

      @Deprecated void setKernel(RubyModule kernelModule)
      Deprecated.
    • setComparable

      @Deprecated void setComparable(RubyModule comparableModule)
      Deprecated.
    • setNumeric

      @Deprecated void setNumeric(RubyClass numericClass)
      Deprecated.
    • setFloat

      @Deprecated void setFloat(RubyClass floatClass)
      Deprecated.
    • setInteger

      @Deprecated void setInteger(RubyClass integerClass)
      Deprecated.
    • setFixnum

      @Deprecated void setFixnum(RubyClass fixnumClass)
      Deprecated.
    • setComplex

      @Deprecated void setComplex(RubyClass complexClass)
      Deprecated.
    • setRational

      @Deprecated void setRational(RubyClass rationalClass)
      Deprecated.
    • setEnumerable

      @Deprecated void setEnumerable(RubyModule enumerableModule)
      Deprecated.
    • setEnumerator

      @Deprecated void setEnumerator(RubyClass enumeratorClass)
      Deprecated.
    • setYielder

      @Deprecated void setYielder(RubyClass yielderClass)
      Deprecated.
    • setGenerator

      @Deprecated public void setGenerator(RubyClass generatorClass)
      Deprecated.
    • setFiber

      @Deprecated public void setFiber(RubyClass fiberClass)
      Deprecated.
    • setString

      @Deprecated void setString(RubyClass stringClass)
      Deprecated.
    • setEncoding

      @Deprecated void setEncoding(RubyClass encodingClass)
      Deprecated.
    • setConverter

      @Deprecated void setConverter(RubyClass converterClass)
      Deprecated.
    • setSymbol

      @Deprecated void setSymbol(RubyClass symbolClass)
      Deprecated.
    • setArray

      @Deprecated void setArray(RubyClass arrayClass)
      Deprecated.
    • setHash

      @Deprecated void setHash(RubyClass hashClass)
      Deprecated.
    • setRange

      @Deprecated void setRange(RubyClass rangeClass)
      Deprecated.
    • setNilClass

      @Deprecated void setNilClass(RubyClass nilClass)
      Deprecated.
    • setTrueClass

      @Deprecated void setTrueClass(RubyClass trueClass)
      Deprecated.
    • setFalseClass

      @Deprecated void setFalseClass(RubyClass falseClass)
      Deprecated.
    • setProc

      @Deprecated void setProc(RubyClass procClass)
      Deprecated.
    • setBinding

      @Deprecated void setBinding(RubyClass bindingClass)
      Deprecated.
    • setMethod

      @Deprecated void setMethod(RubyClass methodClass)
      Deprecated.
    • setUnboundMethod

      @Deprecated void setUnboundMethod(RubyClass unboundMethodClass)
      Deprecated.
    • setMatchData

      @Deprecated void setMatchData(RubyClass matchDataClass)
      Deprecated.
    • setRegexp

      @Deprecated void setRegexp(RubyClass regexpClass)
      Deprecated.
    • setTime

      @Deprecated void setTime(RubyClass timeClass)
      Deprecated.
    • setMath

      @Deprecated void setMath(RubyModule mathModule)
      Deprecated.
    • setMarshal

      @Deprecated void setMarshal(RubyModule marshalModule)
      Deprecated.
    • setBignum

      @Deprecated void setBignum(RubyClass bignumClass)
      Deprecated.
    • setDir

      @Deprecated void setDir(RubyClass dirClass)
      Deprecated.
    • setFile

      @Deprecated void setFile(RubyClass fileClass)
      Deprecated.
    • setFileStat

      @Deprecated void setFileStat(RubyClass fileStatClass)
      Deprecated.
    • setFileTest

      @Deprecated void setFileTest(RubyModule fileTestModule)
      Deprecated.
    • setIO

      @Deprecated void setIO(RubyClass ioClass)
      Deprecated.
    • setThread

      @Deprecated void setThread(RubyClass threadClass)
      Deprecated.
    • setThreadGroup

      @Deprecated void setThreadGroup(RubyClass threadGroupClass)
      Deprecated.
    • setContinuation

      @Deprecated void setContinuation(RubyClass continuationClass)
      Deprecated.
    • setStructClass

      @Deprecated void setStructClass(RubyClass structClass)
      Deprecated.
    • setRandomClass

      @Deprecated void setRandomClass(RubyClass randomClass)
      Deprecated.
    • setGC

      @Deprecated void setGC(RubyModule gcModule)
      Deprecated.
    • setObjectSpaceModule

      @Deprecated void setObjectSpaceModule(RubyModule objectSpaceModule)
      Deprecated.
    • setProcess

      @Deprecated void setProcess(RubyModule processModule)
      Deprecated.
    • setWarning

      @Deprecated public void setWarning(RubyModule warningModule)
      Deprecated.
    • setException

      @Deprecated void setException(RubyClass exceptionClass)
      Deprecated.
    • addToObjectSpace

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

      @Deprecated private void setNetworkStack()
      Deprecated.
    • deprecatedNetworkStackProperty

      private void deprecatedNetworkStackProperty()
    • newErrnoEADDRFromBindException

      @Deprecated public RaiseException newErrnoEADDRFromBindException(BindException be)
      Deprecated.