Package org.jruby.ext.jruby
Class JRubyUtilLibrary
java.lang.Object
org.jruby.ext.jruby.JRubyUtilLibrary
- All Implemented Interfaces:
Library
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 Class Summary
Nested Classes -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IRubyObjectcache_stats(ThreadContext context, IRubyObject self) Provide stats on how many method and constant invalidations have occurred globally.static IRubyObjectclass_loader_resources(ThreadContext context, IRubyObject recv, IRubyObject... args) static IRubyObjectclasspath_launcher(ThreadContext context, IRubyObject recv) static IRubyObjectcurrent_directory(ThreadContext context, IRubyObject recv) static IRubyObjectextra_gem_paths(ThreadContext context, IRubyObject recv) static IRubyObjectgc(ThreadContext context, IRubyObject recv) static IRubyObjectgetClassLoaderResources(IRubyObject recv, IRubyObject name) Deprecated.static IRubyObjectprivate static ObjectgetSyncObject(IRubyObject arg) static RubyArrayinternal_libraries(ThreadContext context, IRubyObject self) Deprecated.voidstatic IRubyObjectload_ext(ThreadContext context, IRubyObject recv, IRubyObject klass) Preffered way to boot-up JRuby extensions (available as>JRuby.load_ext).static IRubyObjectload_java_class(ThreadContext context, IRubyObject recv, IRubyObject name) Loads a (Java) class.private static booleanloadExtension(Ruby runtime, String className) static IRubyObjectnative_posix_p(ThreadContext context, IRubyObject self) static IRubyObjectnotify(ThreadContext context, IRubyObject recv, IRubyObject arg) Notify one waiter on a locked object, as in ObjectObject.notify()The object given must be locked using JRuby.synchronized or a similar Java monitor-based locking mechanism.static IRubyObjectnotifyAll(ThreadContext context, IRubyObject recv, IRubyObject arg) Notify all waiters on a locked object, as in ObjectObject.notifyAll()The object given must be locked using JRuby.synchronized or a similar Java monitor-based locking mechanism.static IRubyObjectrbSynchronized(ThreadContext context, IRubyObject recv, IRubyObject arg, Block block) Invoke the given block under synchronized lock, using standard Java synchronization.static IRubyObjectset_last_exit_status(ThreadContext context, IRubyObject recv, IRubyObject status, IRubyObject pid) static IRubyObjectset_meta_class(ThreadContext context, IRubyObject recv, IRubyObject obj, IRubyObject klass) static IRubyObjectsetObjectSpaceEnabled(IRubyObject recv, IRubyObject arg) static IRubyObjectwait(ThreadContext context, IRubyObject recv, IRubyObject arg) Wait for a locked object to notify, as in ObjectObject.wait().static IRubyObjectwait(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject timeoutMillis) Wait for a locked object to notify, as in ObjectObject.wait(long).static IRubyObjectwait(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject timeoutMillis, IRubyObject timeoutNanos) Wait for a locked object to notify, as in ObjectObject.wait(long, int).
-
Constructor Details
-
JRubyUtilLibrary
public JRubyUtilLibrary()
-
-
Method Details
-
load
-
gc
-
getObjectSpaceEnabled
-
setObjectSpaceEnabled
-
native_posix_p
-
getClassLoaderResources
Deprecated. -
load_java_class
public static IRubyObject load_java_class(ThreadContext context, IRubyObject recv, IRubyObject name) Loads a (Java) class.- Parameters:
context-recv-name- the class name- Returns:
- Java class (wrapper) or raises a NameError if loading fails or class is not found
-
class_loader_resources
public static IRubyObject class_loader_resources(ThreadContext context, IRubyObject recv, IRubyObject... args) - Parameters:
context-recv-args- (name, raw: false, path: false)- Returns:
- an enumerable of class-loader resources
-
classpath_launcher
-
extra_gem_paths
-
current_directory
-
set_last_exit_status
public static IRubyObject set_last_exit_status(ThreadContext context, IRubyObject recv, IRubyObject status, IRubyObject pid) -
set_meta_class
public static IRubyObject set_meta_class(ThreadContext context, IRubyObject recv, IRubyObject obj, IRubyObject klass) -
load_ext
Preffered way to boot-up JRuby extensions (available as>JRuby.load_ext).- Parameters:
context-recv-klass-- Returns:
- loading outcome
-
loadExtension
-
rbSynchronized
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- the current contextrecv- the JRuby modulearg- the object against which to synchronizeblock- the block to execute- Returns:
- the return value of the block
-
wait
public static IRubyObject wait(ThreadContext context, IRubyObject recv, IRubyObject arg) throws InterruptedException Wait for a locked object to notify, as in ObjectObject.wait().- Parameters:
context- the current contextrecv- the JRuby modulearg- the object to wait for- Returns:
- the object given
- Throws:
InterruptedException- if interrupted
-
wait
public static IRubyObject wait(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject timeoutMillis) throws InterruptedException Wait for a locked object to notify, as in ObjectObject.wait(long). The object given must be locked using JRuby.synchronized or a similar Java monitor-based locking mechanism.- Parameters:
context- the current contextrecv- the JRuby modulearg- the object to wait fortimeoutMillis- the time in millis to wait (converted using #to_int)- Returns:
- the object given
- Throws:
InterruptedException- if interrupted
-
wait
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 ObjectObject.wait(long, int). The object given must be locked using JRuby.synchronized or a similar Java monitor-based locking mechanism.- Parameters:
context- the current contextrecv- the JRuby modulearg- the object to wait fortimeoutMillis- the time in millis to wait (converted using #to_int)timeoutNanos- the time in nanos to wait (converted using #to_int, and truncated to a signed 32-bit integer)- Returns:
- the object given
- Throws:
InterruptedException- if interrupted
-
notify
Notify one waiter on a locked object, as in ObjectObject.notify()The object given must be locked using JRuby.synchronized or a similar Java monitor-based locking mechanism.- Parameters:
context- the current contextrecv- the JRuby modulearg- the object to notify- Returns:
- the object given
-
notifyAll
Notify all waiters on a locked object, as in ObjectObject.notifyAll()The object given must be locked using JRuby.synchronized or a similar Java monitor-based locking mechanism.- Parameters:
context- the current contextrecv- the JRuby modulearg- the object to notify- Returns:
- the object given
-
getSyncObject
-
cache_stats
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 -
internal_libraries
Deprecated.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 in https://github.com/Shopify/bootsnap/issues/162
-