Hi,
This post will ask multiple related questions. I'm experimenting with writing a Java method in a class that returns something that can be interpreted as an Assoc. This is being done in Content Server 10.0 U201506. According to the documentation, the Oscript Assoc maps to java.util.Map. This is an abstract type in that Map is an interface, of which both Hashtable and HashMap are known descendents. When my java method returns a java.util.HashTable<string, string> or HashMap (of the same variety), and I call InvokeMethod(), it causes an AccessViolation exception and builder crashes.
I built myself another method to actually see what types are returned in Java for various Oscript types. Both Java and Oscript methods are further below. The interesting thing was that when I passed an Oscript Assoc to my new Java method, it identified it as com.opentext.util.CaseInsensitiveHashMap. I can sort of understand why this may have been done as Assoc has case-insensitive keys and the Map interface defines case sensitive. My questions therefore are:
1) Is there any plan to update the documentation shipped with CS 10.0?
2) When building a Java class that uses types like com.opentext.util.CaseInsensitiveHashMap, what jar do we need to load into our Eclipse so that we can effectively compile our Java classes?
3) Is it enough to rely on this jar being present in CS core, or do we need to also load this jar in our module's ojlib?
Those are the questions, here is the source:
-Hugh
My java method looks like this:
public String OscriptToJavaClass(Object obj) {
String retVal = "unknown";
Class myClass = obj.getClass();
if (myClass != null) {
retVal = myClass.getName();
}
return retVal;
}
My Oscript to call it looks like this:
List elems = {"My new string", Date.Now(), {1,2,3}, Assoc.CreateAssoc()}
Dynamic elem
Dynamic result
JavaObject jObj = JavaObject.New("ca.hferguson.jobj.CSBridge", {})
if !IsError(jObj )
for elem in elems
echo(Str.Format("Oscript data '%1'", elem))
result = jObj.InvokeMethod("OscriptToJavaClass", {elem})
if !isError( result )
echo(Str.Format("Java equivalent : %1", result) )
else
echo(Str.Format("Error invoking method: %1", result))
break
end
end
end