Title: [1139] trunk/javasand/src/java/org/jruby/ext/sandbox: Fix for JRUBY-3229: Javasand does not compile with JRuby 1.1.5
Revision
1139
Author
headius
Date
2009-01-24 22:12:30 -0500 (Sat, 24 Jan 2009)

Log Message

Fix for JRUBY-3229: Javasand does not compile with JRuby 1.1.5

Modified Paths


Diff

Modified: trunk/javasand/src/java/org/jruby/ext/sandbox/SandboxFull.java (1138 => 1139)


--- trunk/javasand/src/java/org/jruby/ext/sandbox/SandboxFull.java	2008-12-17 17:56:32 UTC (rev 1138)
+++ trunk/javasand/src/java/org/jruby/ext/sandbox/SandboxFull.java	2009-01-25 03:12:30 UTC (rev 1139)
@@ -83,7 +83,7 @@
         IRubyObject init = args[0].callMethod(recv.getRuntime().getCurrentContext(),"[]",recv.getRuntime().newSymbol("init"));
         if(!init.isNil()) {
             boolean load=false, env=false, io=false, real=false;
-            init = RubyKernel.new_array(recv.getRuntime().getModule("Kernel"),init);
+            init = RubyKernel.new_array(recv.getRuntime().getCurrentContext(),recv.getRuntime().getModule("Kernel"),init);
             for(Iterator iter = ((RubyArray)init).getList().iterator();iter.hasNext();) {
                 IRubyObject mod = (IRubyObject)iter.next();
                 if(mod == recv.getRuntime().newSymbol("load")) {
@@ -133,7 +133,7 @@
 
         IRubyObject imp = args[0].callMethod(recv.getRuntime().getCurrentContext(),"[]",recv.getRuntime().newSymbol("import"));
         if(!imp.isNil()) {
-            imp = RubyKernel.new_array(recv.getRuntime().getModule("Kernel"),imp);
+            imp = RubyKernel.new_array(recv.getRuntime().getCurrentContext(),recv.getRuntime().getModule("Kernel"),imp);
             for(Iterator iter = ((RubyArray)imp).getList().iterator();iter.hasNext();) {
                 IRubyObject mod = (IRubyObject)iter.next();
                 _import(recv,mod);
@@ -142,14 +142,14 @@
 
         IRubyObject ref = args[0].callMethod(recv.getRuntime().getCurrentContext(),"[]",recv.getRuntime().newSymbol("ref"));
         if(!ref.isNil()) {
-            ref = RubyKernel.new_array(recv.getRuntime().getModule("Kernel"),ref);
+            ref = RubyKernel.new_array(recv.getRuntime().getCurrentContext(),recv.getRuntime().getModule("Kernel"),ref);
             for(Iterator iter = ((RubyArray)ref).getList().iterator();iter.hasNext();) {
                 IRubyObject mod = (IRubyObject)iter.next();
                 ref(recv,mod);
             }
         }
 
-        recv.setInstanceVariable("@options",args[0]);
+        recv.getInstanceVariables().setInstanceVariable("@options",args[0]);
         return recv;
     }
 

Modified: trunk/javasand/src/java/org/jruby/ext/sandbox/Sandkit.java (1138 => 1139)


--- trunk/javasand/src/java/org/jruby/ext/sandbox/Sandkit.java	2008-12-17 17:56:32 UTC (rev 1138)
+++ trunk/javasand/src/java/org/jruby/ext/sandbox/Sandkit.java	2009-01-25 03:12:30 UTC (rev 1139)
@@ -40,6 +40,7 @@
 import org.jruby.RubyString;
 import org.jruby.RubySymbol;
 
+import org.jruby.common.IRubyWarnings;
 import org.jruby.exceptions.RaiseException;
 import org.jruby.runtime.builtin.IRubyObject;
 import org.jruby.runtime.CallbackFactory;
@@ -711,7 +712,7 @@
                     String m_name = (String)ems.next();
                     if(!retain.contains(m_name)) {
                         //                        System.err.println("removing method " + m_name + " from " + name);
-                        mod.removeMethod(m_name);
+                        mod.removeMethod(this.runtime.getCurrentContext(),m_name);
                     }
                 }
             }
@@ -725,7 +726,7 @@
                     String m_name = (String)ems.next();
                     if(!retain.contains(m_name)) {
                         //                        System.err.println("removing singleton method " + m_name + " from " + name);
-                        mod.removeMethod(m_name);
+                        mod.removeMethod(this.runtime.getCurrentContext(),m_name);
                     }
                 }
             }
@@ -748,7 +749,8 @@
         
         removeMethods();
 
-        wrapped.getLoadService().load(runtime.getModule("Sandbox").getConstant("PRELUDE").toString());
+        // not sure what the wrap parameter does, testing with true
+        wrapped.getLoadService().load(runtime.getModule("Sandbox").getConstant("PRELUDE").toString(), true);
     }
 
     public static IRubyObject boxedclass_method_missing(IRubyObject recv, IRubyObject[] args) {
@@ -779,14 +781,14 @@
 
     public IRubyObject eval(IRubyObject str) {
         try {
-            return unbox(wrapped.evalScript(str.toString()));
+            return unbox(wrapped.evalScriptlet(str.toString()));
         } catch(RaiseException e) {
             String msg = e.getException().callMethod(wrapped.getCurrentContext(),"message").toString();
             String path = e.getException().type().getName();
             throw new RaiseException(runtime,(RubyClass)rb_eSandboxException,path + ": " + msg, false);
         } catch(Exception e) {
             e.printStackTrace();
-            runtime.getWarnings().warn("NativeException: " + e);
+            runtime.getWarnings().warn(IRubyWarnings.ID.MISCELLANEOUS, "NativeException: " + e, null);
             return runtime.getNil();
         }
     }
@@ -829,23 +831,23 @@
 
     private static IRubyObject getLinkedClass(IRubyObject arg) {
         IRubyObject c = arg.getRuntime().getNil();
-        if(arg.getInstanceVariables().get("__link__") != null) {
-            c = (IRubyObject)arg.getInstanceVariables().get("__link__");
+        if(arg.getInstanceVariables().getInstanceVariable("__link__") != null) {
+            c = (IRubyObject)arg.getInstanceVariables().fastGetInstanceVariable("__link__");
         }
         return c;
     }
     
     private static IRubyObject getLinkedBox(IRubyObject arg) {
         IRubyObject c = arg.getRuntime().getNil();
-        if(arg.getInstanceVariables().get("__box__") != null) {
-            c = (IRubyObject)arg.getInstanceVariables().get("__box__");
+        if(arg.getInstanceVariables().getInstanceVariable("__box__") != null) {
+            c = (IRubyObject)arg.getInstanceVariables().fastGetInstanceVariable("__box__");
         }
         return c;
     }
 
     private void linkClass(IRubyObject c, IRubyObject kitc) {
-        kitc.getInstanceVariables().put("__link__",c);
-        kitc.getInstanceVariables().put("__box__",ruby_sandbox);
+        kitc.getInstanceVariables().setInstanceVariable("__link__",c);
+        kitc.getInstanceVariables().setInstanceVariable("__box__",ruby_sandbox);
     }
 
     private IRubyObject constFind(Ruby w, String path) {
@@ -868,7 +870,7 @@
         
         for(int i=0;i<parts.length;i++) {
             c = (RubyModule)c.getConstantAt(parts[i]);
-            if(kitc.const_defined(wrapped.newString(parts[i])).isFalse()) {
+            if(kitc.const_defined_p(wrapped.getCurrentContext(), wrapped.newString(parts[i])).isFalse()) {
                 RubyModule sup = wrapped.getClass("BoxedClass");
                 if(!link) {
                     sup = import_class_path(c.getSuperClass().getName(),link);
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to