This is really a Java question, and someone can correct me if I am wrong, but I’m afraid there is no way to make this as specific as you would like without producing some warning.
The compiler would want Set.class in order not to produce a warning about the more specific type parameters for the wrapping ObjectProperty. However, due to type erasure (at runtime, the type parameters get converted e.g. to Object*), there is no such thing as Set.class . There is only one instance of Class at runtime**, which is Set.class and is the same for Set, Set etc. This is also why you cannot do e.g. “if (x instanceof Set)” - the information about the type parameter Integer does not exist at runtime when the test is executed. You can only test “if (x instanceof Set)”.
So, both approaches produce (different) warnings or errors. The compiler could (theoretically) suppress the warning/error in one of the cases, but then it would hide even further what is going on behind the scenes and that the operations are not necessarily fully safe in the general case.
Java Generics are quite limited, nowhere near what you can do with C++ templates, but still quite complicated when you go to the details.
Object or sometimes a more specific type, e.g. when using the “? extends Xyz” syntax for type parameters. See the
Java Language Specification for some details.
** possibly per classloader, but now this is getting really complicated…