[tcljava-user] Returning generics to TclBlend
Brought to you by:
mdejong
From: Tanzer, T. <tro...@am...> - 2007-04-09 19:48:32
|
I'm not sure if this belongs here or on the developer list, but here is my problem. We have a library of functions written in Java, and access the libraries using TclBlend. When those functions return a specific class of Java object, we can use them in the tcl scripts and call methods on them and all works fine. However, when those functions return generics (we are using Java 1.5), the TclBlend shell is confused. I can access the type of the object, but TclBlend sees it as only java.lang.Object, and only allows Object methods on it until I cast it. For example: Case 1) Java method returns an object of Type1 > set oTest [$oFactory getType1] > $oTest getElementValue ToolName Tool42 Case 2) Java method returns a generic (in this case, a Type1 object) > set oTest [$oFactory2 getType1] > $oTest getElementValue ToolName no accessible method "getElementValue" in class java.lang.Object > puts "[$oTest getClass]" Type1 > set oTest2 [java::cast Type1 $oTest] > $oTest2 getElementValue ToolName Tool42 So, I can access the class type on the Tcl side, and work around this on the Tcl side by casting to the correct object type. Is there anything I could do on the Java side (outside of not using generics) that would eliminate the need to cast the return to the correct type on the Tcl side? |