Top Description Inners Constructors Methods
org.jruby.ext.jruby

public Class JRubyUtilLibrary

extends Object
implements Library
Class Inheritance
All Implemented Interfaces
org.jruby.runtime.load.Library
Imports
java.io.IOException, java.net.URL, java.util.Enumeration, .List, org.jruby.*, org.jruby.anno.JRubyMethod, org.jruby.ast.util.ArgsUtil, org.jruby.exceptions.RaiseException, org.jruby.java.proxies.ConcreteJavaProxy, org.jruby.javasupport.Java, org.jruby.runtime.Arity, .Block, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.load.BasicLibraryService, .Library, org.jruby.util.ClasspathLauncher

Utilities library for all those methods that don't need the full 'java' library to be loaded. This is done mostly for performance reasons. For example, for those who only need to enable the object space, not loading 'java' might save 200-300ms of startup time, like in case of jirb.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static IRubyObject
cache_stats(ThreadContext context, IRubyObject self)

Provide stats on how many method and constant invalidations have occurred globally.

public static IRubyObject

Returns:

an enumerable of class-loader resources
class_loader_resources
(ThreadContext context, IRubyObject recv, IRubyObject...
(name, raw: false, path: false)
args
)

Note

class_loader_resources alias exists since 9.2

public static IRubyObject
public static IRubyObject
public static IRubyObject
public static IRubyObject
gc(ThreadContext context, IRubyObject recv)

public static IRubyObject
public static IRubyObject
public static IRubyObject
getObjectSpaceEnabled(IRubyObject recv)
Deprecated since 9.4-.

private static Object
public static RubyArray<T extends IRubyObject>
internal_libraries(ThreadContext context, IRubyObject self)
Deprecated since 9.4-.

Return a list of files and extensions that JRuby treats as internal (or "built-in"), skipping load path and filesystem search.

public void
load(Ruby runtime, boolean wrap)

Implements org.jruby.runtime.load.Library.load.

public static IRubyObject

Returns:

loading outcome
load_ext
(ThreadContext context, IRubyObject recv, IRubyObject klass)

Prefered way to boot-up JRuby extensions (available as JRuby.load_ext).

public static IRubyObject

Returns:

Java class (wrapper) or raises a NameError if loading fails or class is not found
load_java_class
(ThreadContext context, IRubyObject recv, IRubyObject
the class name
name
)

Loads a (Java) class.

private static boolean
loadExtension(ThreadContext context, final String className)

public static IRubyObject
public static IRubyObject

Returns:

the object given
notify
(ThreadContext
the current context
context
,
IRubyObject
the JRuby module
recv
,
IRubyObject
the object to notify
arg
)

Notify one waiter on a locked object, as in Object notify() The object given must be locked using JRuby.synchronized or a similar Java monitor-based locking mechanism.

public static IRubyObject

Returns:

the object given
notifyAll
(ThreadContext
the current context
context
,
IRubyObject
the JRuby module
recv
,
IRubyObject
the object to notify
arg
)

Notify all waiters on a locked object, as in Object notifyAll() The object given must be locked using JRuby.synchronized or a similar Java monitor-based locking mechanism.

public static IRubyObject

Returns:

the return value of the block
rbSynchronized
(ThreadContext
the current context
context
,
IRubyObject
the JRuby module
recv
,
IRubyObject
the object against which to synchronize
arg
,
Block
the block to execute
block
)

Invoke the given block under synchronized lock, using standard Java synchronization.

public static IRubyObject
safe_recurse(ThreadContext context, IRubyObject utilModule, IRubyObject state, IRubyObject obj, IRubyObject name, Block block)

public static IRubyObject
public static IRubyObject
public static IRubyObject
setObjectSpaceEnabled(IRubyObject recv, IRubyObject arg)
Deprecated since 10.0.

public static IRubyObject
public static IRubyObject

Returns:

the object given
wait
(ThreadContext
the current context
context
,
IRubyObject
the JRuby module
recv
,
IRubyObject
the object to wait for
arg
)

Wait for a locked object to notify, as in Object wait().

public static IRubyObject

Returns:

the object given
wait
(ThreadContext
the current context
context
,
IRubyObject
the JRuby module
recv
,
IRubyObject
the object to wait for
arg
,
IRubyObject
the time in millis to wait (converted using #to_int)
timeoutMillis
)

Wait for a locked object to notify, as in Object wait(long).

public static IRubyObject

Returns:

the object given
wait
(ThreadContext
the current context
context
,
IRubyObject
the JRuby module
recv
,
IRubyObject
the object to wait for
arg
,
IRubyObject
the time in millis to wait (converted using #to_int)
timeoutMillis
,
IRubyObject
the time in nanos to wait (converted using #to_int, and truncated to a signed 32-bit integer)
timeoutNanos
)

Wait for a locked object to notify, as in Object wait(long, int).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

JRubyUtilLibraryback to summary
public JRubyUtilLibrary()

Method Detail

cache_statsback to summary
public static IRubyObject cache_stats(ThreadContext context, IRubyObject self)

Provide stats on how many method and constant invalidations have occurred globally. This was added for Pry in https://github.com/jruby/jruby/issues/4384

Annotations
@JRubyMethod
name:cache_stats
module:true
class_loader_resourcesback to summary
public static IRubyObject class_loader_resources(ThreadContext context, IRubyObject recv, IRubyObject... args)

Note

class_loader_resources alias exists since 9.2

Parameters
args:IRubyObject[]

(name, raw: false, path: false)

Returns:IRubyObject

an enumerable of class-loader resources

Annotations
@JRubyMethod
module:true
name:class_loader_resources
alias:classloader_resources
required:1
optional:1
checkArity:false
classpath_launcherback to summary
public static IRubyObject classpath_launcher(ThreadContext context, IRubyObject recv)
Annotations
@JRubyMethod
meta:true
current_directoryback to summary
public static IRubyObject current_directory(ThreadContext context, IRubyObject recv)
Annotations
@JRubyMethod
name:current_directory
meta:true
extra_gem_pathsback to summary
public static IRubyObject extra_gem_paths(ThreadContext context, IRubyObject recv)
Annotations
@JRubyMethod
name:extra_gem_paths
meta:true
gcback to summary
public static IRubyObject gc(ThreadContext context, IRubyObject recv)
Annotations
@JRubyMethod
module:true
getClassLoaderResourcesback to summary
public static IRubyObject getClassLoaderResources(IRubyObject recv, IRubyObject name)

Deprecated

Annotations
@Deprecated
getObjectSpaceEnabledback to summary
public static IRubyObject getObjectSpaceEnabled(ThreadContext context, IRubyObject recv)
Annotations
@JRubyMethod
name:objectspace, object_space?
alias:objectspace?
module:true
getObjectSpaceEnabledback to summary
public static IRubyObject getObjectSpaceEnabled(IRubyObject recv)

Deprecated

since 9.4-.

Annotations
@Deprecated
since:9.4-
getSyncObjectback to summary
private static Object getSyncObject(IRubyObject arg)
internal_librariesback to summary
public static RubyArray<T extends IRubyObject> internal_libraries(ThreadContext context, IRubyObject self)

Deprecated

since 9.4-.

Return a list of files and extensions that JRuby treats as internal (or "built-in"), skipping load path and filesystem search. This was added for Bootsnap

Annotations
@JRubyMethod
module:true
@Deprecated
since:9.4-
loadback to summary
public void load(Ruby runtime, boolean wrap)

Implements org.jruby.runtime.load.Library.load.

load_extback to summary
public static IRubyObject load_ext(ThreadContext context, IRubyObject recv, IRubyObject klass)

Prefered way to boot-up JRuby extensions (available as JRuby.load_ext).

Returns:IRubyObject

loading outcome

Annotations
@JRubyMethod
module:true
name:load_ext
load_java_classback to summary
public static IRubyObject load_java_class(ThreadContext context, IRubyObject recv, IRubyObject name)

Loads a (Java) class.

Parameters
name:IRubyObject

the class name

Returns:IRubyObject

Java class (wrapper) or raises a NameError if loading fails or class is not found

Annotations
@JRubyMethod
meta:true
loadExtensionback to summary
private static boolean loadExtension(ThreadContext context, final String className)
native_posix_pback to summary
public static IRubyObject native_posix_p(ThreadContext context, IRubyObject self)
Annotations
@JRubyMethod
meta:true
name:native_posix?
notifyback to summary
public static IRubyObject notify(ThreadContext context, IRubyObject recv, IRubyObject arg)

Notify one waiter on a locked object, as in Object notify() The object given must be locked using JRuby.synchronized or a similar Java monitor-based locking mechanism.

Parameters
context:ThreadContext

the current context

recv:IRubyObject

the JRuby module

arg:IRubyObject

the object to notify

Returns:IRubyObject

the object given

Annotations
@JRubyMethod
module:true
notifyAllback to summary
public static IRubyObject notifyAll(ThreadContext context, IRubyObject recv, IRubyObject arg)

Notify all waiters on a locked object, as in Object notifyAll() The object given must be locked using JRuby.synchronized or a similar Java monitor-based locking mechanism.

Parameters
context:ThreadContext

the current context

recv:IRubyObject

the JRuby module

arg:IRubyObject

the object to notify

Returns:IRubyObject

the object given

Annotations
@JRubyMethod
name:notify_all
module:true
rbSynchronizedback to summary
public static IRubyObject rbSynchronized(ThreadContext context, IRubyObject recv, IRubyObject arg, Block block)

Invoke the given block under synchronized lock, using standard Java synchronization.

Parameters
context:ThreadContext

the current context

recv:IRubyObject

the JRuby module

arg:IRubyObject

the object against which to synchronize

block:Block

the block to execute

Returns:IRubyObject

the return value of the block

Annotations
@JRubyMethod
name:synchronized
module:true
safe_recurseback to summary
public static IRubyObject safe_recurse(ThreadContext context, IRubyObject utilModule, IRubyObject state, IRubyObject obj, IRubyObject name, Block block)
Annotations
@JRubyMethod
module:true
See Also
ThreadContext#safeRecurse(ThreadContext.RecursiveFunctionEx, Object, IRubyObject, String, boolean)
set_last_exit_statusback to summary
public static IRubyObject set_last_exit_status(ThreadContext context, IRubyObject recv, IRubyObject status, IRubyObject pid)
Annotations
@JRubyMethod
name:set_last_exit_status
meta:true
set_meta_classback to summary
public static IRubyObject set_meta_class(ThreadContext context, IRubyObject recv, IRubyObject obj, IRubyObject klass)
Annotations
@JRubyMethod
meta:true
name:set_meta_class
setObjectSpaceEnabledback to summary
public static IRubyObject setObjectSpaceEnabled(IRubyObject recv, IRubyObject arg)

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
setObjectSpaceEnabledback to summary
public static IRubyObject setObjectSpaceEnabled(ThreadContext context, IRubyObject recv, IRubyObject arg)
Annotations
@JRubyMethod
name:objectspace=, object_space=
module:true
waitback to summary
public static IRubyObject wait(ThreadContext context, IRubyObject recv, IRubyObject arg) throws InterruptedException

Wait for a locked object to notify, as in Object wait().

Parameters
context:ThreadContext

the current context

recv:IRubyObject

the JRuby module

arg:IRubyObject

the object to wait for

Returns:IRubyObject

the object given

Annotations
@JRubyMethod
module:true
Exceptions
InterruptedException:
if interrupted
waitback to summary
public static IRubyObject wait(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject timeoutMillis) throws InterruptedException

Wait for a locked object to notify, as in Object wait(long). The object given must be locked using JRuby.synchronized or a similar Java monitor-based locking mechanism.

Parameters
context:ThreadContext

the current context

recv:IRubyObject

the JRuby module

arg:IRubyObject

the object to wait for

timeoutMillis:IRubyObject

the time in millis to wait (converted using #to_int)

Returns:IRubyObject

the object given

Annotations
@JRubyMethod
module:true
Exceptions
InterruptedException:
if interrupted
waitback to summary
public static IRubyObject wait(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject timeoutMillis, IRubyObject timeoutNanos) throws InterruptedException

Wait for a locked object to notify, as in Object wait(long, int). The object given must be locked using JRuby.synchronized or a similar Java monitor-based locking mechanism.

Parameters
context:ThreadContext

the current context

recv:IRubyObject

the JRuby module

arg:IRubyObject

the object to wait for

timeoutMillis:IRubyObject

the time in millis to wait (converted using #to_int)

timeoutNanos:IRubyObject

the time in nanos to wait (converted using #to_int, and truncated to a signed 32-bit integer)

Returns:IRubyObject

the object given

Annotations
@JRubyMethod
module:true
Exceptions
InterruptedException:
if interrupted
org.jruby.ext.jruby back to summary

public Class JRubyUtilLibrary.StringUtils

extends Object
Class Inheritance
Annotations
@Deprecated

Deprecated

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static IRubyObject
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

StringUtilsback to summary
public StringUtils()

Method Detail

unseeded_hashback to summary
public static IRubyObject unseeded_hash(ThreadContext context, IRubyObject recv)