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

The i18n gem does not work in AOT mode #4416

Closed
glebm opened this issue Dec 30, 2016 · 9 comments
Closed

The i18n gem does not work in AOT mode #4416

glebm opened this issue Dec 30, 2016 · 9 comments

Comments

@glebm
Copy link
Contributor

glebm commented Dec 30, 2016

Environment

$ jruby -v
jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [darwin-x86_64]
$ echo $JRUBY_OPTS                                                                                                                                       
-Xcompile.mode=FORCE
$ uname -a
Darwin Macintosh.local 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64

Expected Behavior

The i18n gem test suite passes in AOT mode:

$ git clone https://github.com/svenfuchs/i18n.git
$ cd i18n
$ bundle
$ JRUBY_OPTS="-Xcompile.mode=FORCE" bundle exec rake

Actual Behavior

# Running:

NoMethodError: private method `run' called for #<I18nBackendPluralizationTest:0x1a02ebe0>
     run_one_method at /Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/minitest-5.10.1/lib/minitest.rb:822
     run_one_method at /Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/minitest-5.10.1/lib/minitest.rb:323
       block in run at /Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/minitest-5.10.1/lib/minitest.rb:310
               each at org/jruby/RubyArray.java:1734
       block in run at /Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/minitest-5.10.1/lib/minitest.rb:309
          on_signal at /Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/minitest-5.10.1/lib/minitest.rb:349
  with_info_handler at /Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/minitest-5.10.1/lib/minitest.rb:336
                run at /Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/minitest-5.10.1/lib/minitest.rb:308
     block in __run at /Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/minitest-5.10.1/lib/minitest.rb:158
                map at org/jruby/RubyArray.java:2492
              __run at /Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/minitest-5.10.1/lib/minitest.rb:158
                run at /Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/minitest-5.10.1/lib/minitest.rb:135
   block in autorun at /Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/minitest-5.10.1/lib/minitest.rb:62
rake aborted!
Command failed with status (1): [ruby -w -I"lib:lib:test" -I"/Users/glebm/.rvm/gems/jruby-9.1.6.0@global/gems/rake-12.0.0/lib" "/Users/glebm/.rvm/gems/jruby-9.1.6.0@global/gems/rake-12.0.0/lib/rake/rake_test_loader.rb" "test/api/all_features_test.rb" "test/api/cascade_test.rb" "test/api/chain_test.rb" "test/api/fallbacks_test.rb" "test/api/key_value_test.rb" "test/api/memoize_test.rb" "test/api/override_test.rb" "test/api/pluralization_test.rb" "test/api/simple_test.rb" "test/backend/cache_test.rb" "test/backend/cascade_test.rb" "test/backend/chain_test.rb" "test/backend/exceptions_test.rb" "test/backend/fallbacks_test.rb" "test/backend/interpolation_compiler_test.rb" "test/backend/key_value_test.rb" "test/backend/memoize_test.rb" "test/backend/metadata_test.rb" "test/backend/pluralization_test.rb" "test/backend/simple_test.rb" "test/backend/transliterator_test.rb" "test/core_ext/hash_test.rb" "test/gettext/api_test.rb" "test/gettext/backend_test.rb" "test/i18n/exceptions_test.rb" "test/i18n/interpolate_test.rb" "test/i18n/load_path_test.rb" "test/i18n_test.rb" "test/locale/fallbacks_test.rb" "test/locale/tag/rfc4646_test.rb" "test/locale/tag/simple_test.rb" ]
/Users/glebm/.rvm/gems/jruby-9.1.6.0@global/gems/rake-12.0.0/exe/rake:27:in `<main>'
/Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `kernel_load'
/Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:27:in `run'
/Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/bundler-1.13.7/lib/bundler/cli.rb:332:in `exec'
/Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/bundler-1.13.7/lib/bundler/cli.rb:20:in `dispatch'
/Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/bundler-1.13.7/lib/bundler/cli.rb:11:in `start'
/Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/bundler-1.13.7/exe/bundle:34:in `block in /Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/bundler-1.13.7/exe/bundle'
/Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/bundler-1.13.7/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors'
/Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/gems/bundler-1.13.7/exe/bundle:26:in `<main>'
/Users/glebm/.rvm/gems/jruby-9.1.6.0@global/gems/rake-12.0.0/exe/rake:25:in `<eval>'
/Users/glebm/.rvm/gems/jruby-9.1.6.0@i18n/bin/jruby_executable_hooks:15:in `<main>'
Tasks: TOP => default => test
(See full trace by running task with --trace)
@glebm glebm changed the title i18n gem doesn't work in AOT mode i18n gem does not work in AOT mode Dec 30, 2016
@glebm glebm changed the title i18n gem does not work in AOT mode The i18n gem does not work in AOT mode Dec 30, 2016
@headius
Copy link
Member

headius commented Jan 4, 2017

Interestingly, the run method itself does not appear to be private or protected.

@headius
Copy link
Member

headius commented Jan 4, 2017

This is minor and we're trying to get 9.1.7.0. Assigning to 9.2, since that would be a nice time to work out any remaining kinks in the JIT.

@kares
Copy link
Member

kares commented Jan 9, 2017

getting a different failures (same without rake loader being loaded) - most are variations of :

kares@sputnik:~/workspace/oss/jruby/i18n$ jruby -Xcompile.mode=FORCE -I"lib:test" -I"/opt/local/rvm/gems/jruby-9.1.6.0@temp/gems/rake-12.0.0/lib" "/opt/local/rvm/gems/jruby-9.1.6.0@temp/gems/rake-12.0.0/lib/rake/rake_test_loader.rb" "test/backend/pluralization_test.rb"
Run options: --seed 48359

# Running:

EEEEEEE

Finished in 0.089272s, 78.4123 runs/s, 0.0000 assertions/s.

  1) Error:
I18nBackendPluralizationTest#test_pluralization_picks_a_pluralizer_from_:'i18n.pluralize':
NoMethodError: private method `store_translations' called for #<I18nBackendPluralizationTest::Backend:0x24aedcc5>
    /home/kares/workspace/oss/jruby/i18n/test/test_helper.rb:49:in `store_translations'
    /home/kares/workspace/oss/jruby/i18n/test/backend/pluralization_test.rb:13:in `setup'

Error:
I18nBackendPluralizationTest#test_pluralization_picks_a_pluralizer_from_:'i18n.pluralize':
NoMethodError: private method `reload!' called for #<I18nBackendPluralizationTest::Backend:0x24aedcc5>
    /home/kares/workspace/oss/jruby/i18n/lib/i18n/config.rb:128:in `load_path='
    /home/kares/workspace/oss/jruby/i18n/lib/i18n.rb:35:in `load_path='
    /home/kares/workspace/oss/jruby/i18n/test/test_helper.rb:34:in `teardown'

... I do seem to be having issues starting this up with current master (targeted for 9.1.7)

@kares
Copy link
Member

kares commented Jan 9, 2017

@headius there definitely seems to be a regression when running FORCE compiled on master :

2017-01-09T11:37:01.428+01:00 [main] INFO Ruby : done compiling target script: uri:classloader:/jruby/java.rb
2017-01-09T11:37:01.544+01:00 [main] INFO Ruby : done compiling target script: uri:classloader:/jruby/java/java_utilities.rb
TypeError: no outer class/module
              getStackTrace at java/lang/Thread.java:1556
           getBacktraceData at org/jruby/runtime/backtrace/TraceType.java:246
               getBacktrace at org/jruby/runtime/backtrace/TraceType.java:47
           prepareBacktrace at org/jruby/RubyException.java:235
                   preRaise at org/jruby/exceptions/RaiseException.java:216
                   preRaise at org/jruby/exceptions/RaiseException.java:183
                     <init> at org/jruby/exceptions/RaiseException.java:111
          newRaiseException at org/jruby/Ruby.java:4099
               newTypeError at org/jruby/Ruby.java:3770
        newRubyModuleFromIR at org/jruby/ir/runtime/IRRuntimeHelpers.java:1272
      newCompiledModuleBody at org/jruby/ir/runtime/IRRuntimeHelpers.java:1266
                     <main> at uri:classloader:/jruby/java/java_utilities.rb:2
        invokeWithArguments at java/lang/invoke/MethodHandle.java:627
                       load at org/jruby/ir/Compiler.java:90
                  runScript at org/jruby/Ruby.java:823
                runNormally at org/jruby/Ruby.java:742
         compileAndLoadFile at org/jruby/Ruby.java:2918
                       load at org/jruby/runtime/load/LibrarySearcher.java:241
                       load at org/jruby/runtime/load/LibrarySearcher.java:34
                       load at org/jruby/runtime/load/LoadService.java:342
                 loadCommon at org/jruby/RubyKernel.java:987
                     load19 at org/jruby/RubyKernel.java:979
                       call at org/jruby/RubyKernel$INVOKER$s$0$1$load19.gen:-1
                       call at org/jruby/internal/runtime/methods/DynamicMethod.java:204
                       call at org/jruby/internal/runtime/methods/DynamicMethod.java:200
               cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:338
                       call at org/jruby/runtime/callsite/CachingCallSite.java:163
          invokeOther1:load at uri_3a_classloader_3a_/jruby/uri:classloader:/jruby/java.rb:37
                     <main> at uri:classloader:/jruby/java.rb:37

@kares
Copy link
Member

kares commented Jan 9, 2017

@headius regression is caused by these top-level script protocol fixes at: a3ad3fb (from #4390)

@enebo enebo added this to the JRuby 9.1.7.0 milestone Jan 9, 2017
@headius
Copy link
Member

headius commented Jan 9, 2017

@kares Ahh, thank you for bisecting. I'll look into that. Might be able to just revert those changes and fix the issue in a different way.

@headius
Copy link
Member

headius commented Jan 9, 2017

Looks like something wrong with how we do load versus running target script directly. If I put...

module Foo
end

...in a file, I can -X+C that file just fine, but if I load it under -X+C it produces that same TypeError.

@headius
Copy link
Member

headius commented Jan 9, 2017

Good news! It seems the fix was simpler than we expected. The problem appears to be that we weren't testing the top-level "container" module when loading scripts with AOT. As a result, any modules or classes they attempted to define would raise that TypeError, because the containing module (into which they would be defined) was null.

My fix is being tested in #4431, but I confirmed it lets both i18n's test suite and one of our own suites both run properly (and all green) with AOT enabled.

@headius headius closed this as completed in 8a8fa01 Jan 9, 2017
@headius
Copy link
Member

headius commented Jan 9, 2017

@glebm If you can confirm with a JRuby master build, we'd appreciate it. I was able to run i18n tests fine with this patch. rvm install jruby-head should work, but it's pretty easy to clone and build too. See BUILDING.md.

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

No branches or pull requests

4 participants