Permalink
Browse files

Fix JRUBY-4765, AssertionError while getting the second new JSR223 en…

…gine.
  • Loading branch information...
1 parent 3a3ae0f commit a1e0c4d837a7b87325f45592c3061f241d437087 @yokolet yokolet committed Apr 29, 2010
@@ -185,6 +185,9 @@ public void inject(Ruby runtime, IRubyObject receiver) {
* @param receiver is the instance that will have variable injection.
*/
public void tryEagerInjection(Ruby runtime, IRubyObject receiver) {
+ // wreckages of global local vars might remain on runtime, which may cause
+ // assertion error since those names doesn't start from "$"
+ name = name.startsWith("$") ? name : ("$" + name).intern();
runtime.getGlobalVariables().set(name, irubyObject);
}
@@ -146,7 +146,7 @@ public static boolean isValidName(Object name) {
*/
@Override
public void inject(Ruby runtime, IRubyObject receiver) {
- runtime.getGlobalVariables().set("$"+name, irubyObject);
+ runtime.getGlobalVariables().set(("$"+name).intern(), irubyObject);
}
/**
@@ -157,6 +157,6 @@ public void inject(Ruby runtime, IRubyObject receiver) {
@Override
public void remove(Ruby runtime) {
setJavaObject(runtime, null);
- runtime.getGlobalVariables().set("$"+name, irubyObject);
+ runtime.getGlobalVariables().set(("$"+name).intern(), irubyObject);
}
}

0 comments on commit a1e0c4d

Please sign in to comment.