Sadly it's not simply overloaded...
I'm trying to upgrade my application from railo 3.3 to 4.1
I'm using the underlying java methods quite often and most of the time this is not a problem. I have an array that I'm sorting using a java Comparator object:
a.sort(
createObject(
"java",
"AlphanumComparator",
"/model/java/AlphanumComparator.jar"
)
);
Which runs fine on 3.3. But with the new member functions in 4.0 a new array.sort
method is added which runs the same as arraySort()
.
Now I get the following error:
invalid sort type [AlphanumComparator@someid], sort types are [text, textNoCase, numeric]
dumping the getClass()
shows the original java method is still there but I cannot seem to call it...
I believe that the .sort()
method you were calling in 3.3 was "merely" an implementation detail of Railo's railo.runtime.type.ArrayImpl
class, rather than a generic (standard) Java class. So that put you at risk that the implementation might change anyway - and it has.
A small code change will allow you to use java.util.Collections
and the static sort()
method there:
var Collections = createObject( "java", "java.util.Collections" );
Collections.sort( a, createObject( "java",
"AlphanumComparator",
"/model/java/AlphanumComparator.jar" ) );
I tested this on Railo 4.0.4.001 using a CFML array of strings and the default java.text.Collator
so I believe it will work with your java.util.Comparator
implementation too.