far as I understand properly, at the very least you should be able to do that programmatically, like this (do not forget ExpandoMetaClass.enableGlobally()):

    def original=UnicastRemoteObject.metaClass.getMetaMethod("toString", new Class[])
    UnicastRemoteObject.metaClass.toString={ ->
        try { delegate.getName() }
        catch (MissingMethodException e) { original.invoke(delegate) }

There might possibly be an easier/more flexible solution, which I don't see offhand.

All the best,

On 17 Jul 2020, at 16:18, Alberto <> wrote:

Hi all,

I'm trying to extend a class so that it has a different toString, but only in specific cases.

I don't know for sure if this is possible, but what I'd like to do is:

    static String toString(UnicastRemoteObject self) {
        try {
            return self.getName();
        } catch (MissingMethodException e) {
            return // return the to string from Unicast.

Is it possible at all to call the original toString?

Alberto Ingenito