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

org.jruby.javasupport.ext.JavaLang.Number#define emits "method redefined" warnings in verbose mode #8244

Closed
ikaronen-relex opened this issue May 19, 2024 · 3 comments · Fixed by #8247

Comments

@ikaronen-relex
Copy link
Contributor

In seems that the proxy.defineAlias calls at https://github.com/jruby/jruby/blob/9.4.6.0/core/src/main/java/org/jruby/javasupport/ext/JavaLang.java#L359 generate warnings in verbose mode, presumably because methods with the same name have already been defined by proxy.defineAnnotatedMethods just before.

This can be easily demonstrated with jruby -S irb:

irb(main):001> $VERBOSE = true
=> true
irb(main):002> java.lang.Integer
(irb):2: warning: method redefined; discarding old to_int
(irb):2: warning: method redefined; discarding old to_f
=> Java::JavaLang::Integer

Presumably one of the redundant sets of definitions should be removed.

Tested on jruby 9.4.6.0 (3.1.4) 2024-02-20 576fab2 OpenJDK 64-Bit Server VM 21.0.2+13-LTS on 21.0.2+13-LTS +jit [arm64-darwin]. The code hasn't changed in 9.4.7.0 or master, however.

@ikaronen-relex
Copy link
Contributor Author

It looks like aliasing to_int to longValue also breaks it for Java BigIntegers:

irb(main):003> java.math.BigInteger.new("12345678901234567890").to_i
=> 12345678901234567890
irb(main):004> java.math.BigInteger.new("12345678901234567890").to_int
=> -6101065172474983726

Given this, I think these aliases should probably just be removed. I'll make a PR tomorrow.

@enebo
Copy link
Member

enebo commented May 21, 2024

Thanks @ikaronen-relex ... It would seem the aliases probably preceded the @JRubyMethod definitions and no one noticed after the real methods were added?

@headius
Copy link
Member

headius commented May 22, 2024

It would seem the aliases probably preceded the @JRubyMethod definitions

Yeah this is a good theory. At some point @kares moved most of the Ruby-based definitions of JI logic in Java, and I'm sure the aliases just got doubled up. Nice to get rid of those warnings! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants