Skip to content

Instantly share code, notes, and snippets.

@tehviking
Created November 10, 2011 17:09
Show Gist options
  • Save tehviking/1355431 to your computer and use it in GitHub Desktop.
Save tehviking/1355431 to your computer and use it in GitHub Desktop.
JRuby in 1.9 UTF-8 breaks ERB: Java::JavaLang::ArrayIndexOutOfBoundsException in Default#index
#WORKS
# -*- coding: UTF-8 -*-
require 'erb'
template = ERB.new <<-EOF
<% 0.times do %>
<% end %>
EOF
puts template.result
#BREAKS
# -*- coding: UTF-8 -*-
require 'erubis'
template = Erubis::Eruby.new <<-EOF
<% 0.times do %>
<% end %>
EOF
puts template.result
Java::JavaLang::ArrayIndexOutOfBoundsException in Default#index
Showing /Users/bjohnson/learn/jutf/app/views/default/index.html.erb where line # raised:
2
Extracted source (around line #):
<% 0.times do %>
<% end %>
@tehviking
Copy link
Author

This seems to relate to this issue, which has no assignee:

http://jira.codehaus.org/browse/JRUBY-6120

I should note this is in JRuby 1.6.5, and that removing the UTF-8 chars or the ERB code seems to bypass the issue.

@qichunren
Copy link

+1
I also got this bug, when I Set JRuby to run in 1.9 mode

@tehviking
Copy link
Author

@tom_enebo (on Twitter) fixed this for ERB renderer, but Erubis is still a problem. This breaks Rails 3 on 1.9, so it seems like it ought to be widespread for 1.9 mode. He says he's looking into this and should have a fix to test in the next week or so.

@bkoc
Copy link

bkoc commented Nov 22, 2011

+1

@tehviking
Copy link
Author

Tom says he hasn't had time to look into this issue, but should soon. I'll post again if and when I hear this issue is ready for some testing.

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