Class<?> baseClass = ...
Object obj = ...
Is there a way in GWT to check whether obj‘s type implements/extends baseClass? (that’s client-side code).
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
JRE emulation reference says isInstance() is not supported.
You can use
obj instanceOf SomeConcrete.class, and all classes have to be known at compile time. GWT compiler needs to know all the types at compile time (so that it can generate appropriate JavaScript code) so true runtime reflection isn’t possible. I think GWT’s approach to that is deferred binding so that you don’t have to check.Here’s a presentation from the 2008 Google IO about this topic:
Seems like there’s a project for this, gwt-reflection, but I haven’t used it.