Skip to content

Commit

Permalink
Fix erroneous 'wrong number of arguments' errors on JRuby 9.0.5.0.
Browse files Browse the repository at this point in the history
Resolves #114.
  • Loading branch information
philr committed Feb 26, 2020
1 parent 7a603da commit 83bdd0e
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 10 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Expand Up @@ -2,9 +2,9 @@ language: ruby
dist: trusty
sudo: false
before_install:
- if [[ $TRAVIS_RUBY_VERSION =~ ^((1|2\.[012]|jruby-1)\.|ree$) ]]; then gem install rubygems-update --version '~> 2.7' --no-document && update_rubygems; else gem update --system; fi
- if [[ $TRAVIS_RUBY_VERSION =~ ^((1|2\.[012]|jruby-(1|9\.0))\.|ree$) ]]; then gem install rubygems-update --version '~> 2.7' --no-document && update_rubygems; else gem update --system; fi
- gem --version
- if [[ $TRAVIS_RUBY_VERSION =~ ^((1|2\.[012]|jruby-1)\.|ree$) ]]; then gem install bundler --version '~> 1.17'; else gem install bundler; fi
- if [[ $TRAVIS_RUBY_VERSION =~ ^((1|2\.[012]|jruby-(1|9\.0))\.|ree$) ]]; then gem install bundler --version '~> 1.17'; else gem install bundler; fi
- bundle --version
before_script:
- bundle update
Expand All @@ -27,6 +27,7 @@ rvm:
- ruby-head
- jruby-18mode
- jruby-1.7.27
- jruby-9.0.5.0
- jruby-9.1.17.0
- jruby-9.2.9.0
- jruby-head
Expand Down
9 changes: 7 additions & 2 deletions appveyor.yml
Expand Up @@ -57,6 +57,11 @@ environment:

- RUBY_ENGINE: jruby
JRUBY_VERSION: 1.7.27
JRUBY_BUNDLER_VERSION: "~> 1.17"

- RUBY_ENGINE: jruby
JRUBY_VERSION: 9.0.5.0
JRUBY_BUNDLER_VERSION: "~> 1.17"

- RUBY_ENGINE: jruby
JRUBY_VERSION: 9.1.17.0
Expand All @@ -69,8 +74,8 @@ install:
- if %RUBY_ENGINE%==jruby appveyor DownloadFile https://repo1.maven.org/maven2/org/jruby/jruby-dist/%JRUBY_VERSION%/jruby-dist-%JRUBY_VERSION%-bin.zip -FileName vendor\jruby-dist-%JRUBY_VERSION%-bin.zip
- if %RUBY_ENGINE%==jruby 7z x vendor\jruby-dist-%JRUBY_VERSION%-bin.zip -ovendor -y
- if %RUBY_ENGINE%==jruby set PATH=C:\projects\tzinfo\vendor\jruby-%JRUBY_VERSION%\bin;%PATH%
- if %RUBY_ENGINE%==jruby if "%JRUBY_VERSION:~0,2%"=="1." gem install bundler --version "~> 1.17"
- if %RUBY_ENGINE%==jruby if not "%JRUBY_VERSION:~0,2%"=="1." gem install bundler
- if %RUBY_ENGINE%==jruby if defined JRUBY_BUNDLER_VERSION gem install bundler --version "%JRUBY_BUNDLER_VERSION%"
- if %RUBY_ENGINE%==jruby if not defined JRUBY_BUNDLER_VERSION gem install bundler
- if v%RUBY_VERSION%==v193 appveyor DownloadFile https://github.com/philr/rubyinstaller/releases/download/1.9.3-p551-openssl-tls-1.1-1.2/ruby-1.9.3-p551-i386-mingw32.7z -FileName vendor\ruby-1.9.3-p551-i386-mingw32.7z
- if v%RUBY_VERSION%==v193 7z e vendor\ruby-1.9.3-p551-i386-mingw32.7z -ovendor ruby-1.9.3-p551-i386-mingw32\bin\libeay32.dll ruby-1.9.3-p551-i386-mingw32\bin\ssleay32.dll ruby-1.9.3-p551-i386-mingw32\lib\ruby\1.9.1\i386-mingw32\openssl.so ruby-1.9.3-p551-i386-mingw32\lib\ruby\1.9.1\rubygems\ssl_certs\ca-bundle.pem
- if v%RUBY_VERSION%==v193 copy /Y vendor\*eay32.dll C:\Ruby193\bin
Expand Down
4 changes: 3 additions & 1 deletion lib/tzinfo/ruby_data_source.rb
@@ -1,5 +1,7 @@
module TZInfo
using RubyCoreSupport::UntaintExt if RubyCoreSupport.const_defined?(:UntaintExt)
# Use send as a workaround for erroneous 'wrong number of arguments' errors
# with JRuby 9.0.5.0 when calling methods with Java implementations. See #114.
send(:using, RubyCoreSupport::UntaintExt) if RubyCoreSupport.const_defined?(:UntaintExt)

# A DataSource that loads data from the set of Ruby modules included in the
# TZInfo::Data library (tzinfo-data gem).
Expand Down
4 changes: 3 additions & 1 deletion lib/tzinfo/zoneinfo_timezone_info.rb
@@ -1,5 +1,7 @@
module TZInfo
using RubyCoreSupport::UntaintExt if RubyCoreSupport.const_defined?(:UntaintExt)
# Use send as a workaround for erroneous 'wrong number of arguments' errors
# with JRuby 9.0.5.0 when calling methods with Java implementations. See #114.
send(:using, RubyCoreSupport::UntaintExt) if RubyCoreSupport.const_defined?(:UntaintExt)

# An InvalidZoneinfoFile exception is raised if an attempt is made to load an
# invalid zoneinfo file.
Expand Down
4 changes: 3 additions & 1 deletion test/tc_country.rb
Expand Up @@ -2,7 +2,9 @@

include TZInfo

using TaintExt if Module.const_defined?(:TaintExt)
# Use send as a workaround for erroneous 'wrong number of arguments' errors with
# JRuby 9.0.5.0 when calling methods with Java implementations. See #114.
send(:using, TaintExt) if Module.const_defined?(:TaintExt)

class TCCountry < Minitest::Test
def setup
Expand Down
4 changes: 3 additions & 1 deletion test/tc_ruby_data_source.rb
Expand Up @@ -2,7 +2,9 @@

include TZInfo

using TaintExt if Module.const_defined?(:TaintExt)
# Use send as a workaround for erroneous 'wrong number of arguments' errors with
# JRuby 9.0.5.0 when calling methods with Java implementations. See #114.
send(:using, TaintExt) if Module.const_defined?(:TaintExt)

class TCRubyDataSource < Minitest::Test
def setup
Expand Down
4 changes: 3 additions & 1 deletion test/tc_timezone.rb
Expand Up @@ -2,7 +2,9 @@

include TZInfo

using TaintExt if Module.const_defined?(:TaintExt)
# Use send as a workaround for erroneous 'wrong number of arguments' errors with
# JRuby 9.0.5.0 when calling methods with Java implementations. See #114.
send(:using, TaintExt) if Module.const_defined?(:TaintExt)

class TCTimezone < Minitest::Test

Expand Down
4 changes: 3 additions & 1 deletion test/tc_zoneinfo_timezone_info.rb
Expand Up @@ -5,7 +5,9 @@

include TZInfo

using RubyCoreSupport::UntaintExt if RubyCoreSupport.const_defined?(:UntaintExt)
# Use send as a workaround for erroneous 'wrong number of arguments' errors with
# JRuby 9.0.5.0 when calling methods with Java implementations. See #114.
send(:using, RubyCoreSupport::UntaintExt) if RubyCoreSupport.const_defined?(:UntaintExt)

class TCZoneinfoTimezoneInfo < Minitest::Test

Expand Down
4 changes: 4 additions & 0 deletions test/test_utils.rb
Expand Up @@ -116,6 +116,10 @@ def assert_array_same_items(expected, actual, msg = nil)
end

def assert_sub_process_returns(expected_lines, code, extra_load_path = [], required = ['tzinfo'])
if RUBY_ENGINE == 'jruby' && JRUBY_VERSION.start_with?('9.0.') && RbConfig::CONFIG['host_os'] =~ /mswin/
skip('JRuby 9.0 on Windows cannot handle writing to the IO instance returned by popen')
end

ruby = File.join(RbConfig::CONFIG['bindir'],
RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT'])

Expand Down

0 comments on commit 83bdd0e

Please sign in to comment.