form redefinition: behavior difference between CRuby & JRuby.
Reported by Bryan Larsen | April 7th, 2011 @ 05:10 PM | in Hobo 1.4
Hobo 1.0.3, JRuby 1.5.6, CRuby 1.8.7-p249, Rails 2.3.11
To reproduce:
hobo jbug2
cd jbug2
./script/generate jdbc
./script/generate hobo_model_resource foo name:string
./script/generate hobo_migration
./script/generate hobo_subsite admin --no-front-site
cp app/controllers/foos_controller.rb app/controllers/admin/ # and edit appropriately
then add a <def tag="form" for="Foo">this is a
test</def>
block into application.dryml.
start your server, and compare /foos/new with /admin/foos/new
In CRuby, both URL's display "this is a test". In JRuby, the /admin/foos/new URL displays the form from app/views/taglibs/auto/admin/rapid/forms.dryml.
Observation: the JRuby behavior is more "right". Hobo loads application.dryml before admin_site.dryml, so the admin_site generated form is the one that should be displayed.
Observation: using --make-front-site
should have
been used rather than --no-front-site
. If the
redefinition is in front_site.dryml rather than application.dryml,
there is no problem. But, application.dryml is supposed to be used
for "common" tags regardless, so this is still a problem.
What bothers me most is why the inconsistency? It's probably an indication of code fragility somewhere...
Comments and changes to this ticket
-
Bryan Larsen April 7th, 2011 @ 05:32 PM
- Title changed from from redefinition: behavior difference between CRuby & JRuby. to form redefinition: behavior difference between CRuby & JRuby.
-
Bryan Larsen April 11th, 2011 @ 06:26 PM
If you instrument Taglib#import_into, you can watch this bug in action. On the import of auto/admin/rapid/forms.dryml, JRuby imports the new definition and CRuby leaves the old definition the same.
CRuby:
class_or module before: #<UnboundMethod: #<Class:0x7fd29bb6fba0>(#<Module:0x7fd29b965dc8>)#form__for_foo> @module before: #<UnboundMethod: #<Module:0x7fd29b56f408>(#<Module:0x7fd29b67a550>)#form__for_foo> class_or module after: #<UnboundMethod: #<Class:0x7fd29bb6fba0>(#<Module:0x7fd29b965dc8>)#form__for_foo>
JRuby:
class_or module before: #<UnboundMethod: #<Class:01x54d57bcb>(#<Module:01x61bf61a0>)#form__for_foo> @module before: #<UnboundMethod: #<Module:01x115c6cb>(#<Module:01x33896444>)#form__for_foo> class_or module after: #<UnboundMethod: #<Class:01x54d57bcb>(#<Module:01x33896444>)#form__for_foo>
The Ruby behavior that we're triggering is that Ruby refuses to import a function into a class more than once. If you import function foo into a class, then foo with a different definition, and then the original foo, you end up with the second foo. That explains the CRuby behaviour. However, our form__for_foo function is created through a class_eval, so each function is different, thus the JRuby behaviour.
I've tried to reproduce this issue outside of Rails (see the attached hello.rb), but in hello.rb, the JRuby style behaviour is seen in both CRuby and JRuby, so I cannot escalate the problem.
-
Bryan Larsen April 12th, 2011 @ 02:42 PM
- no changes were found...
-
Matt Jones September 15th, 2011 @ 06:45 PM
- State changed from new to open
- Milestone set to Hobo 1.4
- Milestone order changed from 197968 to 0
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
People watching this ticket
Attachments
Referenced by
- 950 subsite generator default options suboptimal I believe this is a mistake, that the --make-front-site i...