How hacky are you allowed to be? The following works, but is "ugly" and you lose the ability to use class-specific methods.
public void myMethod(String... elements) {
myMethod((Object[]) elements);
}
public void myMethod(Class<?>... elements) {
myMethod((Object[]) elements);
}
public void myMethod(MyWidget... elements) {
myMethod((Object[]) elements);
}
private void myMethod(Object... elements) {
// do it here
}
On the other hand, are you sure that you are not running into an XY-problem? https://xyproblem.info/
I.e., what are you trying to achieve? Is this the best solution for it, or do you have tunnel vision for this problem, which was not your original problem?