The authors of a test tool have unilaterally decided that you [...] are [not] allowed to use a comparator function that they didn't provide,
A more accurate summary would be that a test tool uses a special class as a sentinel and complains if a sentinel value turns up in a place where it has no business being. Meanwhile, a sloppy hack to get around draconian type checking had the side effect of making a non-sentinel appear to be a sentinel. The solution was to make the hack slightly less sloppy.
I would put more blame on the type checking that requires the hack than on the use of an internal class name as a way to create and detect sentinels.