require "java" URLClassLoader = java.net.URLClassLoader JFile = java.io.File JURL = java.net.URL JClass = java.lang.Class JObject = java.lang.Object # make file objects out of strings jFile1 = JFile.new("/someplace/wrapper-sesame2.jar") jFile2 = JFile.new("/someplace/openrdf-sesame-2.0-alpha4-onejar.jar") #jFile1 = JFile.new("/home/metaman/workspaces/deri-workspace/activerdf/activerdf-sesame/ext/wrapper-sesame2.jar") #jFile2 = JFile.new("/home/metaman/workspaces/deri-workspace/activerdf/activerdf-sesame/ext/openrdf-sesame-2.0-alpha4-onejar.jar") # make an array of URL, which contains the URLs corresponding to the files uris = JURL[].new(2) uris[0] = jFile1.toURL uris[1] = jFile2.toURL # this is our custom class loader, yay! myClassLoader = URLClassLoader.new(uris) # and now we want our custom class loader to actually do some work # --> fetch us the class object for the specified class name, # intialize that class object, and use the specified class loader for it classWrapper = JClass.forName("org.activerdf.wrapper.sesame2.WrapperForSesame2", true, myClassLoader) # cool, so we got that class object, and it seems pretty valid: puts classWrapper.java_class # => java.lang.Class # put this does not work ! myWrapperInstance = classWrapper.new # instead we have to do this. this points to the guess that this is in fact # not a class object but a constuctor object # maybe this is the first bug here? myWrapperInstance = classWrapper.new_instance # okay, so far so good. the real problem is constructing the class with an # argument constructorArgs = JObject[].new(1) constructorArgs[0] = "/someplace/sesame-rep.s2" #constuctorArgs[0] = "/home/metaman/workspaces/deri-workspace/sioc-playground/data/sesame-rep.s2" myWrapperInstance = classWrapper.new_instance(constructorArgs) # NameError: no method 'newInstance' with arguments matching [[Ljava.lang.Object;] # from /mnt/small/jruby-workspace/jruby-trunk/src/builtin/javasupport.rb:433:in `matching_method' # from (irb):1:in `binding' # If I would have just said this: # WrapperForSesame2 = org.activerdf.wrapper.sesame2.WrapperForSesame2 # then I could say: # myWrapperInstance = WrapperForSesame2.new("/someplace/sesame-rep.s2") # no problem there. # --> this seems to be the second bug?