Flaws in constant caching
-------------------------

                 Key: JRUBY-3091
                 URL: http://jira.codehaus.org/browse/JRUBY-3091
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
            Reporter: Charles Oliver Nutter
            Assignee: Thomas E Enebo
            Priority: Blocker
             Fix For: JRuby 1.1.5


In response to a report from Raphael Valyi I have discovered some crucial flaws 
in the constant caching logic; some of them may not be reconcilable with the 
current design.

The first is when a value previously cached gets shadowed by new value in an 
intermediate module or class in the inheritance hierarchy:

{noformat}
BAR = 1
class Bar; end
class Foo < Bar
  def bar; BAR; end
end
puts Foo.new.bar
Bar.const_set(:BAR, 2)
puts Foo.new.bar
{noformat}

This should print 1, then 2, but it prints 1 and 1.

The second case is when a previously cached value is shadowed by a new value in 
an intermediate module or class in the containment hierarchy.

{noformat}
BAR = 1
class Bar
  class Foo
    def bar; BAR; end
  end
end
puts Bar::Foo.new.bar
Bar.const_set(:BAR, 2)
puts Bar::Foo.new.bar
{noformat}

The first case seems like it would be caused by bad generation-twiddling. It 
could probably be fixed by sorting out when generation-twiddling is not 
happening and making sure it is cascading properly.

The second case, however, is a more serious problem. Because we do not 
currently track cref containment from parent to child, there's no way for an 
update to a cref constant scope to inform containing scopes of the change. We 
would need to add a new weak list of contained crefs similar to the subclasses 
list currently in RubyModule.

If we can't resolve these problems 1.1.5 will have to ship without constant 
caching. I'm committing a change to temporarily disable constant caching, and I 
am adding the tests I describe above.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to