Issue Details (XML | Word | Printable)

Key: JRUBY-942
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Thomas E Enebo
Reporter: Koichiro Ohba
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
JRuby

ClassCastException occurs when Object#instance_eval is invoked

Created: 16/May/07 05:00 AM   Updated: 22/Dec/07 06:29 AM
Component/s: Core Classes/Modules
Affects Version/s: JRuby 1.0.0RC1
Fix Version/s: JRuby 1.0.0RC3

Time Tracking:
Not Specified

File Attachments: 1. Text File rubyobject.patch (1 kB)



 Description  « Hide
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)


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Koichiro Ohba added a comment - 16/May/07 09:10 AM
Oops!

I made a mistake.

x   InstanceEvalTest.new(File.new($0))
o   InstanceEvalTest.new(Pathname.new($0))

Thomas E Enebo added a comment - 30/May/07 01:18 PM
This was fixed with my fixing of eval positioning fix from about a week back or so