Java class loading problem at YAML::load when using "rest_client" gem
---------------------------------------------------------------------

                 Key: JRUBY-4986
                 URL: http://jira.codehaus.org/browse/JRUBY-4986
             Project: JRuby
          Issue Type: Bug
          Components: Java Integration
    Affects Versions: JRuby 1.5.1
         Environment: jruby 1.5.1 (ruby 1.8.7 patchlevel 249) (2010-06-06 
f3a3480) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_20) [x86_64-java]

rest-client-1.0.3

java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01-279, mixed mode)
            Reporter: Tobias Vogele


There is a strange exception at {{YAML::load}}, when:
* gem "rest_client" is loaded
* java.net.URI class is not loaded yet
* YAML text encodes a java.net.URI object

Here some code snippets to reproduce the problem:

{code:title=Works, because no rest_client gem is used}
require "rubygems"
require "yaml"
YAML::load("--- !ruby/object:Java::JavaNet::URI {}")
{code}

{code:title=Works, because java.net.URI is loaded explicitly}
require "rubygems"
require "rest_client"
require "yaml"
Java::JavaNet::URI.new("http://www.example.com";) # load the java.net.URI class
YAML::load("--- !ruby/object:Java::JavaNet::URI {}")
{code}

{code:title=throws exception}
require "rubygems"
require "rest_client"
require "yaml"
YAML::load("--- !ruby/object:Java::JavaNet::URI {}")
{code}


This is the complete stacktrace of the exception:
{noformat}
Resolver.java:126:in `transfer': java.lang.ClassCastException: 
org.jruby.RubyModule cannot be cast to org.jruby.RubyClass
        from 
org/yecht/ruby/Resolver$s_method_2_0$RUBYINVOKER$transfer.gen:65535:in `call'
        from JavaMethod.java:987:in `call'
        from RubyClass.java:644:in `finvoke'
        from RuntimeHelpers.java:461:in `invoke'
        from RubyBasicObject.java:340:in `callMethod'
        from DefaultResolver.java:456:in `node_import'
        from 
org/yecht/ruby/DefaultResolver$s_method_1_0$RUBYINVOKER$node_import.gen:65535:in
 `call'
        from CachingCallSite.java:309:in `cacheAndCall'
        from CachingCallSite.java:148:in `call'
        from RubyLoadHandler.java:40:in `handle'
        from Parser.java:300:in `addNode'
        from DefaultYAMLParser.java:365:in `yyparse'
        from Parser.java:290:in `yechtparse'
        from Parser.java:284:in `parse'
        from YParser.java:152:in `load'
        from org/yecht/ruby/YParser$s_method_0_1$RUBYINVOKER$load.gen:65535:in 
`call'
        from JavaMethod.java:630:in `call'
        from DynamicMethod.java:186:in `call'
        from CachingCallSite.java:309:in `cacheAndCall'
        from CachingCallSite.java:148:in `call'
        from CallOneArgNode.java:57:in `interpret'
        from LocalAsgnNode.java:123:in `interpret'
        from NewlineNode.java:104:in `interpret'
        from InterpretedMethod.java:180:in `call'
        from DefaultMethod.java:172:in `call'
        from CachingCallSite.java:309:in `cacheAndCall'
        from CachingCallSite.java:148:in `call'
        from yamltest.rb:4:in `__file__'
        from yamltest.rb:-1:in `load'
        from Ruby.java:685:in `runScript'
        from Ruby.java:568:in `runNormally'
        from Ruby.java:414:in `runFromMain'
        from Main.java:286:in `run'
        from Main.java:128:in `run'
        from Main.java:97:in `main'
{noformat}


Note, that "works" here just means, that no exception is thrown. There is still 
the problem of JRUBY-4888.

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