Skip to content
Permalink
Browse files
Fix Java interface aggregation in modles for JRUBY-6945.
  • Loading branch information
headius committed Dec 29, 2014
1 parent 2ecb4ed commit c74647f9ac3fb71a24fdfec37b39796766892748
Showing with 16 additions and 3 deletions.
  1. +3 −3 core/src/main/java/org/jruby/java/proxies/JavaInterfaceTemplate.java
  2. +13 −0 spec/java_integration/interfaces/implementation_spec.rb
@@ -307,10 +307,10 @@ private static void appendFeaturesToModule(ThreadContext context, IRubyObject se
singleton.addMethod("append_features", new JavaMethodOneBlock(singleton, Visibility.PUBLIC) {
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg, Block block) {
if (!(arg instanceof RubyClass)) {
throw context.runtime.newTypeError("append_features called with non-class");
if (!(arg instanceof RubyModule)) {
throw context.runtime.newTypeError("append_features called with non-module");
}
RubyClass target = (RubyClass)arg;
RubyModule target = (RubyModule)arg;
RubyArray javaInterfaceMods = (RubyArray)self.getInstanceVariables().getInstanceVariable("@java_interface_mods");

target.include(javaInterfaceMods.toJavaArray());
@@ -38,6 +38,19 @@ def call_it
end
end

# JRUBY-6945
it "should allow aggregating interfaces in a module" do
a = Module.new do
include java.awt.event.ActionListener
end

lambda do
b = Module.new do
include a
end
end.should_not raise_error
end

it "should be kind_of? the interface" do
@value_holder1.new(1).should be_kind_of(SingleMethodInterface)
SingleMethodInterface.should === @value_holder1.new(1)

0 comments on commit c74647f

Please sign in to comment.