I think you got the sense reversed (which I often do, too). declaringClass.asSubclass(RequestContext.class) works.
I'm open to look at caching, but would like to run with this before introducing any potential stateful bugs. On 2011/03/16 17:14:23, tbroyer wrote:
On 2011/03/16 16:52:48, drfibonacci wrote: > I removed the corresponding try/catch in ResolverServiceLayer also. > >
http://gwt-code-reviews.appspot.com/1384802/diff/6005/user/src/com/google/gwt/requestfactory/server/LocatorServiceLayer.java
> File
user/src/com/google/gwt/requestfactory/server/LocatorServiceLayer.java
> (right): > >
http://gwt-code-reviews.appspot.com/1384802/diff/6005/user/src/com/google/gwt/requestfactory/server/LocatorServiceLayer.java#newcode60
>
user/src/com/google/gwt/requestfactory/server/LocatorServiceLayer.java:60:
> getTop().resolveServiceClass((Class<? extends RequestContext>) declaringClass); > On 2011/03/16 13:54:02, tbroyer wrote: > > You're casting a Class to a Class, so it'll never fail. > > Good catch, forgot about type erasure. Done.
I wasn't commenting about the unused try/catch, but about the cast
which
wouldn't do what you'd have expected.
RequestContext.class.asSubclass(declaringClass) would cast the class
in a
type-safe manner *and* do the check for you (ensuring that
declaringClass
actually is a subclass of RequestContext, and throwing a
ClassCastException
otherwise).
Oh, and BTW, I still think the result of resolveServiceClass should be
cached in
ServiceLayerCache.
http://gwt-code-reviews.appspot.com/1384802/ -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
