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

ClassCastException thrown when a method is defined inside a test #4014

JasonLunn opened this issue Jul 13, 2016 · 0 comments

ClassCastException thrown when a method is defined inside a test #4014

JasonLunn opened this issue Jul 13, 2016 · 0 comments


Copy link

@JasonLunn JasonLunn commented Jul 13, 2016


jruby (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 24.45-b08 on 1.7.0_45-b18 +jit [darwin-x86_64]
Darwin shinji.local 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64

First discovered in the body of a large Rails 4.2.6 application where I am piloting the transition to JRuby 9K, but reproduced in a stock Rails application fresh out of the scaffold.

Other relevant info you may wish to add:

  • Rails 4.2.7

Expected Behavior

  • Defining a function in the body of a test should not cause a ClassCastException to be raised at runtime. It worked fine under JRuby 1.7.x.
require 'test_helper'

class FailcaseTest < ActiveSupport::TestCase
  test 'should not throw a class cast exception' do
    def bad

Actual Behavior

bundle exec rake test
Run options: --seed 7502

# Running:


Finished in 0.028675s, 34.8738 runs/s, 0.0000 assertions/s.

  1) Error:
Java::JavaLang::ClassCastException: org.jruby.RubyObjectVar7 cannot be cast to org.jruby.RubyModule

1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
@enebo enebo added the ir label Jul 14, 2016
@enebo enebo added this to the JRuby milestone Jul 14, 2016
@subbuss subbuss closed this in 6bb13ef Jul 16, 2016
subbuss added a commit that referenced this issue Jul 26, 2016
* Jason Lunn provided the reduced test case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.