The problem is the GWT compiler needs to know *exactly* which exception types the client can receive over an RPC call, so it knows to include code to deserialize the exception instance if it is thrown by that RPC call. The compiler cannot simply include JavaScript code for every possible RuntimeException and Error class out there, as that would bloat the page size out to something completely unreasonable.
Declaring the RuntimeExceptions in the throws declaration of the method permits the compiler to see which types it needs to include serialization code for, and tells the servlet its safe to send these types to the client because the client has the necessary code. Without that, the servlet has to err on the side of caution and assume the client doesn't know how to deserialize that exception type. On Wed, Dec 31, 2008 at 07:21, deanhiller <[email protected]> wrote: > > Isn't that like saying I want your RuntimeExceptions to be checked > Exceptions? There is actually more to the issue here though as > well.... > > The problem I am running into though is we have a ServletFilter for > security purposes used by all our apps. Developers don't add throws > GwtSessionTimeout as none of the methods really throw this > exception...it is marshalled by the ServletFilter when the session > times out but that fails when developers forget to add "throws > GwtSessionTimeout" to their method which i would prefer they would not > need that statement at all especially since they don't throw that > exception. > > Forcing people to declare RuntimeExceptions we want noticed by the GWT > client is like forcing us to have checked Exceptions....ie. forcing me > to do a throws GwtSessionTimeout means I mine as well not have > RuntimeExceptions and only have checked exceptions......In some > regards, I almost prefer C# here where they are all Runtime and no > checked exceptions. > > thanks, > Dean > > > On Dec 31, 12:47 am, Jason Morris <[email protected]> wrote: > > An Exception is expected from RPC if it is declared (in which case the > compiler will have generated > > the required Serialization code). > > > > I find declaring your RuntimeExceptions to be "good practice" anyways, > since it notifies developers > > that can't see your source code of what Exceptions may be thrown (even if > they don't catch and > > handle them). It also serves to inform IDE's of what catch statements to > generate. > > > > There is no need for a patch to the RPC class (someone can correct me if > I'm wrong, but it may even > > be dangerous, since I'm not sure the compiler will see a need for the > Serialization code to be > > generated). > > > > Hope that helps, > > Jason. > > > > deanhiller wrote: > > > Can someone add the following code to RPC.isExpectedException(Method > > > serviceIntfMethod, Throwable cause) at the very beginning...... > > > > > if(cause instanceof RuntimeException && cause instanceof > > > IsSerializable) > > > return true; > > > > > Can someone fix this? I can't throw a RuntimeException as this code > > > prevents it!!!! It turns it into a StatusCodeException with > > > exc.getCause returning null. My Exception implements IsSerializable > > > so I think it should be allowable but GWT code does not allow it :(. > > > This is a quick bug fix. Where can I post it to get it into the next > > > release? > > > > > thanks, > > > Dean > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
