ClassCastException occurs when Object#instance_eval is invoked
--------------------------------------------------------------

                 Key: JRUBY-942
                 URL: http://jira.codehaus.org/browse/JRUBY-942
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.0.0RC1
            Reporter: Koichiro Ohba
         Attachments: rubyobject.patch

Hi,

The exception ocuurs when instance_eval is invoked with the non-String 2nd 
argument.
Please check my patch.

{code}
require 'pathname'

class InstanceEvalTest
  def initialize(file)
    instance_eval( "def hello; p 'hello'; end", file , 1)
  end
end

InstanceEvalTest.new(File.new($0))
{code}


result:
{code}
$ jruby.bat test/test_cast.rb
RubyObject.java:827:in `org.jruby.RubyObject$2.execute': 
java.lang.ClassCastException: org.jruby.RubyObject (NativeException)
        from RubyModule.java:1146:in `org.jruby.RubyModule.executeUnder'
        from RubyObject.java:819:in `org.jruby.RubyObject.evalUnder'
        from RubyObject.java:805:in `org.jruby.RubyObject.specificEval'
        from RubyObject.java:1314:in `org.jruby.RubyObject.instance_eval'
        from null:-1:in `org.jruby.RubyObjectInvokerinstance_evalxx1.call'
        from InvocationCallback.java:49:in 
`org.jruby.runtime.callback.InvocationCallback.execute'
        from FullFunctionCallbackMethod.java:79:in 
`org.jruby.internal.runtime.methods.FullFunctionCallbackMethod.internalCall'
        from DynamicMethod.java:79:in 
`org.jruby.internal.runtime.methods.DynamicMethod.call'
         ... 81 levels...
        from :-1:in `initialize'
        from :-1:in `new'
        from :-1
Complete Java stackTrace
java.lang.ClassCastException: org.jruby.RubyObject
        at org.jruby.RubyObject$2.execute(RubyObject.java:827)
        at org.jruby.RubyModule.executeUnder(RubyModule.java:1146)
        at org.jruby.RubyObject.evalUnder(RubyObject.java:819)
        at org.jruby.RubyObject.specificEval(RubyObject.java:805)
        at org.jruby.RubyObject.instance_eval(RubyObject.java:1314)
        at org.jruby.RubyObjectInvokerinstance_evalxx1.call(Unknown Source)
        at 
org.jruby.runtime.callback.InvocationCallback.execute(InvocationCallback.java:49)
        at 
org.jruby.internal.runtime.methods.FullFunctionCallbackMethod.internalCall(FullFunctionCallbackMethod.java:79)
        at 
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:79)
        at org.jruby.RubyObject.compilerCallMethod(RubyObject.java:510)
        at 
org.jruby.javasupport.util.CompilerHelpers.doInvokeDynamic(CompilerHelpers.java:123)
        at EVAL27535250.initialize__1(EVAL27535250:5)
        at EVAL27535250Invokerinitialize__1Fixed0.call(Unknown Source)
        at 
org.jruby.internal.runtime.methods.CompiledMethod.call(CompiledMethod.java:79)
        at org.jruby.RubyObject.callMethod(RubyObject.java:572)
        at org.jruby.RubyObject.callMethod(RubyObject.java:450)
        at org.jruby.RubyClass.newInstance(RubyClass.java:287)
        at org.jruby.RubyClassInvokernewInstancexx1.call(Unknown Source)
        at 
org.jruby.runtime.callback.InvocationCallback.execute(InvocationCallback.java:49)
        at 
org.jruby.internal.runtime.methods.FullFunctionCallbackMethod.internalCall(FullFunctionCallbackMethod.java:79)
        at 
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:79)
        at org.jruby.RubyObject.compilerCallMethod(RubyObject.java:510)
        at 
org.jruby.javasupport.util.CompilerHelpers.doInvokeDynamic(CompilerHelpers.java:123)
        at EVAL27535250.__file__(EVAL27535250:9)
        at EVAL27535250.run(EVAL27535250)
        at org.jruby.Ruby.compileOrFallbackAndRun(Ruby.java:306)
        at org.jruby.Main.runInterpreter(Main.java:233)
        at org.jruby.Main.runInterpreter(Main.java:190)
        at org.jruby.Main.run(Main.java:120)
        at org.jruby.Main.main(Main.java:95)
{code}


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to