Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e097afb77219
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6f98597dcf67
Choose a head ref
  • 3 commits
  • 3 files changed
  • 2 contributors

Commits on Mar 22, 2016

  1. Remove 'new' method from interfaces

    Added a new spec: 'interface_new.rb'
    
    See issue #3275
    Lan5432 committed Mar 22, 2016
    Copy the full SHA
    4050fe7 View commit details

Commits on Mar 29, 2016

  1. Copy the full SHA
    654e7db View commit details

Commits on Apr 27, 2016

  1. Merge pull request #3752 from Lan5432/master

    Removing 'new' class method from interfaces #3275
    kares committed Apr 27, 2016
    Copy the full SHA
    6f98597 View commit details
Original file line number Diff line number Diff line change
@@ -515,20 +515,6 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule klaz

}

@JRubyMethod(name = "new", rest = true)
public static IRubyObject new_impl(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) {
final Ruby runtime = context.runtime;

RubyClass implClass = (RubyClass) self.getInstanceVariables().getInstanceVariable("@__implementation");
if (implClass == null) {
implClass = RubyClass.newClass(runtime, runtime.getClass("InterfaceJavaProxy"));
implClass.include(new IRubyObject[] { self });
Helpers.setInstanceVariable(implClass, self, "@__implementation");
}

return Helpers.invoke(context, implClass, "new", args, block);
}

private static JavaClass getJavaClassForInterface(final IRubyObject module) {
return (JavaClass) module.getInstanceVariables().getInstanceVariable("@java_class");
}
15 changes: 15 additions & 0 deletions spec/java_integration/interfaces/interface_new.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require File.dirname(__FILE__) + "/../spec_helper"

describe "what happens with method new on interfaces" do

it "should not be able to instantiate an interface" do
expect{java.lang.Runnable.new}.to raise_error(NoMethodError)
end

it "should not affect impl()" do
@runnable = java.lang.Runnable.impl {a = "Hello"}
expect{@runnable.run}.to_not raise_error(NoMethodError)
expect{@runnable.run}.to eq("Hello")
end

end
22 changes: 11 additions & 11 deletions spec/java_integration/methods/naming_spec.rb
Original file line number Diff line number Diff line change
@@ -191,37 +191,37 @@

describe "Needed implementation methods for interfaces" do
it "should have __id__ method" do
expect(BeanLikeInterface.new.methods).to have_strings_or_symbols("__id__")
expect(BeanLikeInterface.impl {}.methods).to have_strings_or_symbols("__id__")
end
it "should have __send__ method" do
expect(BeanLikeInterface.new.methods).to have_strings_or_symbols("__send__")
expect(BeanLikeInterface.impl {}.methods).to have_strings_or_symbols("__send__")
end
it "should have == method" do
expect(BeanLikeInterface.new.methods).to have_strings_or_symbols("==")
expect(BeanLikeInterface.impl {}.methods).to have_strings_or_symbols("==")
end
it "should have inspect method" do
expect(BeanLikeInterface.new.methods).to have_strings_or_symbols("inspect")
expect(BeanLikeInterface.impl {}.methods).to have_strings_or_symbols("inspect")
end
it "should have respond_to? method" do
expect(BeanLikeInterface.new.methods).to have_strings_or_symbols("respond_to?")
expect(BeanLikeInterface.impl {}.methods).to have_strings_or_symbols("respond_to?")
end
it "should have class method" do
expect(BeanLikeInterface.new.methods).to have_strings_or_symbols("class")
expect(BeanLikeInterface.impl {}.methods).to have_strings_or_symbols("class")
end
it "should have methods method" do
expect(BeanLikeInterface.new.methods).to have_strings_or_symbols("methods")
expect(BeanLikeInterface.impl {}.methods).to have_strings_or_symbols("methods")
end
it "should have send method" do
expect(BeanLikeInterface.new.methods).to have_strings_or_symbols("send")
expect(BeanLikeInterface.impl {}.methods).to have_strings_or_symbols("send")
end
it "should have equal? method" do
expect(BeanLikeInterface.new.methods).to have_strings_or_symbols("equal?")
expect(BeanLikeInterface.impl {}.methods).to have_strings_or_symbols("equal?")
end
it "should have eql? method" do
expect(BeanLikeInterface.new.methods).to have_strings_or_symbols("eql?")
expect(BeanLikeInterface.impl {}.methods).to have_strings_or_symbols("eql?")
end
it "should have to_s method" do
expect(BeanLikeInterface.new.methods).to have_strings_or_symbols("to_s")
expect(BeanLikeInterface.impl {}.methods).to have_strings_or_symbols("to_s")
end

it "should be able to access Java methods of core Ruby Methods via __method" do