org.jruby
Class Ruby

java.lang.Object
  extended by org.jruby.Ruby

public final class Ruby
extends java.lang.Object

The Ruby object represents the top-level of a JRuby "instance" in a given VM. JRuby supports spawning multiple instances in the same JVM. Generally, objects created under these instances are tied to a given runtime, for such details as identity and type, because multiple Ruby instances means there are multiple instances of each class. This means that in multi-runtime mode (or really, multi-VM mode, where each JRuby instance is a ruby "VM"), objects generally can't be transported across runtimes without marshaling. This class roots everything that makes the JRuby runtime function, and provides a number of utility methods for constructing global types and accessing global runtime structures.


Nested Class Summary
 class Ruby.CallTraceFuncHook
           
static class Ruby.DaemonThreadFactory
          A ThreadFactory for when we're using pooled threads; we want to create the threads with daemon = true so they don't keep us from shutting down.
 
Field Summary
 RubyFixnum[] fixnumCache
           
static boolean RUNTIME_THREADLOCAL
           
 
Method Summary
 void addEventHook(EventHook hook)
           
 void addFinalizer(Finalizable finalizer)
           
 void addInternalFinalizer(Finalizable finalizer)
           
 int allocModuleId()
           
 int allocSymbolId()
           
 CallbackFactory callbackFactory(java.lang.Class<?> type)
           
 void callEventHooks(ThreadContext context, int event, java.lang.String file, int line, java.lang.String name, IRubyObject type)
           
 void checkSafeString(IRubyObject object)
           
 void compileAndLoadFile(java.lang.String filename, java.io.InputStream in, boolean wrap)
           
 RubyClass defineClass(java.lang.String name, RubyClass superClass, ObjectAllocator allocator)
          Define a new class under the Object namespace.
 RubyClass defineClassUnder(java.lang.String name, RubyClass superClass, ObjectAllocator allocator, RubyModule parent)
          Define a new class with the given name under the given module or class namespace.
 void defineGlobalConstant(java.lang.String name, IRubyObject value)
          rb_define_global_const
 RubyModule defineModule(java.lang.String name)
          Define a new module under the Object namespace.
 RubyModule defineModuleUnder(java.lang.String name, RubyModule parent)
          Define a new module with the given name under the given module or class namespace.
 void defineReadonlyVariable(java.lang.String name, IRubyObject value)
          defines a readonly global variable
 void defineVariable(GlobalVariable variable)
          Defines a global variable
 IRubyObject evalScriptlet(java.lang.String script)
          Evaluates a script under the current scope (perhaps the top-level scope) and returns the result (generally the last value calculated).
 IRubyObject executeScript(java.lang.String script, java.lang.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.
 RubyClass fastGetClass(java.lang.String internedName)
          Retrieve the class with the given name from the Object namespace.
 RubyModule fastGetModule(java.lang.String internedName)
          Retrieve the module with the given name from the Object namespace.
 RubySymbol fastNewSymbol(java.lang.String internedName)
          Faster than newSymbol(String) if you already have an interned name String.
 RubyClass getArray()
           
 RubyClass getBignum()
           
 RubyClass getBinding()
           
 CacheMap getCacheMap()
          Retrieve mappings of cached methods to where they have been cached.
 RubyClass getClass(java.lang.String name)
          Retrieve the class with the given name from the Object namespace.
 RubyClass getClassClass()
           
 RubyModule getClassFromPath(java.lang.String path)
           
 RubyModule getComparable()
           
 RubyClass getContinuation()
           
 ThreadContext getCurrentContext()
           
 java.lang.String getCurrentDirectory()
           
static Ruby getCurrentInstance()
           
 IRubyObject getDebug()
          Getter for property isDebug.
static Ruby getDefaultInstance()
          Deprecated. use #newInstance()
 java.util.Map<java.lang.Integer,java.lang.ref.WeakReference<ChannelDescriptor>> getDescriptors()
           
 RubyClass getDir()
           
 RubyClass getDummy()
           
 RubyModule getEnumerable()
           
 java.io.PrintStream getErr()
           
 RubyClass getErrno(int n)
           
 java.io.PrintStream getErrorStream()
           
 RubyModule getEtc()
           
 RubyClass getException()
           
 java.util.concurrent.ExecutorService getExecutor()
           
 RubyBoolean getFalse()
          Returns the "false" instance from the instance pool.
 RubyClass getFalseClass()
           
 RubyClass getFile()
           
 RubyClass getFileStat()
           
 RubyModule getFileTest()
           
 RubyClass getFixnum()
           
 RubyClass getFloat()
           
 RubyModule getGC()
           
 long getGlobalState()
          GET_VM_STATE_VERSION
 GlobalVariables getGlobalVariables()
           
 IRubyObject getGroupStruct()
           
 RubyClass getHash()
           
 java.io.InputStream getIn()
           
 java.io.InputStream getInputStream()
           
 RubyInstanceConfig getInstanceConfig()
           
 RubyClass getInteger()
           
 RubyClass getIO()
           
 JavaSupport getJavaSupport()
           
 java.util.Set<Script> getJittedMethods()
           
 JRubyClassLoader getJRubyClassLoader()
           
 java.lang.String getJRubyHome()
           
 KCode getKCode()
           
 RubyModule getKernel()
           
 LoadService getLoadService()
          Returns the loadService.
 RubyModule getMarshal()
           
 RubyClass getMatchData()
           
 RubyModule getMath()
           
 RubyClass getMethod()
           
 RubyClass getModule()
           
 RubyModule getModule(java.lang.String name)
          Retrieve the module with the given name from the Object namespace.
 IRubyObject getNil()
          Returns the "nil" singleton instance.
 RubyClass getNilClass()
           
 RubyClass getNumeric()
           
 RubyClass getObject()
           
 ObjectSpace getObjectSpace()
           
 RubyModule getObjectSpaceModule()
           
 java.lang.Object getObjectToYamlMethod()
           
 RubyModule getOrCreateModule(java.lang.String name)
          From Object, retrieve the named module.
 java.io.PrintStream getOut()
           
 java.io.PrintStream getOutputStream()
           
 IRubyObject getPasswdStruct()
           
 POSIX getPosix()
           
 RubyModule getPrecision()
           
 RubyClass getProc()
           
 RubyModule getProcess()
           
 RubyModule getProcGID()
           
 RubyClass getProcStatus()
           
 RubyModule getProcSysModule()
           
 RubyModule getProcUID()
           
 Profile getProfile()
           
 java.util.Random getRandom()
           
 long getRandomSeed()
           
 RubyClass getRange()
           
 GlobalVariable getRecordSeparatorVar()
           
 RubyClass getRegexp()
           
 int getSafeLevel()
          Retrieve the current safe level.
 int getStackTraces()
           
 RubyClass getStandardError()
           
 long getStartTime()
           
 RubyClass getString()
           
 RubyClass getStructClass()
           
 RubyClass getSymbol()
           
 RubySymbol.SymbolTable getSymbolTable()
           
 RubyClass getThread()
           
 RubyClass getThreadGroup()
           
 ThreadService getThreadService()
           
 RubyClass getTime()
           
 IRubyObject getTmsStruct()
           
 IRubyObject getTopSelf()
          Getter for property rubyTopSelf.
 RubyBoolean getTrue()
          Returns the "true" instance from the instance pool.
 RubyClass getTrueClass()
           
 RubyClass getUnboundMethod()
           
 IRubyObject getVerbose()
          Getter for property isVerbose.
 RubyWarnings getWarnings()
           
 boolean hasEventHooks()
           
 void incGlobalState()
          INC_VM_STATE_VERSION
 long incrementRandomSeedSequence()
           
 boolean isClassDefined(java.lang.String name)
           
 boolean isDoNotReverseLookupEnabled()
           
 boolean isGlobalAbortOnExceptionEnabled()
           
 boolean isInspecting(java.lang.Object obj)
           
 boolean isObjectSpaceEnabled()
           
static boolean isSecurityRestricted()
           
 void loadFile(java.lang.String scriptName, java.io.InputStream in, boolean wrap)
           
 void loadScript(Script script)
           
 RaiseException newArgumentError(int got, int expected)
           
 RaiseException newArgumentError(java.lang.String message)
           
 RubyArray newArray()
           
 RubyArray newArray(int size)
           
 RubyArray newArray(IRubyObject object)
           
 RubyArray newArray(IRubyObject[] objects)
           
 RubyArray newArray(IRubyObject car, IRubyObject cdr)
           
 RubyArray newArray(java.util.List<IRubyObject> list)
           
 RubyArray newArrayLight()
           
 RubyArray newArrayNoCopy(IRubyObject[] objects)
           
 RubyArray newArrayNoCopyLight(IRubyObject[] objects)
           
 RubyBinding newBinding()
           
 RubyBinding newBinding(Binding binding)
           
 RubyBoolean newBoolean(boolean value)
           
 RubyArray newEmptyArray()
           
 RaiseException newEOFError()
           
 RaiseException newEOFError(java.lang.String message)
           
 RaiseException newErrnoEACCESError(java.lang.String message)
           
 RaiseException newErrnoEADDRINUSEError()
           
 RaiseException newErrnoEAGAINError(java.lang.String message)
           
 RaiseException newErrnoEBADFError()
           
 RaiseException newErrnoEBADFError(java.lang.String message)
           
 RaiseException newErrnoECHILDError()
           
 RaiseException newErrnoECONNREFUSEDError()
           
 RaiseException newErrnoEDOMError(java.lang.String message)
           
 RaiseException newErrnoEEXISTError(java.lang.String message)
           
 RaiseException newErrnoEINVALError()
           
 RaiseException newErrnoEINVALError(java.lang.String message)
           
 RaiseException newErrnoEISDirError()
           
 RaiseException newErrnoENOENTError()
           
 RaiseException newErrnoENOENTError(java.lang.String message)
           
 RaiseException newErrnoENOPROTOOPTError()
           
 RaiseException newErrnoENOTDIRError(java.lang.String message)
           
 RaiseException newErrnoEPIPEError()
           
 RaiseException newErrnoESPIPEError()
           
 RaiseException newErrnoESPIPEError(java.lang.String message)
           
 RubyFileStat newFileStat(java.io.FileDescriptor descriptor)
           
 RubyFileStat newFileStat(java.lang.String filename, boolean lstat)
           
 RubyFixnum newFixnum(long value)
           
 RubyFloat newFloat(double value)
           
 RaiseException newFloatDomainError(java.lang.String message)
           
 RaiseException newFrozenError(java.lang.String objectType)
           
 RaiseException newIndexError(java.lang.String message)
           
static Ruby newInstance()
          Returns a new instance of the JRuby runtime configured with defaults.
static Ruby newInstance(java.io.InputStream in, java.io.PrintStream out, java.io.PrintStream err)
          Returns a new instance of the JRuby runtime configured with the given input, output and error streams and otherwise default configuration (except where specified system properties alter defaults).
static Ruby newInstance(RubyInstanceConfig config)
          Returns a new instance of the JRuby runtime configured as specified.
 RaiseException newInvalidEncoding(java.lang.String message)
           
 RaiseException newIOError(java.lang.String message)
           
 RaiseException newIOErrorFromException(java.io.IOException ioe)
           
 RaiseException newLoadError(java.lang.String message)
           
 RaiseException newLocalJumpError(java.lang.String reason, IRubyObject exitValue, java.lang.String message)
           
 RaiseException newNameError(java.lang.String message, java.lang.String name)
           
 RaiseException newNameError(java.lang.String message, java.lang.String name, java.lang.Throwable origException)
           
 RaiseException newNameError(java.lang.String message, java.lang.String name, java.lang.Throwable origException, boolean printWhenVerbose)
           
 RaiseException newNoMethodError(java.lang.String message, java.lang.String name, IRubyObject args)
           
 RaiseException newNotImplementedError(java.lang.String message)
           
 RubyNumeric newNumeric()
           
 RubyProc newProc(Block.Type type, Block block)
           
 RaiseException newRangeError(java.lang.String message)
           
 RaiseException newRedoLocalJumpError()
           
 RaiseException newRegexpError(java.lang.String message)
           
 RaiseException newRuntimeError(java.lang.String message)
           
 RaiseException newSecurityError(java.lang.String message)
           
 RaiseException newStandardError(java.lang.String message)
           
 RubyString newString()
           
 RubyString newString(ByteList byteList)
           
 RubyString newString(java.lang.String string)
           
 RubyString newStringShared(ByteList byteList)
           
 RubySymbol newSymbol(java.lang.String name)
           
 RaiseException newSyntaxError(java.lang.String message)
           
 RaiseException newSystemCallError(java.lang.String message)
           
 RaiseException newSystemExit(int status)
           
 RaiseException newSystemStackError(java.lang.String message)
           
 RaiseException newThreadError(java.lang.String message)
           
 RubyTime newTime(long milliseconds)
           
 RaiseException newTypeError(IRubyObject receivedObject, RubyClass expectedType)
           
 RaiseException newTypeError(java.lang.String message)
           
 RaiseException newZeroDivisionError()
           
 Node parse(ByteList content, java.lang.String file, DynamicScope scope, int lineNumber, boolean extraPositionInformation)
           
 Node parse(java.lang.String content, java.lang.String file, DynamicScope scope, int lineNumber, boolean extraPositionInformation)
           
 Node parseEval(ByteList content, java.lang.String file, DynamicScope scope, int lineNumber)
           
 Node parseEval(java.lang.String content, java.lang.String file, DynamicScope scope, int lineNumber)
           
 Node parseFile(java.io.InputStream in, java.lang.String file, DynamicScope scope)
           
 Node parseFromMain(java.io.InputStream inputStream, java.lang.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.
 Node parseInline(java.io.InputStream in, java.lang.String file, DynamicScope scope)
           
 void printError(RubyException excp)
          Prints an error with backtrace to the error stream.
 IRubyObject pushExitBlock(RubyProc proc)
          Push block onto exit stack.
 void registerInspecting(java.lang.Object obj)
           
 void removeEventHook(EventHook hook)
           
 void removeFinalizer(Finalizable finalizer)
           
 void removeInternalFinalizer(Finalizable finalizer)
           
 void runFromMain(java.io.InputStream inputStream, java.lang.String filename)
          Run the script contained in the specified input stream, using the specified filename as the name of the script being executed.
 IRubyObject runNormally(Node scriptNode, boolean yarvCompile)
          Run the specified script without any of the loop-processing wrapper code.
 IRubyObject runWithGetsLoop(Node scriptNode, boolean printing, boolean processLineEnds, boolean split, boolean yarvCompile)
          Run the given script with a "while gets; end" loop wrapped around it.
 void secure(int level)
           
 void setCurrentDirectory(java.lang.String dir)
           
static void setCurrentInstance(Ruby runtime)
           
 void setDebug(IRubyObject debug)
          Setter for property isDebug.
 void setDoNotReverseLookupEnabled(boolean b)
           
 void setEtc(RubyModule etcModule)
           
 void setGlobalAbortOnExceptionEnabled(boolean enable)
           
 void setGlobalVariables(GlobalVariables globalVariables)
           
 void setJRubyHome(java.lang.String home)
           
 void setKCode(KCode kcode)
           
 void setRandomSeed(long randomSeed)
           
 void setRecordSeparatorVar(GlobalVariable recordSeparatorVar)
           
 void setSafeLevel(int safeLevel)
          Set the current safe level: 0 - strings from streams/environment/ARGV are tainted (default) 1 - no dangerous operation by tainted value 2 - process/file operations prohibited 3 - all generated objects are tainted 4 - no global (non-tainted) variable modification/no direct output The safe level is set using $SAFE in Ruby code.
static void setSecurityRestricted(boolean restricted)
           
 void setStackTraces(int stackTraces)
           
 void setTraceFunction(RubyProc traceFunction)
           
 void setVerbose(IRubyObject verbose)
          Setter for property isVerbose.
 void tearDown()
          Make sure Kernel#at_exit procs get invoked on runtime shutdown.
 void unregisterInspecting(java.lang.Object obj)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RUNTIME_THREADLOCAL

public static final boolean RUNTIME_THREADLOCAL

fixnumCache

public final RubyFixnum[] fixnumCache
Method Detail

newInstance

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

Returns:
the JRuby runtime
See Also:
RubyInstanceConfig

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

newInstance

public static Ruby newInstance(java.io.InputStream in,
                               java.io.PrintStream out,
                               java.io.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:
RubyInstanceConfig

evalScriptlet

public IRubyObject evalScriptlet(java.lang.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

executeScript

public IRubyObject executeScript(java.lang.String script,
                                 java.lang.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(java.io.InputStream inputStream,
                        java.lang.String filename)
Run the script contained in the specified input stream, using the specified filename as the name of the script being executed. The stream will be read fully before being parsed and executed. The given filename will be used for the ruby $PROGRAM_NAME and $0 global variables in this runtime. This method is intended to be called once per runtime, generally from Main or from main-like top-level entry points. As part of executing the script loaded from the input stream, various RubyInstanceConfig properties will be used to determine whether to compile the script before execution or run with various wrappers (for looping, printing, and so on, see jruby -help).

Parameters:
inputStream - The InputStream from which to read the script contents
filename - The filename to use when parsing, and for $PROGRAM_NAME and $0 ruby global variables.

parseFromMain

public Node parseFromMain(java.io.InputStream inputStream,
                          java.lang.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

runWithGetsLoop

public IRubyObject runWithGetsLoop(Node scriptNode,
                                   boolean printing,
                                   boolean processLineEnds,
                                   boolean split,
                                   boolean yarvCompile)
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
yarvCompile - Whether to compile the target script to YARV (Ruby 1.9) bytecode before executing.
Returns:
The result of executing the specified script

runNormally

public IRubyObject runNormally(Node scriptNode,
                               boolean yarvCompile)
Run the specified script without any of the loop-processing wrapper code.

Parameters:
scriptNode - The root node of the script to be executed
yarvCompile - Whether to compile the script to YARV (Ruby 1.9) bytecode before execution
Returns:
The result of executing the script

getDefaultInstance

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


getCurrentInstance

public static Ruby getCurrentInstance()

setCurrentInstance

public static void setCurrentInstance(Ruby runtime)

allocSymbolId

public int allocSymbolId()

allocModuleId

public int allocModuleId()

getModule

public RubyModule getModule(java.lang.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

public RubyModule fastGetModule(java.lang.String internedName)
Retrieve the module 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 module; must be an interned String
Returns:
The module or null if not found

getClass

public RubyClass getClass(java.lang.String name)
Retrieve the class with the given name from the Object namespace.

Parameters:
name - The name of the class
Returns:
The class

fastGetClass

public RubyClass fastGetClass(java.lang.String internedName)
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(java.lang.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

defineClassUnder

public RubyClass defineClassUnder(java.lang.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

defineModule

public RubyModule defineModule(java.lang.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(java.lang.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(java.lang.String name)
From Object, retrieve the named module. If it doesn't exist a new module is created.

Parameters:
name - The name of the module

getSafeLevel

public int getSafeLevel()
Retrieve the current safe level.

See Also:
org.jruby.Ruby#setSaveLevel

setSafeLevel

public void setSafeLevel(int safeLevel)
Set the current safe level: 0 - strings from streams/environment/ARGV are tainted (default) 1 - no dangerous operation by tainted value 2 - process/file operations prohibited 3 - all generated objects are tainted 4 - no global (non-tainted) variable modification/no direct output The safe level is set using $SAFE in Ruby code. It is not particularly well supported in JRuby.


getKCode

public KCode getKCode()

setKCode

public void setKCode(KCode kcode)

secure

public void secure(int level)

checkSafeString

public void checkSafeString(IRubyObject object)

defineGlobalConstant

public void defineGlobalConstant(java.lang.String name,
                                 IRubyObject value)
rb_define_global_const


isClassDefined

public boolean isClassDefined(java.lang.String name)

getErrno

public RubyClass getErrno(int n)

getObjectToYamlMethod

public java.lang.Object getObjectToYamlMethod()

getCacheMap

public CacheMap getCacheMap()
Retrieve mappings of cached methods to where they have been cached. When a cached method needs to be invalidated this map can be used to remove all places it has been cached.

Returns:
the mappings of where cached methods have been stored

getTopSelf

public IRubyObject getTopSelf()
Getter for property rubyTopSelf.

Returns:
Value of property rubyTopSelf.

setCurrentDirectory

public void setCurrentDirectory(java.lang.String dir)

getCurrentDirectory

public java.lang.String getCurrentDirectory()

getEtc

public RubyModule getEtc()

setEtc

public void setEtc(RubyModule etcModule)

getObject

public RubyClass getObject()

getModule

public RubyClass getModule()

getClassClass

public RubyClass getClassClass()

getKernel

public RubyModule getKernel()

getDummy

public RubyClass getDummy()

getComparable

public RubyModule getComparable()

getNumeric

public RubyClass getNumeric()

getFloat

public RubyClass getFloat()

getInteger

public RubyClass getInteger()

getFixnum

public RubyClass getFixnum()

getEnumerable

public RubyModule getEnumerable()

getString

public RubyClass getString()

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"

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()

getContinuation

public RubyClass getContinuation()

getStructClass

public RubyClass getStructClass()

getTmsStruct

public IRubyObject getTmsStruct()

getPasswdStruct

public IRubyObject getPasswdStruct()

getGroupStruct

public IRubyObject getGroupStruct()

getGC

public RubyModule getGC()

getObjectSpaceModule

public RubyModule getObjectSpaceModule()

getProcess

public RubyModule getProcess()

getProcStatus

public RubyClass getProcStatus()

getProcUID

public RubyModule getProcUID()

getProcGID

public RubyModule getProcGID()

getProcSysModule

public RubyModule getProcSysModule()

getPrecision

public RubyModule getPrecision()

getException

public RubyClass getException()

getStandardError

public RubyClass getStandardError()

getVerbose

public IRubyObject getVerbose()
Getter for property isVerbose.

Returns:
Value of property isVerbose.

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.

setDebug

public void setDebug(IRubyObject debug)
Setter for property isDebug.

Parameters:
debug - New value of property isDebug.

getJavaSupport

public JavaSupport getJavaSupport()

getJRubyClassLoader

public JRubyClassLoader getJRubyClassLoader()

defineVariable

public void defineVariable(GlobalVariable variable)
Defines a global variable


defineReadonlyVariable

public void defineReadonlyVariable(java.lang.String name,
                                   IRubyObject value)
defines a readonly global variable


parseFile

public Node parseFile(java.io.InputStream in,
                      java.lang.String file,
                      DynamicScope scope)

parseInline

public Node parseInline(java.io.InputStream in,
                        java.lang.String file,
                        DynamicScope scope)

parseEval

public Node parseEval(java.lang.String content,
                      java.lang.String file,
                      DynamicScope scope,
                      int lineNumber)

parse

public Node parse(java.lang.String content,
                  java.lang.String file,
                  DynamicScope scope,
                  int lineNumber,
                  boolean extraPositionInformation)

parseEval

public Node parseEval(ByteList content,
                      java.lang.String file,
                      DynamicScope scope,
                      int lineNumber)

parse

public Node parse(ByteList content,
                  java.lang.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

getWarnings

public RubyWarnings getWarnings()

getErrorStream

public java.io.PrintStream getErrorStream()

getInputStream

public java.io.InputStream getInputStream()

getOutputStream

public java.io.PrintStream getOutputStream()

getClassFromPath

public RubyModule getClassFromPath(java.lang.String path)

printError

public void printError(RubyException excp)
Prints an error with backtrace to the error stream. MRI: eval.c - error_print()


loadFile

public void loadFile(java.lang.String scriptName,
                     java.io.InputStream in,
                     boolean wrap)

compileAndLoadFile

public void compileAndLoadFile(java.lang.String filename,
                               java.io.InputStream in,
                               boolean wrap)

loadScript

public void loadScript(Script script)

addEventHook

public void addEventHook(EventHook hook)

removeEventHook

public void removeEventHook(EventHook hook)

setTraceFunction

public void setTraceFunction(RubyProc traceFunction)

callEventHooks

public void callEventHooks(ThreadContext context,
                           int event,
                           java.lang.String file,
                           int line,
                           java.lang.String name,
                           IRubyObject type)

hasEventHooks

public boolean hasEventHooks()

getGlobalVariables

public GlobalVariables getGlobalVariables()

setGlobalVariables

public void setGlobalVariables(GlobalVariables globalVariables)

callbackFactory

public CallbackFactory callbackFactory(java.lang.Class<?> type)

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

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 get 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.


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(java.util.List<IRubyObject> list)

newArray

public RubyArray newArray(int size)

newBoolean

public RubyBoolean newBoolean(boolean value)

newFileStat

public RubyFileStat newFileStat(java.lang.String filename,
                                boolean lstat)

newFileStat

public RubyFileStat newFileStat(java.io.FileDescriptor descriptor)

newFixnum

public RubyFixnum newFixnum(long value)

newFloat

public RubyFloat newFloat(double value)

newNumeric

public RubyNumeric newNumeric()

newProc

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

newBinding

public RubyBinding newBinding()

newBinding

public RubyBinding newBinding(Binding binding)

newString

public RubyString newString()

newString

public RubyString newString(java.lang.String string)

newString

public RubyString newString(ByteList byteList)

newStringShared

public RubyString newStringShared(ByteList byteList)

newSymbol

public RubySymbol newSymbol(java.lang.String name)

fastNewSymbol

public RubySymbol fastNewSymbol(java.lang.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(java.lang.String message)

newArgumentError

public RaiseException newArgumentError(java.lang.String message)

newArgumentError

public RaiseException newArgumentError(int got,
                                       int expected)

newErrnoEBADFError

public RaiseException newErrnoEBADFError()

newErrnoENOPROTOOPTError

public RaiseException newErrnoENOPROTOOPTError()

newErrnoEPIPEError

public RaiseException newErrnoEPIPEError()

newErrnoECONNREFUSEDError

public RaiseException newErrnoECONNREFUSEDError()

newErrnoEADDRINUSEError

public RaiseException newErrnoEADDRINUSEError()

newErrnoEINVALError

public RaiseException newErrnoEINVALError()

newErrnoENOENTError

public RaiseException newErrnoENOENTError()

newErrnoEACCESError

public RaiseException newErrnoEACCESError(java.lang.String message)

newErrnoEAGAINError

public RaiseException newErrnoEAGAINError(java.lang.String message)

newErrnoEISDirError

public RaiseException newErrnoEISDirError()

newErrnoESPIPEError

public RaiseException newErrnoESPIPEError()

newErrnoEBADFError

public RaiseException newErrnoEBADFError(java.lang.String message)

newErrnoEINVALError

public RaiseException newErrnoEINVALError(java.lang.String message)

newErrnoENOTDIRError

public RaiseException newErrnoENOTDIRError(java.lang.String message)

newErrnoENOENTError

public RaiseException newErrnoENOENTError(java.lang.String message)

newErrnoESPIPEError

public RaiseException newErrnoESPIPEError(java.lang.String message)

newErrnoEEXISTError

public RaiseException newErrnoEEXISTError(java.lang.String message)

newErrnoEDOMError

public RaiseException newErrnoEDOMError(java.lang.String message)

newErrnoECHILDError

public RaiseException newErrnoECHILDError()

newIndexError

public RaiseException newIndexError(java.lang.String message)

newSecurityError

public RaiseException newSecurityError(java.lang.String message)

newSystemCallError

public RaiseException newSystemCallError(java.lang.String message)

newTypeError

public RaiseException newTypeError(java.lang.String message)

newThreadError

public RaiseException newThreadError(java.lang.String message)

newSyntaxError

public RaiseException newSyntaxError(java.lang.String message)

newRegexpError

public RaiseException newRegexpError(java.lang.String message)

newRangeError

public RaiseException newRangeError(java.lang.String message)

newNotImplementedError

public RaiseException newNotImplementedError(java.lang.String message)

newInvalidEncoding

public RaiseException newInvalidEncoding(java.lang.String message)

newNoMethodError

public RaiseException newNoMethodError(java.lang.String message,
                                       java.lang.String name,
                                       IRubyObject args)

newNameError

public RaiseException newNameError(java.lang.String message,
                                   java.lang.String name)

newNameError

public RaiseException newNameError(java.lang.String message,
                                   java.lang.String name,
                                   java.lang.Throwable origException)

newNameError

public RaiseException newNameError(java.lang.String message,
                                   java.lang.String name,
                                   java.lang.Throwable origException,
                                   boolean printWhenVerbose)

newLocalJumpError

public RaiseException newLocalJumpError(java.lang.String reason,
                                        IRubyObject exitValue,
                                        java.lang.String message)

newRedoLocalJumpError

public RaiseException newRedoLocalJumpError()

newLoadError

public RaiseException newLoadError(java.lang.String message)

newFrozenError

public RaiseException newFrozenError(java.lang.String objectType)

newSystemStackError

public RaiseException newSystemStackError(java.lang.String message)

newSystemExit

public RaiseException newSystemExit(int status)

newIOError

public RaiseException newIOError(java.lang.String message)

newStandardError

public RaiseException newStandardError(java.lang.String message)

newIOErrorFromException

public RaiseException newIOErrorFromException(java.io.IOException ioe)

newTypeError

public RaiseException newTypeError(IRubyObject receivedObject,
                                   RubyClass expectedType)

newEOFError

public RaiseException newEOFError()

newEOFError

public RaiseException newEOFError(java.lang.String message)

newZeroDivisionError

public RaiseException newZeroDivisionError()

newFloatDomainError

public RaiseException newFloatDomainError(java.lang.String message)

getSymbolTable

public RubySymbol.SymbolTable getSymbolTable()

setStackTraces

public void setStackTraces(int stackTraces)

getStackTraces

public int getStackTraces()

setRandomSeed

public void setRandomSeed(long randomSeed)

getRandomSeed

public long getRandomSeed()

getRandom

public java.util.Random getRandom()

getObjectSpace

public ObjectSpace getObjectSpace()

getDescriptors

public java.util.Map<java.lang.Integer,java.lang.ref.WeakReference<ChannelDescriptor>> getDescriptors()

incrementRandomSeedSequence

public long incrementRandomSeedSequence()

getIn

public java.io.InputStream getIn()

getOut

public java.io.PrintStream getOut()

getErr

public java.io.PrintStream getErr()

isGlobalAbortOnExceptionEnabled

public boolean isGlobalAbortOnExceptionEnabled()

setGlobalAbortOnExceptionEnabled

public void setGlobalAbortOnExceptionEnabled(boolean enable)

isDoNotReverseLookupEnabled

public boolean isDoNotReverseLookupEnabled()

setDoNotReverseLookupEnabled

public void setDoNotReverseLookupEnabled(boolean b)

registerInspecting

public void registerInspecting(java.lang.Object obj)

isInspecting

public boolean isInspecting(java.lang.Object obj)

unregisterInspecting

public void unregisterInspecting(java.lang.Object obj)

isObjectSpaceEnabled

public boolean isObjectSpaceEnabled()

getStartTime

public long getStartTime()

getProfile

public Profile getProfile()

getJRubyHome

public java.lang.String getJRubyHome()

setJRubyHome

public void setJRubyHome(java.lang.String home)

getInstanceConfig

public RubyInstanceConfig getInstanceConfig()

getGlobalState

public long getGlobalState()
GET_VM_STATE_VERSION


incGlobalState

public void incGlobalState()
INC_VM_STATE_VERSION


isSecurityRestricted

public static boolean isSecurityRestricted()

setSecurityRestricted

public static void setSecurityRestricted(boolean restricted)

getPosix

public POSIX getPosix()

setRecordSeparatorVar

public void setRecordSeparatorVar(GlobalVariable recordSeparatorVar)

getRecordSeparatorVar

public GlobalVariable getRecordSeparatorVar()

getJittedMethods

public java.util.Set<Script> getJittedMethods()

getExecutor

public java.util.concurrent.ExecutorService getExecutor()


Copyright © 2002-2007 JRuby Team. All Rights Reserved.