Skip to content

Commit

Permalink
Fix Java interface aggregation in modles for JRUBY-6945.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Dec 29, 2014
1 parent 2ecb4ed commit c74647f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
13 changes: 13 additions & 0 deletions spec/java_integration/interfaces/implementation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c74647f

Please sign in to comment.