Top Description Constructors Methods
org.jruby.runtime

public abstract Class MethodFactory

extends Object
Class Inheritance
Known Direct Subclasses
org.jruby.internal.runtime.methods.InvocationMethodFactory
Imports
org.jruby.RubyModule, org.jruby.anno.JavaMethodDescriptor, org.jruby.internal.runtime.methods.DynamicMethod, .InvocationMethodFactory, .InvokeDynamicMethodFactory, org.jruby.util.cli.Options, org.jruby.util.log.Logger, .LoggerFactory, java.util.List

MethodFactory is used to generate "invokers" or "method handles" given a target class, method name, and other characteristics. In order to bind methods into Ruby's reified class hierarchy, we need a way to treat individual methods as objects. Implementers of this class provide that functionality.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static MethodFactory

Returns:

A new MethodFactory.
createFactory
(ClassLoader
The classloader to use for searching for and dynamically loading code.
classLoader
)

Based on optional properties, create a new MethodFactory.

public abstract DynamicMethod

Returns:

A method handle for the target object.
getAnnotatedMethod
(RubyModule
The target class or module on which the method will be bound.
implementationClass
,
List<JavaMethodDescriptor> desc, String name)

Based on a list of annotated Java methods, generate a method handle using the annotation and the target signatures.

public abstract DynamicMethod

Returns:

A method handle for the target object.
getAnnotatedMethod
(RubyModule
The target class or module on which the method will be bound.
implementationClass
,
JavaMethodDescriptor
A JavaMethodDescriptor describing the target method
desc
,
String name)

Based on an annotated Java method object, generate a method handle using the annotation and the target signature.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MethodFactoryback to summary
public MethodFactory()

Method Detail

createFactoryback to summary
public static MethodFactory createFactory(ClassLoader classLoader)

Based on optional properties, create a new MethodFactory. By default, this will create a code-generation-based InvocationMethodFactory. If security restricts code generation, ReflectionMethodFactory will be used. If we are dumping class definitions, DumpingInvocationMethodFactory will be used. See MethodFactory's static initializer for more details.

Parameters
classLoader:ClassLoader

The classloader to use for searching for and dynamically loading code.

Returns:MethodFactory

A new MethodFactory.

getAnnotatedMethodback to summary
public abstract DynamicMethod getAnnotatedMethod(RubyModule implementationClass, List<JavaMethodDescriptor> desc, String name)

Based on a list of annotated Java methods, generate a method handle using the annotation and the target signatures. The annotation and signatures will be used to dynamically generate the appropriate call logic for the handle. This differs from the single-method version in that it will dispatch multiple specific-arity paths to different target methods.

Parameters
implementationClass:RubyModule

The target class or module on which the method will be bound.

Returns:DynamicMethod

A method handle for the target object.

getAnnotatedMethodback to summary
public abstract DynamicMethod getAnnotatedMethod(RubyModule implementationClass, JavaMethodDescriptor desc, String name)

Based on an annotated Java method object, generate a method handle using the annotation and the target signature. The annotation and signature will be used to dynamically generate the appropriate call logic for the handle.

Parameters
implementationClass:RubyModule

The target class or module on which the method will be bound.

desc:JavaMethodDescriptor

A JavaMethodDescriptor describing the target method

Returns:DynamicMethod

A method handle for the target object.