Friday, September 2, 2011

variable not passed in generated JS code in finally block

I'm using GWT 2.4.0-rc1 and have hit a possible JS bug (not 100% sure
as I don't have a simple reproducer) and thought it's worth
sharing.

I wrote some Antlr based validation of user input in GWT client and
everything worked fine in debug mode but the compiled JS code never
called the logic that should be executed when there's no error (err =
false in code below)

So the issue is that if I've code like below

boolean err = false
try {
// do something that might fail due to exception
} catch (Throwable e) {
err = true;
// do something to process the error
} finally {
someLogicThatDependyOnErrValue(abc,def,err)
}

Then the generated js code assumes that err will always be false in
finally and pass false as param, i.e it creates

someLogicThatDependyOnErrValue(abc,def,false)

Note that instead or 'err', false is passed

My fix is to improve my needlessly complicated code (must have been
late night)

try {
// do something that might fail due to exception

// We should reach this point only if there's no error
someLogicThatDependyOnErrValue(abc,def,true)
} catch (Throwable e) {
// do something to process the error
}

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment