> What i'm looking to do is to serve dynamically generated Javascript
> from a J2EE application. I'd like to see if there are Javascript
[quoted text clipped - 3 lines]
> to tell if there are compile time exceptions in the JS? An alternative
> or other suggestions are welcome! Thank you.
When I google for "javascript interpreter for java" I get
http://www.mozilla.org/rhino/
- Oliver
alexandre_paterson@yahoo.fr - 26 May 2006 14:46 GMT
> > What i'm looking to do is to serve dynamically generated Javascript
> > from a J2EE application. I'd like to see if there are Javascript
[quoted text clipped - 6 lines]
> When I google for "javascript interpreter for java" I get
> http://www.mozilla.org/rhino/
I'd indeed expect "Rhino" to be one of the first matches, for Rhino
is actually included in Java 1.6
:)
> What i'm looking to do is to serve dynamically generated Javascript
> from a J2EE application. I'd like to see if there are Javascript
> compiler exceptions before i serve the JS to the browser.
The entirety of what you're asking for is absolutely IMPOSSIBLE, for any
sufficiently powerful language (of which JavaScript is considered
sufficiently powerful). Alan Turing and Alonzo Church both gave
independent proofs of this in 1936. There exists NO way to examine an
arbitrary piece of code and determine whether something will happen or
not in general.
That said, you can do as Oliver suggested and give it a few test runs
with Rhino. The problem will be in simulating the user's web browser
accurately enough to reproduce any problems that might come up. Are you
sure you want to re-implement the DOM for HTML, for instance? It will
be a lot of work, and it won't be perfect... but it still might be
better than nothing.

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Oliver Wong - 25 May 2006 21:18 GMT
>> What i'm looking to do is to serve dynamically generated Javascript
>> from a J2EE application. I'd like to see if there are Javascript
[quoted text clipped - 6 lines]
> arbitrary piece of code and determine whether something will happen or
> not in general.
I had assumed by "compiler exceptions", the OP meant they wanted to
check for syntax errors (e.g. missing braces or parentheses). The usefulness
of this? Perhaps as unit tests, or because the generated JavaScript depends
on user provided input. If the OP is indeed asking about behaviour of
syntactically legal JavaScript, then Chris is right: it's impossible, and a
summary of why is at http://en.wikipedia.org/wiki/Halting_problem
- Oliver