Top Description Fields Constructors Methods
org.jruby.internal.runtime.methods

public Class HandleMethod

extends DynamicMethod
implements MethodArgs2, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, org.jruby.internal.runtime.methods.MethodArgs2
Imports
java.lang.invoke.MethodHandle, .MethodHandles, java.util.function.Supplier, com.headius.invokebinder.SmartBinder, org.jruby.RubyModule, org.jruby.runtime.Arity, .Block, .Helpers, .Signature, .ThreadContext, .Visibility, org.jruby.runtime.builtin.IRubyObject

A DynamicMethod backed by one or more java.lang.invoke.MethodHandle objects. The MethodHandles contained in this method are used by invokedynamic-based call site binding to bind more directly to the target. Previously, the handles required for binding were built at the call site by inspecting the DynamicMethod that came in. With the newer logic, handles are created at bind time, so they're already ready and so we don't need to generate our own handle classes that might only get used by the interpreter.
Author
headius

Field Summary

Modifier and TypeField and Description
private static final Signature[]
private static final Signature
private static final Signature
private static final Signature
private static final Signature
private final boolean
private volatile boolean
private volatile boolean
private volatile boolean
private volatile boolean
private volatile boolean
private Supplier<MethodHandle>
private Supplier<MethodHandle>
private Supplier<MethodHandle>
private Supplier<MethodHandle>
private Supplier<MethodHandle>
private final int
private final int
private final boolean
private final String
private final Signature
private MethodHandle
private MethodHandle
private MethodHandle
private MethodHandle
private MethodHandle
Inherited from org.jruby.internal.runtime.methods.DynamicMethod:
aliasCountdefinedClassflagshandleimplementationClassnameprotectedClassserialNumber

Constructor Summary

AccessConstructor and Description
public
HandleMethod(RubyModule implementationClass, Visibility visibility, String name, long encodedSignature, boolean builtin, boolean notImplemented, String parameterDesc, final int min, final int max, final Supplier<MethodHandle> maker0, final Supplier<MethodHandle> maker1, final Supplier<MethodHandle> maker2, final Supplier<MethodHandle> maker3, final Supplier<MethodHandle> maker4)

Method Summary

Modifier and TypeMethod and Description
private MethodHandle
public IRubyObject
call(ThreadContext
The thread context for the currently executing thread
context
,
IRubyObject
The 'self' or 'receiver' object to use for this call
self
,
RubyModule
The Ruby class against which this method is binding
clazz
,
String
The incoming name used to invoke this method
name
,
IRubyObject[]
The argument list to this invocation
args
,
Block
The block passed to this invocation
block
)

Implements abstract org.jruby.internal.runtime.methods.DynamicMethod.call.

The minimum 'call' method required for a dynamic method handle.

public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public DynamicMethod
dup()

Implements abstract org.jruby.internal.runtime.methods.DynamicMethod.dup.

Duplicate this method, returning DynamicMethod referencing the same code and with the same attributes.

private MethodHandle
private MethodHandle
private MethodHandle
private MethodHandle
private MethodHandle
public Arity
getArity()

Overrides org.jruby.internal.runtime.methods.DynamicMethod.getArity.

Deprecated

Retrieve the arity of this method, used for reporting arity to Ruby code.

public MethodHandle
getHandle(int arity)

public String[]
public Signature
getSignature()

Overrides org.jruby.internal.runtime.methods.DynamicMethod.getSignature.

Retrieve the signature of this method.

public boolean
isBuiltin()

Overrides org.jruby.internal.runtime.methods.DynamicMethod.isBuiltin.

Whether this method is a builtin method, i.e. a method built-in to JRuby and loaded during its core boot process.

public boolean
isNative()

Overrides org.jruby.internal.runtime.methods.DynamicMethod.isNative.

Returns true if this method is backed by native (i.e. Java) code.

public boolean
isNotImplemented()

Overrides org.jruby.internal.runtime.methods.DynamicMethod.isNotImplemented.

Whether this method is "not implemented".

Inherited from org.jruby.internal.runtime.methods.DynamicMethod:
adjustAliasCountcalculateProtectedClasscallcallcallcallcallcallRespondTogetAliasCountgetCallConfiggetDefinedClassgetHandlegetImplementationClassgetInstanceVariableNamesgetMethodDatagetNamegetProtectedClassgetRealMethodgetSerialNumbergetVisibilityinitinitisCallableFromisImplementedByisNullisRefinedisUndefinedsetCallConfigsetDefinedClasssetHandlesetImplementationClasssetIsBuiltinsetNotImplementedsetRuby2KeywordssetVisibility

Field Detail

ARITIESback to summary
private static final Signature[] ARITIES
ARITY_0back to summary
private static final Signature ARITY_0
ARITY_1back to summary
private static final Signature ARITY_1
ARITY_2back to summary
private static final Signature ARITY_2
ARITY_3back to summary
private static final Signature ARITY_3
builtinback to summary
private final boolean builtin
initialized0back to summary
private volatile boolean initialized0
initialized1back to summary
private volatile boolean initialized1
initialized2back to summary
private volatile boolean initialized2
initialized3back to summary
private volatile boolean initialized3
initialized4back to summary
private volatile boolean initialized4
maker0back to summary
private Supplier<MethodHandle> maker0
maker1back to summary
private Supplier<MethodHandle> maker1
maker2back to summary
private Supplier<MethodHandle> maker2
maker3back to summary
private Supplier<MethodHandle> maker3
maker4back to summary
private Supplier<MethodHandle> maker4
maxback to summary
private final int max
minback to summary
private final int min
notImplementedback to summary
private final boolean notImplemented
parameterDescback to summary
private final String parameterDesc
signatureback to summary
private final Signature signature
target0back to summary
private MethodHandle target0
target1back to summary
private MethodHandle target1
target2back to summary
private MethodHandle target2
target3back to summary
private MethodHandle target3
target4back to summary
private MethodHandle target4

Constructor Detail

HandleMethodback to summary
public HandleMethod(RubyModule implementationClass, Visibility visibility, String name, long encodedSignature, boolean builtin, boolean notImplemented, String parameterDesc, final int min, final int max, final Supplier<MethodHandle> maker0, final Supplier<MethodHandle> maker1, final Supplier<MethodHandle> maker2, final Supplier<MethodHandle> maker3, final Supplier<MethodHandle> maker4)

Method Detail

adaptSpecificToVarargsback to summary
private MethodHandle adaptSpecificToVarargs(MethodHandle varargs, int arity)
callback to summary
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block)

Implements abstract org.jruby.internal.runtime.methods.DynamicMethod.call.

Doc from org.jruby.internal.runtime.methods.DynamicMethod.call.

The minimum 'call' method required for a dynamic method handle. Subclasses must implement this method, but may implement the other signatures to provide faster, non-boxing call paths. Typically subclasses will implement this method to check variable arity calls, then performing a specific-arity invocation to the appropriate method or performing variable-arity logic in-line.

Parameters
context:ThreadContext

The thread context for the currently executing thread

self:IRubyObject

The 'self' or 'receiver' object to use for this call

clazz:RubyModule

The Ruby class against which this method is binding

name:String

The incoming name used to invoke this method

args:IRubyObject[]

The argument list to this invocation

block:Block

The block passed to this invocation

Returns:IRubyObject

The result of the call

Annotations
@Override
callback to summary
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block)

Overrides org.jruby.internal.runtime.methods.DynamicMethod.call.

Annotations
@Override
callback to summary
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, Block block)

Overrides org.jruby.internal.runtime.methods.DynamicMethod.call.

Annotations
@Override
callback to summary
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, Block block)

Overrides org.jruby.internal.runtime.methods.DynamicMethod.call.

Annotations
@Override
callback to summary
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block)

Overrides org.jruby.internal.runtime.methods.DynamicMethod.call.

Annotations
@Override
dupback to summary
public DynamicMethod dup()

Implements abstract org.jruby.internal.runtime.methods.DynamicMethod.dup.

Doc from org.jruby.internal.runtime.methods.DynamicMethod.dup.

Duplicate this method, returning DynamicMethod referencing the same code and with the same attributes. It is not required that this method produce a new object if the semantics of the DynamicMethod subtype do not require such.

Returns:DynamicMethod

An identical DynamicMethod object to the target.

Annotations
@Override
ensureTarget0back to summary
private MethodHandle ensureTarget0()
ensureTarget1back to summary
private MethodHandle ensureTarget1()
ensureTarget2back to summary
private MethodHandle ensureTarget2()
ensureTarget3back to summary
private MethodHandle ensureTarget3()
ensureTarget4back to summary
private MethodHandle ensureTarget4()
getArityback to summary
public Arity getArity()

Overrides org.jruby.internal.runtime.methods.DynamicMethod.getArity.

Doc from org.jruby.internal.runtime.methods.DynamicMethod.getArity.

Deprecated

Retrieve the arity of this method, used for reporting arity to Ruby code. This arity may or may not reflect the actual specific or variable arities of the referenced method.

Returns:Arity

The arity of the method, as reported to Ruby consumers.

Annotations
@Deprecated
@Override
getHandleback to summary
public MethodHandle getHandle(int arity)
getParameterListback to summary
public String[] getParameterList()

Implements org.jruby.internal.runtime.methods.MethodArgs2.getParameterList.

Annotations
@Override
getSignatureback to summary
public Signature getSignature()

Overrides org.jruby.internal.runtime.methods.DynamicMethod.getSignature.

Doc from org.jruby.internal.runtime.methods.DynamicMethod.getSignature.

Retrieve the signature of this method.

Returns:Signature

the signature

Annotations
@Override
isBuiltinback to summary
public boolean isBuiltin()

Overrides org.jruby.internal.runtime.methods.DynamicMethod.isBuiltin.

Doc from org.jruby.internal.runtime.methods.DynamicMethod.isBuiltin.

Whether this method is a builtin method, i.e. a method built-in to JRuby and loaded during its core boot process.

Returns:boolean

true if this is a core built-in method, false otherwise

Annotations
@Override
isNativeback to summary
public boolean isNative()

Overrides org.jruby.internal.runtime.methods.DynamicMethod.isNative.

Doc from org.jruby.internal.runtime.methods.DynamicMethod.isNative.

Returns true if this method is backed by native (i.e. Java) code.

Returns:boolean

true If backed by Java code or JVM bytecode; false otherwise

Annotations
@Override
isNotImplementedback to summary
public boolean isNotImplemented()

Overrides org.jruby.internal.runtime.methods.DynamicMethod.isNotImplemented.

Doc from org.jruby.internal.runtime.methods.DynamicMethod.isNotImplemented.

Whether this method is "not implemented". This is primarily to support Ruby 1.9's behavior of respond_to? yielding false if the feature in question is unsupported (but still having the method defined).

Returns:boolean

is this a method which is marked as not implemented

Annotations
@Override