java.lang.Object
org.jruby.java.codegen.BlockInterfaceGenerator
Generates a concrete subclass of
BlockInterfaceTemplate for a Java interface, where
every abstract method delegates straight into one of the inherited __ruby_call helpers.
Default methods on the interface are intentionally not overridden, matching the pre-existing
convertProcToInterface behavior where only abstract methods were backed by the proc.
For an interface such as:
public interface MyIface {
int compute(int a, String b);
default int compute2(int a, String b) { return compute(a, b) * 2; }
}
the generated class is equivalent to:
public final class BlockInterfaceImpl$<hash> extends BlockInterfaceTemplate implements MyIface {
public BlockInterfaceImpl$<hash>(RubyProc proc) { super(proc); }
public int compute(int a, String b) {
Object result = __ruby_call(Integer.TYPE, coerce(a), coerce(b));
return ((Number) result).intValue();
}
// compute2 is not overridden — the interface default is used
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Constructor<? extends BlockInterfaceTemplate> static Constructor<? extends BlockInterfaceTemplate> getConstructor(Ruby runtime, Class<?> interfaceType)
-
Constructor Details
-
BlockInterfaceGenerator
public BlockInterfaceGenerator()
-
-
Method Details
-
fromCache
-
getConstructor
public static Constructor<? extends BlockInterfaceTemplate> getConstructor(Ruby runtime, Class<?> interfaceType) throws ReflectiveOperationException - Returns:
- the constructor, which is usable with any Ruby block targeting the same interface
- Throws:
ReflectiveOperationException
-