JavaScript variable name mangling

230 views
Skip to first unread message

eliasb...@gmail.com

unread,
Jan 5, 2008, 8:53:48 AM1/5/08
to Google Web Toolkit
Trying to programmatically construct a JavaScript call in JSNI
function using 'eval' function
Problem is that the names of JavaScript variables I declare in JSNI
function and pass to 'eval' call are mangled in the compiled version
of the function making thus the 'eval' expression invalid generating a
related error.


Is there a way to either know the mangled name in advance (before GWT
compilation) or deactivate JavaScript variable names mangling for
desired JSNI functions?

Ian Petersen

unread,
Jan 5, 2008, 12:38:47 PM1/5/08
to Google-We...@googlegroups.com
On Jan 5, 2008 8:53 AM, eliasb...@gmail.com <eliasb...@gmail.com> wrote:
> Is there a way to either know the mangled name in advance (before GWT
> compilation) or deactivate JavaScript variable names mangling for
> desired JSNI functions?

Can't be done. You can turn off name mangling completely by passing
'-style PRETTY' to the compiler, but even then, you can't know for
sure that the signature of the method won't change because the
compiler might devirtualize it, or optimize it in some other way.

Can you explain what you're trying to accomplish with eval? Maybe
there's another way to do it.

Ian

--
Tired of pop-ups, security holes, and spyware?
Try Firefox: http://www.getfirefox.com

eliasb...@gmail.com

unread,
Jan 5, 2008, 1:00:34 PM1/5/08
to Google-We...@googlegroups.com
The trouble is that I am trying to use 'eval' to make a call to javascript
method that is programmatically discovered. But the variable name gets
mangled by the GWT compiler.

Here is a reference to another post with more detailed explanation.
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/7bb92
2e7a6644b24

Meanwhile I observed that if the variables in a JSNI function do not change
the mangling does not change either.
Can I assume this as a stable behaviour that will not change in the future?
(The problem was solved with code based on this exact assumption)

eliasb...@gmail.com

unread,
Jan 5, 2008, 1:03:33 PM1/5/08
to Google Web Toolkit
Here is the correct link to the more detailed post (it got corrupted)
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/7bb922e7a6644b24


On Jan 5, 8:00 pm, <eliasbala...@gmail.com> wrote:
> The trouble is that I am trying to use 'eval' to make a call to javascript
> method that is programmatically discovered. But the variable name gets
> mangled by the GWT compiler.
>
> Here is a reference to another post with more detailed explanation.http://groups.google.com/group/Google-Web-Toolkit/browse_thread/threa...
> 2e7a6644b24
>
> Meanwhile I observed that if the variables in a JSNI function do not change
> the mangling does not change either.
> Can I assume this as a stable behaviour that will not change in the future?
> (The problem was solved with code based on this exact assumption)
>
> -----Original Message-----
> From: Google-We...@googlegroups.com
>
> [mailto:Google-We...@googlegroups.com] On Behalf Of Ian Petersen
> Sent: Saturday, January 05, 2008 7:39 PM
> To: Google-We...@googlegroups.com
> Subject: Re: JavaScript variable name mangling
>
> On Jan 5, 2008 8:53 AM, eliasbala...@gmail.com <eliasbala...@gmail.com>

eliasb...@gmail.com

unread,
Jan 6, 2008, 12:33:56 PM1/6/08
to Google Web Toolkit
Here is an additional post reference (more detailed)

http://groups.google.com/group/Google-Web-Toolkit-Contributors/browse_thread/thread/aca8313a61d54c16


On Jan 5, 8:03 pm, "eliasbala...@gmail.com" <eliasbala...@gmail.com>
wrote:
> Here is the correct link to the more detailed post (it got corrupted)http://groups.google.com/group/Google-Web-Toolkit/browse_thread/threa...
>
> On Jan 5, 8:00 pm, <eliasbala...@gmail.com> wrote:
>
> > The trouble is that I am trying to use 'eval' to make a call to javascript
> > method that is programmatically discovered. But the variable name gets
> > mangled by the GWT compiler.
>
> > Here is a reference to another post with more detailed explanation.http://groups.google.com/group/Google-Web-Toolkit/browse_thread/threa...
> > 2e7a6644b24
>
> > Meanwhile I observed that if the variables in a JSNI function do not change
> > themanglingdoes not change either.
> > Can I assume this as a stable behaviour that will not change in the future?
> > (The problem was solved with code based on this exact assumption)
>
> > -----Original Message-----
> > From: Google-We...@googlegroups.com
>
> > [mailto:Google-We...@googlegroups.com] On Behalf Of Ian Petersen
> > Sent: Saturday, January 05, 2008 7:39 PM
> > To: Google-We...@googlegroups.com
> > Subject: Re: JavaScript variable namemangling
>
> > On Jan 5, 2008 8:53 AM, eliasbala...@gmail.com <eliasbala...@gmail.com>
> > wrote:
> > > Is there a way to either know the mangled name in advance (before GWT
> > > compilation) or deactivate JavaScript variable namesmanglingfor
> > > desired JSNI functions?
>
> > Can't be done. You can turn off namemanglingcompletely by passing
Reply all
Reply to author
Forward
0 new messages