Package org.jruby.javasupport
Class Java
java.lang.Object
org.jruby.javasupport.Java
- All Implemented Interfaces:
Library
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classprivate static final classprivate static final classprivate static classstatic classstatic classUsed for concrete reified classes.static classstatic class(package private) static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Patternstatic final booleanstatic final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddToJavaPackageModule(RubyModule proxyClass) static IRubyObjectallocateProxy(Object javaObject, RubyClass clazz) private static booleanallowUppercasePackageNames(Ruby runtime) private static booleanbindJavaPackageOrClassMethod(RubyModule parentPackage, String name, RubyModule packageOrClass) private static booleanbindJavaPackageOrClassMethod(Ruby runtime, String name, RubyModule packageOrClass) private static RubyModulecacheConstant(RubyModule owner, String constName, RubyModule packageOrClass, boolean hidden) private static <T extends ParameterTypes>
TcheckCallableForArity(int arity, T[] callables, int index) private static voidcheckJavaReservedNames(Ruby runtime, String name, boolean allowPrimitives) 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 module) Deprecated.static RubyModulecreateJavaModule(Ruby runtime) private static RubyModulecreatePackageModule(Ruby runtime, RubyModule parentModule, String name, String packageString) private static RubyClasscreateProxyClass(Ruby runtime, RubyClass proxyClass, Class<?> javaClass, RubyClass superClass, boolean invokeInherited) (package private) static RubyModulecreateProxyClassForClass(Ruby runtime, Class<?> clazz) (package private) static <T extends ParameterTypes>
ArrayList<T>findCallablesForArity(int arity, T[] callables) private static voidgenerateClassProxy(Ruby runtime, Class<?> clazz, RubyClass proxy, RubyClass superClass) private static voidgenerateInterfaceProxy(Ruby runtime, Class javaClass, RubyModule proxy) static ClassgenerateRealClass(RubyClass clazz) static IRubyObjectget_inner_class(ThreadContext context, RubyModule self, IRubyObject name) static RubyModuleget_interface_module(Ruby runtime, IRubyObject java_class) static IRubyObjectget_java_class(IRubyObject self, IRubyObject name) Deprecated.static RubyModuleget_package_module(IRubyObject self, IRubyObject name) static IRubyObjectget_package_module_dot_format(IRubyObject self, IRubyObject dottedName) static RubyModuleget_proxy_class(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) static RubyModulegetInterfaceModule(Ruby runtime, JavaClass javaClass) Deprecated.static Class[]static ClassgetJavaClass(Ruby runtime, String className) static ClassgetJavaClass(Ruby runtime, String className, boolean initialize) static RubyModulegetJavaPackageModule(Ruby runtime, Package pkg) static RubyModulegetJavaPackageModule(Ruby runtime, String packageString) private static Stringprivate static RubyModulegetPackageModule(Ruby runtime, String name) static RubyModulegetProxyClass(Ruby runtime, Class<?> clazz) static RubyModulegetProxyClass(Ruby runtime, JavaClass javaClass) static RubyClassgetProxyClassForObject(Ruby runtime, Object object) private static RubyModulegetProxyClassOrNull(Ruby runtime, String className) (package private) static RubyModulegetProxyOrPackageUnderPackage(ThreadContext context, RubyModule parentPackage, String name, boolean cacheMethod) private static RubyModulegetProxyUnderClass(ThreadContext context, RubyModule enclosingClass, String name) static Constructor<? extends IRubyObject>getRealClassConstructor(Ruby runtime, Class<? extends IRubyObject> proxyImplClass) private static RubyModulegetTopLevelProxyOrPackage(Ruby runtime, String name, boolean cacheMethod) (package private) static RaiseExceptioninitCause(RaiseException ex, Throwable cause) private static intinterfacesHashCode(Class[] a) private static IRubyObjectinvokeProxyClassInherited(ThreadContext context, IRubyObject clazz, IRubyObject subclazz) static <T extends AccessibleObject & Member>
booleanisAccessible(T member) Check if the given member would be accessible without using the deprecated AccessibleObject.isAccessible.private static booleanisPrimitiveClassName(String name) 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) (package private) static ClassloadJavaClass(Ruby runtime, String className, boolean initialize) private static RaiseExceptionmapGeneratedProxyException(Ruby runtime, InvocationTargetException e) private static RaiseExceptionprivate static intmapMajorMinorClassVersionToJavaVersion(String msg, int offset) 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 ifcs, Block block) static JavaObjectnewInterfaceImpl(IRubyObject wrapper, Class[] interfaces) private static ObjectnewProxyInterfaceImpl(IRubyObject wrapper, Class[] interfaces, ClassLoader loader) (package private) static Class<?>resolveClassType(Ruby runtime, IRubyObject type) static Class<?>resolveClassType(ThreadContext context, IRubyObject type) private static Class<?>resolveJavaClassArgument(Ruby runtime, IRubyObject java_class) private static ClassresolveShortClassName(String name) static RubyModuleresolveType(Ruby runtime, IRubyObject type) static IRubyObjectruby_to_java(IRubyObject recv, IRubyObject object, Block unusedBlock) Deprecated.static RubyModulesetProxyClass(Ruby runtime, RubyModule target, String constName, Class<?> javaClass) private static voidsetupJavaSubclass(ThreadContext context, RubyClass subclass) 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) static IRubyObjectwrapJavaObject(Ruby runtime, Object object)
-
Field Details
-
NEW_STYLE_EXTENSION
public static final boolean NEW_STYLE_EXTENSION -
OBJECT_PROXY_CACHE
public static final boolean OBJECT_PROXY_CACHE -
CAMEL_CASE_PACKAGE_SPLITTER
-
-
Constructor Details
-
Java
public Java()
-
-
Method Details
-
load
-
createJavaModule
-
create_proxy_class
@Deprecated public static IRubyObject create_proxy_class(IRubyObject self, IRubyObject name, IRubyObject javaClass, IRubyObject module) Deprecated. -
setProxyClass
public static RubyModule setProxyClass(Ruby runtime, RubyModule target, String constName, Class<?> javaClass) -
get_java_class
Deprecated. -
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. -
getInterfaceModule
-
get_interface_module
-
get_proxy_class
-
resolveJavaClassArgument
-
unwrapClassProxy
-
getProxyClassForObject
-
resolveClassType
-
resolveType
-
resolveClassType
-
resolveShortClassName
-
getProxyClass
-
getProxyClass
-
createProxyClassForClass
-
generateInterfaceProxy
-
generateClassProxy
-
createProxyClass
-
concrete_proxy_inherited
@Deprecated public static IRubyObject concrete_proxy_inherited(IRubyObject clazz, IRubyObject subclazz) Deprecated. -
invokeProxyClassInherited
private static IRubyObject invokeProxyClassInherited(ThreadContext context, IRubyObject clazz, IRubyObject subclazz) -
setupJavaSubclass
-
findCallablesForArity
-
checkCallableForArity
private static <T extends ParameterTypes> T checkCallableForArity(int arity, T[] callables, int index) -
addToJavaPackageModule
-
getJavaPackageModule
-
getJavaPackageModule
-
createPackageModule
private static RubyModule createPackageModule(Ruby runtime, RubyModule parentModule, String name, String packageString) -
getPackageModule
-
get_package_module
-
get_package_module_dot_format
-
getProxyOrPackageUnderPackage
static RubyModule getProxyOrPackageUnderPackage(ThreadContext context, RubyModule parentPackage, String name, boolean cacheMethod) -
allowUppercasePackageNames
-
checkJavaReservedNames
-
isPrimitiveClassName
-
getJavaClass
- Throws:
RaiseException
-
getJavaClass
public static Class getJavaClass(Ruby runtime, String className, boolean initialize) throws RaiseException - Throws:
RaiseException
-
loadJavaClass
public static Class loadJavaClass(Ruby runtime, String className) throws ClassNotFoundException, RaiseException - Throws:
ClassNotFoundExceptionRaiseException
-
loadJavaClass
static Class loadJavaClass(Ruby runtime, String className, boolean initialize) throws ClassNotFoundException, RaiseException - Throws:
ClassNotFoundExceptionRaiseException
-
getJavaVersionErrorMessage
-
initCause
-
getProxyClassOrNull
-
mapMajorMinorClassVersionToJavaVersion
-
get_proxy_or_package_under_package
public static IRubyObject get_proxy_or_package_under_package(ThreadContext context, IRubyObject self, IRubyObject parentPackage, IRubyObject name) -
getTopLevelProxyOrPackage
-
bindJavaPackageOrClassMethod
private static boolean bindJavaPackageOrClassMethod(Ruby runtime, String name, RubyModule packageOrClass) -
bindJavaPackageOrClassMethod
private static boolean bindJavaPackageOrClassMethod(RubyModule parentPackage, String name, RubyModule packageOrClass) -
getProxyUnderClass
private static RubyModule getProxyUnderClass(ThreadContext context, RubyModule enclosingClass, String name) -
get_inner_class
-
const_missing
-
cacheConstant
private static RubyModule cacheConstant(RubyModule owner, String constName, RubyModule packageOrClass, boolean hidden) -
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
-
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
public static IRubyObject new_proxy_instance2(IRubyObject recv, IRubyObject wrapper, IRubyObject ifcs, Block block) -
newInterfaceImpl
-
newProxyInterfaceImpl
private static Object newProxyInterfaceImpl(IRubyObject wrapper, Class[] interfaces, ClassLoader loader) -
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) -
mapGeneratedProxyException
private static RaiseException mapGeneratedProxyException(Ruby runtime, ReflectiveOperationException e) -
mapGeneratedProxyException
-
allocateProxy
-
wrapJavaObject
-
getInterfacesFromRubyClass
-
interfacesHashCode
-
getFunctionalInterfaceMethod
- Parameters:
iface-- Returns:
- the sole un-implemented method for a functional-style interface or null
-
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.
-