JRuby

ClassCastException occurs when Object#instance_eval is invoked

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.0.0RC1
  • Fix Version/s: JRuby 1.0.0RC3
  • Component/s: Core Classes/Modules
  • Labels:
    None
  • Number of attachments :
    1

Description

Hi,

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

require 'pathname'

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

InstanceEvalTest.new(File.new($0))

result:

$ 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)

Activity

Hide
Koichiro Ohba added a comment -

Oops!

I made a mistake.

x   InstanceEvalTest.new(File.new($0))
o   InstanceEvalTest.new(Pathname.new($0))
Show
Koichiro Ohba added a comment - Oops! I made a mistake.
x   InstanceEvalTest.new(File.new($0))
o   InstanceEvalTest.new(Pathname.new($0))
Hide
Thomas E Enebo added a comment -

This was fixed with my fixing of eval positioning fix from about a week back or so

Show
Thomas E Enebo added a comment - This was fixed with my fixing of eval positioning fix from about a week back or so

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: