Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

JRuby compatibility #85

Merged
merged 1 commit into from

2 participants

@djreimer

When I attempt to run in JRuby, the follow error occurs:

RuntimeError: ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable each_object at org/jruby/RubyObjectSpace.java:167

By default, ObjectSpace.each_object is disabled in JRuby for performance reasons. However, ObjectSpace.each_object(Class) still works without enabling on the whole enchilada. I made this change and all the specs pass on MRI and JRuby, except for the integration tests (I'm having trouble getting the integration tests to pass on my machine even without the patch). Perhaps someone could verify that those pass as well.

@djreimer djreimer JRuby compatibility
By default, ObjectSpace.each_object is disabled in JRuby. However,
ObjectSpace.each_object(Class) still works.
83cacd7
@djreimer

Sounds good, thanks!

@alexch
Collaborator

Confirmed to work fine in MRI 1.9.3.

@alexch alexch merged commit 75e4bfa into from
@lime lime referenced this pull request from a commit in lime/annotate_models
@alexch alexch Integrate various fixes around finding model classes, including ctran#82 076e778
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 17, 2012
  1. @djreimer

    JRuby compatibility

    djreimer authored
    By default, ObjectSpace.each_object is disabled in JRuby. However,
    ObjectSpace.each_object(Class) still works.
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 5 deletions.
  1. +2 −5 lib/annotate/annotate_models.rb
View
7 lib/annotate/annotate_models.rb
@@ -316,11 +316,8 @@ def get_model_class(file)
# Retrieve loaded model class by path to the file where it's supposed to be defined.
def get_loaded_model(model_path)
- ObjectSpace.each_object.
- select { |c|
- Class === c and # note: we use === to avoid a bug in activesupport 2.3.14 OptionMerger vs. is_a?
- c.ancestors.include?(ActiveRecord::Base)
- }.
+ ObjectSpace.each_object(::Class).
+ select { |c| c.ancestors.include?(ActiveRecord::Base) }.
detect { |c| ActiveSupport::Inflector.underscore(c) == model_path }
end
Something went wrong with that request. Please try again.