Polymorphic @JsonRequest argument

Hello.
Is there a way to use polymorphic object as @JsonRequest argument?

Consider following:

@JsonRequest("test")
public CompletableFuture<String> testEndpoint(Animal animal) {
    return CompletableFuture.completableFuture(((Dog) animal).breed);
}


public abstract class Animal {
    public String animalType;
}

public class Dog extends Animal {
    public String breed;
}

So if animalType == "Dog", deserialize request parameter into class Dog.

Is your problem Theia (https://github.com/eclipse-theia/theia) related?

You posted Java source code, while Theia runs on Javascript (close in name only).

I thought maybe someone had a similar problem since Theia uses vscode-jsonrpc.

All I know is that our current JSON-RPC system only handles Javascript primitive values and plain objects. The system won’t try to look up classes and try to instantiate those.

The pattern we use is to revive the parameters upon reception, manually:

import URI from '@theia/core/lib/common/uri';

class SomeService {
    async someMethod(uri: string): Promise<void> {
        const uri2 = new URI(uri);
        // ...
    }
}

Class information is lost upon serialization, unless you explicitly expose it through a field in your object.