Package org.jruby.javasupport
Class Java
java.lang.Object
org.jruby.javasupport.Java
- All Implemented Interfaces:
Library
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static class
Used for concrete reified classes.static class
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
static final boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IRubyObject
allocateProxy
(Object javaObject, RubyClass clazz) static JavaObject
castToJavaObject
(ThreadContext context, IRubyObject newValue) static IRubyObject
concrete_proxy_inherited
(IRubyObject clazz, IRubyObject subclazz) Deprecated.static IRubyObject
const_missing
(ThreadContext context, IRubyObject self, IRubyObject name) static IRubyObject
constructProxy
(Ruby runtime, Constructor<? extends IRubyObject> proxyConstructor, RubyClass clazz) static IRubyObject
create_proxy_class
(IRubyObject self, IRubyObject name, IRubyObject javaClass, IRubyObject mod) Deprecated.static RubyModule
createJavaModule
(ThreadContext context) static Class
generateRealClass
(RubyClass clazz) static IRubyObject
get_inner_class
(ThreadContext context, RubyModule self, IRubyObject name) static RubyModule
get_interface_module
(Ruby runtime, IRubyObject java_class) Deprecated.static RubyModule
get_interface_module
(ThreadContext context, IRubyObject java_class) static RubyModule
get_package_module
(IRubyObject self, IRubyObject name) Deprecated.static RubyModule
get_package_module
(ThreadContext context, IRubyObject self, IRubyObject name) static IRubyObject
get_package_module_dot_format
(ThreadContext context, IRubyObject self, IRubyObject dottedName) static RubyModule
get_proxy_class
(IRubyObject self, IRubyObject java_class) Deprecated.static RubyModule
get_proxy_class
(ThreadContext context, IRubyObject self, IRubyObject java_class) static IRubyObject
get_proxy_or_package_under_package
(ThreadContext context, IRubyObject self, IRubyObject parentPackage, IRubyObject name) static IRubyObject
get_top_level_proxy_or_package
(ThreadContext context, IRubyObject self, IRubyObject name) static Method
getFunctionalInterfaceMethod
(Class<?> iface) static IRubyObject
getInstance
(Ruby runtime, Object rawJavaObject) Same as Java#getInstance(runtime, rawJavaObject, false).static IRubyObject
getInstance
(Ruby runtime, Object rawJavaObject, boolean forceCache) Returns a new proxy instance of a type corresponding to rawJavaObject's class, or the cached proxy if we've already seen this object.static RubyModule
getInterfaceModule
(Ruby runtime, Class javaClass) Deprecated.static RubyModule
getInterfaceModule
(Ruby runtime, JavaClass javaClass) Deprecated.static RubyModule
getInterfaceModule
(ThreadContext context, Class javaClass) static Class[]
static Class
getJavaClass
(Ruby runtime, String className) Deprecated.static Class
getJavaClass
(Ruby runtime, String className, boolean initialize) Deprecated.static Class
getJavaClass
(ThreadContext context, String className) static Class
getJavaClass
(ThreadContext context, String className, boolean initialize) static RubyModule
getJavaPackageModule
(Ruby runtime, Package pkg) static RubyModule
getJavaPackageModule
(Ruby runtime, String packageString) Deprecated.static RubyModule
getJavaPackageModule
(ThreadContext context, String packageString) static RubyModule
getProxyClass
(Ruby runtime, Class<?> clazz) Deprecated.static RubyModule
getProxyClass
(Ruby runtime, JavaClass javaClass) Deprecated.static RubyModule
getProxyClass
(ThreadContext context, Class<?> clazz) static RubyClass
getProxyClassForObject
(Ruby runtime, Object object) Deprecated.static RubyClass
getProxyClassForObject
(ThreadContext context, Object object) static Constructor
<? extends IRubyObject> getRealClassConstructor
(Ruby runtime, Class<? extends IRubyObject> proxyImplClass) static <T extends AccessibleObject & Member>
booleanisAccessible
(T member) Check if the given member would be accessible without using the deprecated AccessibleObject.isAccessible.static boolean
isProxyType
(RubyModule proxy) static IRubyObject
java_to_primitive
(IRubyObject recv, IRubyObject object, Block unusedBlock) Deprecated.static IRubyObject
java_to_ruby
(IRubyObject recv, IRubyObject object, Block unusedBlock) Deprecated.void
static Class
loadJavaClass
(Ruby runtime, String className) Deprecated.static Class
loadJavaClass
(ThreadContext context, String className) static IRubyObject
method_missing
(ThreadContext context, IRubyObject self, IRubyObject name) static IRubyObject
method_missing
(ThreadContext context, IRubyObject self, IRubyObject[] args) static IRubyObject
new_proxy_instance2
(IRubyObject recv, IRubyObject wrapper, IRubyObject interfaces, Block block) Deprecated.static IRubyObject
new_proxy_instance2
(ThreadContext context, IRubyObject recv, IRubyObject wrapper, IRubyObject interfaces, Block block) static Object
newInterfaceImpl
(IRubyObject wrapper, Class[] interfaces) Deprecated.static Object
newInterfaceImpl
(ThreadContext context, IRubyObject wrapper, Class[] interfaces) static Class
<?> resolveClassType
(ThreadContext context, IRubyObject type) static RubyModule
resolveType
(Ruby runtime, IRubyObject type) Deprecated.static RubyModule
resolveType
(ThreadContext context, IRubyObject type) static IRubyObject
ruby_to_java
(IRubyObject recv, IRubyObject object, Block unusedBlock) Deprecated.static RubyModule
setProxyClass
(Ruby runtime, RubyModule target, String constName, Class<?> javaClass) Deprecated.static RubyModule
setProxyClass
(ThreadContext context, RubyModule target, String constName, Class<?> javaClass) static <T extends AccessibleObject & Member>
booleantrySetAccessible
(T member) Try to set the given member to be accessible, considering open modules and avoiding the actual setAccessible call when it would produce a JPMS warning.static Class
<?> unwrapClassProxy
(IRubyObject self) static IRubyObject
wrap
(Ruby runtime, IRubyObject java_object) Deprecated.static IRubyObject
wrapJavaObject
(Ruby runtime, Object object) Deprecated.static IRubyObject
wrapJavaObject
(ThreadContext context, Object object)
-
Field Details
-
NEW_STYLE_EXTENSION
public static final boolean NEW_STYLE_EXTENSION -
OBJECT_PROXY_CACHE
public static final boolean OBJECT_PROXY_CACHE
-
-
Constructor Details
-
Java
public Java()
-
-
Method Details
-
load
-
createJavaModule
-
create_proxy_class
@Deprecated(since="9.4") public static IRubyObject create_proxy_class(IRubyObject self, IRubyObject name, IRubyObject javaClass, IRubyObject mod) Deprecated. -
setProxyClass
@Deprecated(since="10.0") public static RubyModule setProxyClass(Ruby runtime, RubyModule target, String constName, Class<?> javaClass) throws NameError Deprecated.- Throws:
NameError
-
setProxyClass
public static RubyModule setProxyClass(ThreadContext context, RubyModule target, String constName, Class<?> javaClass) throws NameError - Throws:
NameError
-
getInstance
Same as Java#getInstance(runtime, rawJavaObject, false). -
getInstance
Returns a new proxy instance of a type corresponding to rawJavaObject's class, or the cached proxy if we've already seen this object. Note that primitives and strings are not coerced to corresponding Ruby types; use JavaUtil.convertJavaToUsableRubyObject to get coerced types or proxies as appropriate.- Parameters:
runtime
- the JRuby runtimerawJavaObject
- the object to get a wrapper forforceCache
- whether to force the use of the proxy cache- Returns:
- the new (or cached) proxy for the specified Java object
- See Also:
-
getInterfaceModule
@Deprecated(since="9.4-") public static RubyModule getInterfaceModule(Ruby runtime, JavaClass javaClass) Deprecated. -
getInterfaceModule
@Deprecated(since="10.0") public static RubyModule getInterfaceModule(Ruby runtime, Class javaClass) Deprecated. -
getInterfaceModule
-
get_interface_module
@Deprecated(since="10.0") public static RubyModule get_interface_module(Ruby runtime, IRubyObject java_class) Deprecated. -
get_interface_module
-
get_proxy_class
@Deprecated(since="10.0") public static RubyModule get_proxy_class(IRubyObject self, IRubyObject java_class) Deprecated. -
get_proxy_class
public static RubyModule get_proxy_class(ThreadContext context, IRubyObject self, IRubyObject java_class) -
unwrapClassProxy
-
getProxyClassForObject
@Deprecated(since="10.0") public static RubyClass getProxyClassForObject(Ruby runtime, Object object) Deprecated. -
getProxyClassForObject
-
resolveClassType
- Throws:
TypeError
-
resolveType
Deprecated. -
resolveType
-
getProxyClass
Deprecated. -
getProxyClass
Deprecated. -
getProxyClass
-
isProxyType
-
concrete_proxy_inherited
@Deprecated public static IRubyObject concrete_proxy_inherited(IRubyObject clazz, IRubyObject subclazz) Deprecated. -
getJavaPackageModule
-
getJavaPackageModule
@Deprecated(since="10.0") public static RubyModule getJavaPackageModule(Ruby runtime, String packageString) Deprecated. -
getJavaPackageModule
-
get_package_module
@Deprecated(since="10.0") public static RubyModule get_package_module(IRubyObject self, IRubyObject name) Deprecated. -
get_package_module
public static RubyModule get_package_module(ThreadContext context, IRubyObject self, IRubyObject name) -
get_package_module_dot_format
public static IRubyObject get_package_module_dot_format(ThreadContext context, IRubyObject self, IRubyObject dottedName) -
getJavaClass
@Deprecated(since="10.0") public static Class getJavaClass(Ruby runtime, String className) throws RaiseException Deprecated.- Throws:
RaiseException
-
getJavaClass
- Throws:
RaiseException
-
getJavaClass
@Deprecated(since="10.0") public static Class getJavaClass(Ruby runtime, String className, boolean initialize) throws RaiseException Deprecated.- Throws:
RaiseException
-
getJavaClass
public static Class getJavaClass(ThreadContext context, String className, boolean initialize) throws RaiseException - Throws:
RaiseException
-
loadJavaClass
@Deprecated(since="10.0") public static Class loadJavaClass(Ruby runtime, String className) throws ClassNotFoundException, RaiseException Deprecated.- Throws:
ClassNotFoundException
RaiseException
-
loadJavaClass
public static Class loadJavaClass(ThreadContext context, String className) throws ClassNotFoundException, RaiseException - Throws:
ClassNotFoundException
RaiseException
-
get_proxy_or_package_under_package
public static IRubyObject get_proxy_or_package_under_package(ThreadContext context, IRubyObject self, IRubyObject parentPackage, IRubyObject name) -
get_inner_class
-
const_missing
-
method_missing
-
method_missing
public static IRubyObject method_missing(ThreadContext context, IRubyObject self, IRubyObject[] args) -
get_top_level_proxy_or_package
public static IRubyObject get_top_level_proxy_or_package(ThreadContext context, IRubyObject self, IRubyObject name) -
wrap
Deprecated. -
java_to_ruby
@Deprecated public static IRubyObject java_to_ruby(IRubyObject recv, IRubyObject object, Block unusedBlock) Deprecated.High-level object conversion utility function 'java_to_primitive' is the low-level version -
ruby_to_java
@Deprecated public static IRubyObject ruby_to_java(IRubyObject recv, IRubyObject object, Block unusedBlock) Deprecated.High-level object conversion utility. -
java_to_primitive
@Deprecated public static IRubyObject java_to_primitive(IRubyObject recv, IRubyObject object, Block unusedBlock) Deprecated. -
new_proxy_instance2
@Deprecated(since="10.0") public static IRubyObject new_proxy_instance2(IRubyObject recv, IRubyObject wrapper, IRubyObject interfaces, Block block) Deprecated. -
new_proxy_instance2
public static IRubyObject new_proxy_instance2(ThreadContext context, IRubyObject recv, IRubyObject wrapper, IRubyObject interfaces, Block block) -
newInterfaceImpl
@Deprecated(since="10.0") public static Object newInterfaceImpl(IRubyObject wrapper, Class[] interfaces) Deprecated. -
newInterfaceImpl
public static Object newInterfaceImpl(ThreadContext context, IRubyObject wrapper, Class[] interfaces) -
generateRealClass
-
getRealClassConstructor
public static Constructor<? extends IRubyObject> getRealClassConstructor(Ruby runtime, Class<? extends IRubyObject> proxyImplClass) -
constructProxy
public static IRubyObject constructProxy(Ruby runtime, Constructor<? extends IRubyObject> proxyConstructor, RubyClass clazz) -
allocateProxy
-
wrapJavaObject
Deprecated. -
wrapJavaObject
-
getInterfacesFromRubyClass
-
getFunctionalInterfaceMethod
- Parameters:
iface
-- Returns:
- the sole un-implemented method for a functional-style interface or null
Note: This method is internal and might be subject to change, do not assume its part of JRuby's API!
-
trySetAccessible
Try to set the given member to be accessible, considering open modules and avoiding the actual setAccessible call when it would produce a JPMS warning. All classes on Java 8 are considered open, allowing setAccessible to proceed. The open check is based on this class, Java.java, which will be in whatever core or dist JRuby module you are using. -
isAccessible
Check if the given member would be accessible without using the deprecated AccessibleObject.isAccessible. This uses backport9 logic to check if the given class is in a package that has been opened up to us, since under JPMS that is the only way we can do invasive accesses. On Java 8, it continues to use isAccessible. The open check is based on this class, Java.java, which will be in whatever core or dist JRuby module you are using. -
castToJavaObject
-