Forum: JRuby toJavaObject() Not implemented for VariantObject

87f380c90154a04d83a3ce78ec35c878?d=identicon&s=25 Antonio Castellon (antonio_c66)
on 2013-09-19 12:20
I have a DLL win32ole to be executed, and it was implemented in C# NET.4
framework.
When I access to the execution of the methods asll was fine (the traces
shows to me that the methods are executed correctly) but when my ruby
code try to acquire the result it lanuch an exception:

------------------------------------------------
<code>


Exception in thread "main" org.jruby.embed.InvokeFailedException:
java.lang.RuntimeException: toJavaObject() Not implemented for
VariantObject
  at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.call(EmbedRubyObjectAdapterImpl.java:319)
  at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.callMethod(EmbedRubyObjectAdapterImpl.java:147)
  at
org.jruby.embed.ScriptingContainer.callMethod(ScriptingContainer.java:1400)
  at MyTest.getDocosane(MyTest.java:62)
  at MyTest.main(MyTest.java:115)
Caused by: java.lang.RuntimeException: toJavaObject() Not implemented
for VariantObject
  at
org.racob.com.VariantUtilities.variantToObject(VariantUtilities.java:124)
  at org.racob.com.Variant.toJavaObject(Variant.java:552)
  at
org.jruby.ext.win32ole.RubyWIN32OLE.fromVariant(RubyWIN32OLE.java:284)
  at
org.jruby.ext.win32ole.RubyWIN32OLE.invokeMethodOrGet(RubyWIN32OLE.java:206)
  at
org.jruby.ext.win32ole.RubyWIN32OLE.method_missing(RubyWIN32OLE.java:113)
  at
org.jruby.ext.win32ole.RubyWIN32OLE$INVOKER$i$0$0$method_missing.call(RubyWIN32OLE$INVOKER$i$0$0$method_missing.gen)
  at
org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:674)
  at
org.jruby.runtime.Helpers$MethodMissingMethod.call(Helpers.java:426)
  at
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:209)
  at
org.jruby.runtime.callsite.CachingCallSite.callMethodMissing(CachingCallSite.java:401)
  at
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:323)
  at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
  at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
  at org.jruby.ast.LocalAsgnNode.interpret(LocalAsgnNode.java:123)
  at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
  at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
  at
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
  at
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:139)
  at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:170)
  at org.jruby.RubyClass.finvoke(RubyClass.java:674)
  at org.jruby.runtime.Helpers.invoke(Helpers.java:474)
  at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.callEachType(EmbedRubyObjectAdapterImpl.java:351)
  at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.call(EmbedRubyObjectAdapterImpl.java:306)
  ... 4 more

</code>
------------------------------------------------
The C# result is an strcuture like this:

  public class OBJ_LIST
    {
        public const int COL_LEN = 12;
        public const string pMf = "RefPeak";

        public int[] cnos;
        public string l_names;
        public uint l_names_len;
        public int max_l_name_len;
        public string[] hdf;
        public float[][] pMf;
        public ROC[] s_locs;

        public OBJ_LIST();
    }

===== The inner structure is like :

 public struct ROC
    {
        public sbyte ftype;
        public sbyte lib;
        public int loc;

        public ROC(int dummy);
    }


Any suggestion? Exists any way to resolve it? any change in the origin
DLL to fix it..or anything to do in the Java side? anything to help to
develop in the jruby side?

Thanks in advance
Antonio
87f380c90154a04d83a3ce78ec35c878?d=identicon&s=25 Antonio Castellon (antonio_c66)
on 2013-09-19 13:49
Also, for more information about the error...if I executed directly the
ruby test file
with jruby, it launch this exception>


VariantUtilities.java:124:in `variantToObject':
java.lang.RuntimeException: toJavaObject() Not implemented for
VariantObject
        from Variant.java:552:in `toJavaObject'
        from RubyWIN32OLE.java:284:in `fromVariant'
        from RubyWIN32OLE.java:206:in `invokeMethodOrGet'
        from RubyWIN32OLE.java:113:in `method_missing'
        from RubyWIN32OLE$INVOKER$i$0$0$method_missing.gen:-1:in `call'
        from JavaMethod.java:674:in `call'
        from Helpers.java:426:in `call'
        from DynamicMethod.java:209:in `call'
        from CachingCallSite.java:401:in `callMethodMissing'
        from CachingCallSite.java:323:in `cacheAndCall'
        from CachingCallSite.java:170:in `call'
        from test.rb:5:in `__file__'
        from test.rb:-1:in `load'
        from Ruby.java:807:in `runScript'
        from Ruby.java:800:in `runScript'
        from Ruby.java:669:in `runNormally'
        from Ruby.java:518:in `runFromMain'
        from Main.java:390:in `doRunFromMain'
        from Main.java:279:in `internalRun'
        from Main.java:221:in `run'
        from Main.java:201:in `main'
87f380c90154a04d83a3ce78ec35c878?d=identicon&s=25 Antonio Castellon (antonio_c66)
on 2013-09-20 10:22
I recompiled the dll libraries where the strcutures are defined and
currently the error was change to:

variantToObject: unhandled VT 16420

the stacktrace is:

Exception in thread "main" org.jruby.embed.InvokeFailedException:
org.racob.com.ComFailException: variantToObject: unhandled VT 16420

  at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.call(EmbedRubyObjectAdapterImpl.java:319)
  at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.callMethod(EmbedRubyObjectAdapterImpl.java:147)
  at
org.jruby.embed.ScriptingContainer.callMethod(ScriptingContainer.java:1400)
  at MyTest.getDocosane(MyTest.java:62)
  at MyTest.main(MyTest.java:116)
Caused by: org.racob.com.ComFailException: variantToObject: unhandled VT
16420

  at org.racob.com.Dispatch.invokev0(Native Method)
  at org.racob.com.Dispatch.callO(Dispatch.java:208)
  at
org.jruby.ext.win32ole.RubyWIN32OLE.invokeMethodOrGet(RubyWIN32OLE.java:202)
  at
org.jruby.ext.win32ole.RubyWIN32OLE.method_missing(RubyWIN32OLE.java:113)
  at
org.jruby.ext.win32ole.RubyWIN32OLE$INVOKER$i$0$0$method_missing.call(RubyWIN32OLE$INVOKER$i$0$0$method_missing.gen)
  at
org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:674)
  at
org.jruby.runtime.Helpers$MethodMissingMethod.call(Helpers.java:426)
  at
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:201)
  at
org.jruby.runtime.callsite.CachingCallSite.callMethodMissing(CachingCallSite.java:393)
  at
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:303)
  at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:136)
  at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:60)
  at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
  at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:60)
  at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)
  at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
  at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
  at
org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
  at
org.jruby.runtime.InterpretedBlock.evalBlockBody(InterpretedBlock.java:384)
  at org.jruby.runtime.InterpretedBlock.yield(InterpretedBlock.java:357)
  at org.jruby.runtime.InterpretedBlock.yield(InterpretedBlock.java:312)
  at org.jruby.runtime.Block.yield(Block.java:142)
  at org.jruby.RubyRange.fixnumEach(RubyRange.java:443)
  at org.jruby.RubyRange.each19(RubyRange.java:459)
  at
org.jruby.RubyRange$INVOKER$i$0$0$each19.call(RubyRange$INVOKER$i$0$0$each19.gen)
  at
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:316)
  at
org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:145)
  at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:149)
  at org.jruby.ast.ForNode.interpret(ForNode.java:111)
  at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
  at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
  at
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
  at
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:139)
  at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:170)
  at org.jruby.RubyClass.finvoke(RubyClass.java:674)
  at org.jruby.runtime.Helpers.invoke(Helpers.java:474)
  at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.callEachType(EmbedRubyObjectAdapterImpl.java:351)
  at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.call(EmbedRubyObjectAdapterImpl.java:306)
  ... 4 more


Any idea? :-(
Thanks in advance
Antonio
13313ac2ec7ba7c43b1b952db034ff3b?d=identicon&s=25 Thomas E Enebo (Guest)
on 2013-09-20 17:24
(Received via mailing list)
Hmmm, I can tell you what it is but not really how it can be supported.
Perhaps you can look into what this object type is actually:

16384 of that vt value means it is a reference to a variant.  The 36
left
over I guess means it is of type VT_RECORD, which I have never seen nor
heard of before.  Racob under jruby-win32ole needs to be updated for
this
type assuming we can do something with it.  Possibly we could just keep
it
alive so it can be passed into other OLE methods?

-Tom
87f380c90154a04d83a3ce78ec35c878?d=identicon&s=25 Antonio Castellon (antonio_c66)
on 2013-09-23 08:10
Hi Tom,

Yes please, this variables are returned by a hidden DLL (no source code
available).
May be is possible that Racob try force to cast to a simple String
object or an Array of Strings (At the same time that throws a warning
about the type of the variable is not good to be used and needs to be
carefully with the returned data, because may be it could had lost some
parts of information in this automatic cast).
What do you think? it will be possible to do it? I can do anything to
help you to implement this part?

Thanks in advance,
Antonio
This topic is locked and can not be replied to.