Package org.jruby.javasupport
Class Java
java.lang.Object
org.jruby.javasupport.Java
- All Implemented Interfaces:
Library
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classUsed for concrete reified classes.static classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IRubyObjectallocateProxy(Object javaObject, RubyClass clazz) static JavaObjectcastToJavaObject(ThreadContext context, IRubyObject newValue) static IRubyObjectconcrete_proxy_inherited(IRubyObject clazz, IRubyObject subclazz) Deprecated.static IRubyObjectconst_missing(ThreadContext context, IRubyObject self, IRubyObject name) static IRubyObjectconstructProxy(Ruby runtime, Constructor<? extends IRubyObject> proxyConstructor, RubyClass clazz) static IRubyObjectcreate_proxy_class(IRubyObject self, IRubyObject name, IRubyObject javaClass, IRubyObject mod) Deprecated.static RubyModulecreateJavaModule(ThreadContext context) static ClassgenerateRealClass(RubyClass clazz) static IRubyObjectget_inner_class(ThreadContext context, RubyModule self, IRubyObject name) static RubyModuleget_interface_module(Ruby runtime, IRubyObject java_class) Deprecated.static RubyModuleget_interface_module(ThreadContext context, IRubyObject java_class) static RubyModuleget_package_module(IRubyObject self, IRubyObject name) Deprecated.static RubyModuleget_package_module(ThreadContext context, IRubyObject self, IRubyObject name) static IRubyObjectget_package_module_dot_format(ThreadContext context, IRubyObject self, IRubyObject dottedName) static RubyModuleget_proxy_class(IRubyObject self, IRubyObject java_class) Deprecated.static RubyModuleget_proxy_class(ThreadContext context, IRubyObject self, IRubyObject java_class) static IRubyObjectget_proxy_or_package_under_package(ThreadContext context, IRubyObject self, IRubyObject parentPackage, IRubyObject name) static IRubyObjectget_top_level_proxy_or_package(ThreadContext context, IRubyObject self, IRubyObject name) static MethodgetFunctionalInterfaceMethod(Class<?> iface) static IRubyObjectgetInstance(Ruby runtime, Object rawJavaObject) Same as Java#getInstance(runtime, rawJavaObject, false).static IRubyObjectgetInstance(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 RubyModulegetInterfaceModule(Ruby runtime, Class javaClass) Deprecated.static RubyModulegetInterfaceModule(Ruby runtime, JavaClass javaClass) Deprecated.static RubyModulegetInterfaceModule(ThreadContext context, Class javaClass) static Class[]static ClassgetJavaClass(Ruby runtime, String className) Deprecated.static ClassgetJavaClass(Ruby runtime, String className, boolean initialize) Deprecated.static ClassgetJavaClass(ThreadContext context, String className) static ClassgetJavaClass(ThreadContext context, String className, boolean initialize) static RubyModulegetJavaPackageModule(Ruby runtime, Package pkg) static RubyModulegetJavaPackageModule(Ruby runtime, String packageString) Deprecated.static RubyModulegetJavaPackageModule(ThreadContext context, String packageString) static RubyModulegetProxyClass(Ruby runtime, Class<?> clazz) Deprecated.static RubyModulegetProxyClass(Ruby runtime, JavaClass javaClass) Deprecated.static RubyModulegetProxyClass(ThreadContext context, Class<?> clazz) static RubyClassgetProxyClassForObject(Ruby runtime, Object object) Deprecated.static RubyClassgetProxyClassForObject(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 booleanisProxyType(RubyModule proxy) static IRubyObjectjava_to_primitive(IRubyObject recv, IRubyObject object, Block unusedBlock) Deprecated.static IRubyObjectjava_to_ruby(IRubyObject recv, IRubyObject object, Block unusedBlock) Deprecated.voidstatic ClassloadJavaClass(Ruby runtime, String className) Deprecated.static ClassloadJavaClass(ThreadContext context, String className) static IRubyObjectmethod_missing(ThreadContext context, IRubyObject self, IRubyObject name) static IRubyObjectmethod_missing(ThreadContext context, IRubyObject self, IRubyObject[] args) static IRubyObjectnew_proxy_instance2(IRubyObject recv, IRubyObject wrapper, IRubyObject interfaces, Block block) Deprecated.static IRubyObjectnew_proxy_instance2(ThreadContext context, IRubyObject recv, IRubyObject wrapper, IRubyObject interfaces, Block block) static ObjectnewInterfaceImpl(IRubyObject wrapper, Class[] interfaces) Deprecated.static ObjectnewInterfaceImpl(ThreadContext context, IRubyObject wrapper, Class[] interfaces) static Class<?> resolveClassType(ThreadContext context, IRubyObject type) static RubyModuleresolveType(Ruby runtime, IRubyObject type) Deprecated.static RubyModuleresolveType(ThreadContext context, IRubyObject type) static IRubyObjectruby_to_java(IRubyObject recv, IRubyObject object, Block unusedBlock) Deprecated.static RubyModulesetProxyClass(Ruby runtime, RubyModule target, String constName, Class<?> javaClass) Deprecated.static RubyModulesetProxyClass(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 IRubyObjectwrap(Ruby runtime, IRubyObject java_object) Deprecated.static IRubyObjectwrapJavaObject(Ruby runtime, Object object) Deprecated.static IRubyObjectwrapJavaObject(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:
ClassNotFoundExceptionRaiseException
-
loadJavaClass
public static Class loadJavaClass(ThreadContext context, String className) throws ClassNotFoundException, RaiseException - Throws:
ClassNotFoundExceptionRaiseException
-
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
-