assets/src/org/ruboto/ScriptLoader.java in ruboto-0.9.0.rc.1 vs assets/src/org/ruboto/ScriptLoader.java in ruboto-0.9.0
- old
+ new
@@ -9,11 +9,11 @@
/**
Return true if we are called from JRuby.
*/
public static boolean isCalledFromJRuby() {
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
- int maxLookBack = Math.min(10, stackTraceElements.length);
+ int maxLookBack = Math.min(9, stackTraceElements.length);
for(int i = 0; i < maxLookBack ; i++){
if (stackTraceElements[i].getClassName().startsWith("org.jruby.javasupport.JavaMethod")) {
return true;
}
}
@@ -24,11 +24,11 @@
try {
if (component.getScriptInfo().getScriptName() != null) {
System.out.println("Looking for Ruby class: " + component.getScriptInfo().getRubyClassName());
Object rubyClass = JRubyAdapter.get(component.getScriptInfo().getRubyClassName());
System.out.println("Found: " + rubyClass);
- Script rubyScript = new Script(component.getScriptInfo().getScriptName());
+ final Script rubyScript = new Script(component.getScriptInfo().getScriptName());
Object rubyInstance;
if (rubyScript.exists()) {
rubyInstance = component;
final String script = rubyScript.getContents();
if (script.matches("(?s).*class " + component.getScriptInfo().getRubyClassName() + ".*")) {
@@ -59,11 +59,11 @@
JRubyAdapter.put(component.getScriptInfo().getRubyClassName(), JRubyAdapter.runScriptlet("Java::" + component.getClass().getName()));
}
System.out.println("Set class: " + JRubyAdapter.get(component.getScriptInfo().getRubyClassName()));
Thread t = new Thread(new Runnable(){
public void run() {
- JRubyAdapter.setScriptFilename(component.getScriptInfo().getScriptName());
+ JRubyAdapter.setScriptFilename(rubyScript.getAbsolutePath());
JRubyAdapter.runScriptlet(script);
}
});
try {
t.start();
@@ -79,10 +79,10 @@
if (!JRubyAdapter.isJRubyPreOneSeven()) {
JRubyAdapter.runScriptlet("Java::" + component.getClass().getName() + ".__persistent__ = true");
}
JRubyAdapter.runScriptlet("$activity.instance_variable_set '@ruboto_java_class', '" + component.getScriptInfo().getRubyClassName() + "'");
JRubyAdapter.runScriptlet("puts %Q{$activity: #$activity}");
- JRubyAdapter.setScriptFilename(component.getScriptInfo().getScriptName());
+ JRubyAdapter.setScriptFilename(rubyScript.getAbsolutePath());
JRubyAdapter.runScriptlet(script);
}
}
} else if (rubyClass != null) {
// We have a predefined Ruby class without corresponding Ruby source file.