Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambiguous method warning when submitting a Runnable to an Executor #3263

Closed
blinsay opened this Issue Aug 18, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@blinsay
Copy link

blinsay commented Aug 18, 2015

This is a followup to #2065. Submitting a class that includes java.lang.Runnable to an executor generates an ambiguous method warning on 9.0.0.0.

java_import java.util.concurrent.Executors
e = Executors.new_fixed_thread_pool(1)

class Foo
  include java.lang.Runnable

  def run
    sleep 2
    puts "hi"
  end
end
e.submit(Foo.new)
# (pry):11: warning: ambiguous Java methods found, using submit(java.lang.Runnable)
@headius

This comment has been minimized.

Copy link
Member

headius commented Aug 18, 2015

I'm confused...I see the warning on 1.7.21 but not on 9.0.0.0.

@blinsay

This comment has been minimized.

Copy link
Author

blinsay commented Aug 18, 2015

Weeeeeeeeeeeeeeeird. I'm on 9k installed through rbenv and ruby-build and Java 8.

$ java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
$ rbenv local jruby-9.0.0.0
$ irb
irb(main):001:0> puts RUBY_VERSION, RUBY_PATCHLEVEL, JRUBY_VERSION
2.2.2
0
9.0.0.0
=> nil
irb(main):002:0> java_import java.util.concurrent.Executors
=> [Java::JavaUtilConcurrent::Executors]
irb(main):003:0> e = Executors.new_fixed_thread_pool(1)
=> #<Java::JavaUtilConcurrent::ThreadPoolExecutor:0x77be656f>
irb(main):004:0>
irb(main):005:0* class Foo
irb(main):006:1>   include java.lang.Runnable
irb(main):007:1>
irb(main):008:1*   def run
irb(main):009:2>     sleep 2
irb(main):010:2>     puts "hi"
irb(main):011:2>   end
irb(main):012:1> end
=> :run
irb(main):013:0> e.submit(Foo.new)
(irb):13: warning: ambiguous Java methods found, using submit(java.lang.Runnable)
=> #<Java::JavaUtilConcurrent::FutureTask:0x6b1274d2>
@kares

This comment has been minimized.

Copy link
Member

kares commented Aug 19, 2015

mean to try out jruby-1_7 ... but no problem I did :

kares@sputnik:~/workspace/oss/jruby$ bin/jruby -v
jruby 1.7.22-SNAPSHOT (1.9.3p551) 2015-08-19 6992f8e on Java HotSpot(TM) 64-Bit Server VM 1.8.0_45-b14 +jit [linux-amd64]
kares@sputnik:~/workspace/oss/jruby$ bin/jruby -S irb
Ignoring jruby-launcher-1.0.19-java because its extensions are not built.  Try: gem pristine jruby-launcher --version 1.0.19
irb(main):001:0> java_import java.util.concurrent.Executors
=> [Java::JavaUtilConcurrent::Executors]
irb(main):002:0> e = Executors.new_fixed_thread_pool(1)
=> #<Java::JavaUtilConcurrent::ThreadPoolExecutor:0x7f416310>
irb(main):003:0> 
irb(main):004:0* class Foo
irb(main):005:1>   include java.lang.Runnable
irb(main):006:1> 
irb(main):007:1*   def run
irb(main):008:2>     sleep 2
irb(main):009:2>     puts "hi"
irb(main):010:2>   end
irb(main):011:1> end
=> nil
irb(main):012:0> e.submit(Foo.new)
=> #<Java::JavaUtilConcurrent::FutureTask:0xdbd940d>
irb(main):013:0> hi

... @headius probably tried 9k (master) which already has the merges from jruby-1_7, marking for 1.7.22

@blinsay

This comment has been minimized.

Copy link
Author

blinsay commented Aug 19, 2015

Thanks team!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.